rcarriga / cmp-dap

nvim-cmp source for nvim-dap REPL and nvim-dap-ui buffers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when opening Telescope for the first time in a session

ayepezcalderon opened this issue · comments

After installing cmp-dap, when I try to open Telescope for the first time in an nvim session, the Telescope prompt immediately closes. Subsequent attempts to open Telescope work fine, but it is annoying to get buggy behavior on the first attempt.

I fixed this by using the following enabled function instead of the one given in the README:

enabled = function()
  local disabled = false
  disabled = disabled or (vim.api.nvim_buf_get_option(0, 'buftype') == 'prompt'
      and not require("cmp_dap").is_dap_buffer())
  disabled = disabled or (vim.fn.reg_recording() ~= '')
  disabled = disabled or (vim.fn.reg_executing() ~= '')
  return not disabled
end,

The enabled function above is the default enabled function of nvim-cmp, with the only exception that this line

disabled = disabled or (vim.api.nvim_buf_get_option(0, 'buftype') == 'prompt')

was replaced with this line

disabled = disabled or (vim.api.nvim_buf_get_option(0, 'buftype') == 'prompt'
    and not require("cmp_dap").is_dap_buffer())

I suggest to update the README with the above enabled function instead of the current one, which is causing the issue I described earlier with Telescope (and probably other "prompt" buftypes).