Giter Club home page Giter Club logo

cmp-dap's Introduction

cmp-dap

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

Setup

You must be using an adapter that supports completion requests. The following should print true when you are in an active debug session

:lua= require("dap").session().capabilities.supportsCompletionsRequest
require("cmp").setup({
  enabled = function()
    return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt"
        or require("cmp_dap").is_dap_buffer()
  end
})

require("cmp").setup.filetype({ "dap-repl", "dapui_watches", "dapui_hover" }, {
  sources = {
    { name = "dap" },
  },
})

cmp-dap's People

Contributors

liadoz avatar rcarriga avatar wookayin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cmp-dap's Issues

Error when using custom repl commands

The nvim-dap REPL can be customized to use custom commands using the following syntax:

local repl = require('dap.repl')
repl.commands = vim.tbl_extend('force', repl.commands, {
  custom_commands = {
    ['.restart'] = function()
      dap.restart()
      repl.open()
      vim.cmd.wincmd('j')
    end,
    ['.clear'] = repl.clear()
  },
})

When using these custom commands alongside cmp-dap, an error is thrown:

Error detected while processing TextChangedI Autocommands for "*":
Error executing lua callback: vim/shared.lua:0: s: expected string, got function
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'validate'
        vim/shared.lua: in function 'startswith'
        ...chan/.local/share/nvim/lazy/cmp-dap/lua/cmp_dap/init.lua:88: in function 'complete'
        .../chan/.local/share/nvim/lazy/nvim-cmp/lua/cmp/source.lua:334: in function 'complete'
        /home/chan/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:299: in function 'complete'
        /home/chan/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:169: in function 'callback'
        /home/chan/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:229: in function 'autoindent'
        /home/chan/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:161: in function 'on_change'
        /home/chan/.local/share/nvim/lazy/nvim-cmp/lua/cmp/init.lua:338: in function 'callback'
        ...local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:49: in function 'emit'
        ...local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:23: in function <...local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:22>

How to make it work

Silly question, but I can't seem to use it with Neovim 0.8.0.
My cmp config is quiet vast so I removed everything and just left the stuff from the README.
It still doesn't work and CmpStatus lists cmp-dap under unavailable source names.
Any rough ideas/caveats with this one?

Error when `supportsCompletionsRequest` is not supported

After playing with this plugin and diving into the source I've finally figured out why this did not work for me. I'm using PHP and the PHP debug adapter (https://github.com/xdebug/vscode-php-debug/) does not support supportsCompletionsRequest.

When it does not support the completions request I assume the plugin should just do nothing but it gives the following error:

Error executing vim.schedule lua callback: ...e/pack/packer/start/cmp-buffer/lua/cmp_buffer/buffer.lua:356: bad argument #1 to 'ipairs' (table expected, got userdata)
stack traceback:
        [C]: in function 'ipairs'
        ...e/pack/packer/start/cmp-buffer/lua/cmp_buffer/buffer.lua:356: in function 'rebuild_unique_words'
        ...e/pack/packer/start/cmp-buffer/lua/cmp_buffer/buffer.lua:341: in function 'get_words'
        ...e/pack/packer/start/cmp-buffer/lua/cmp_buffer/source.lua:66: in function ''
        vim/_editor.lua: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

It happens sometimes when I type in the REPL window. When I disable the plugin, the error is gone.

dap-repl buffer does not automatically close

Hello!
I am using nvim-dap with your nvim-dap-ui and lately also tried cmp-dap. I really like it, thank you!

Without cmp-dap, the repl buffer automatically closes when toggling/closing the dap-ui. The corresponding issue was raised here. Your workaround in this comment and your PR in nvim-dap both worked.
Now, after I included cmp-dap, the issue reappears. Could you imagine whether this is due to cmp-dap?

Error when opening Telescope for the first time in a session

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.