rcarriga / cmp-dap

nvim-cmp source for nvim-dap REPL and nvim-dap-ui buffers
MIT License
147 stars 8 forks source link

Error when opening Telescope for the first time in a session #11

Open ayepezcalderon opened 8 months ago

ayepezcalderon commented 8 months ago

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).