Adds client-side code for codelenses commands that are not available in the language servers.
Some servers provide some codelenses that cannot be run by default on the server and need some client-code like rust-analyzer's runnables. Neovim provides the option to add custom commands for the clients and validates these before sending a command to a server.
This plugin intends to add that missing functionality.
-
This plugin DOES NOT intend to give an out of the box experience for LSP or DAP. Other plugins already accomplish this for certain languages, like rust-tools.nvim, or go.nvim.
-
This plugin DOES NOT manage your LSP codelenses, not showing them, not refreshing them. It only adds the commands for executed lenses that are not supported by the server.
rust-analyzer.runSingle
rust-analyzer.debugSingle
neovim nightly
(or a version that includes this commitplenary
(optional for rust-runnables debbug)dap
(optional for rust-runnables debbug)- for
rust-analyzer.debugSingle
command, a debug adapter configured for rust is required, codelldb will be used by default to launch. Instructions for this configuration can be found on the dap wiki
Use your favorite package manager.
Using packer.nvim:
use {
'E-ricus/lsp_codelens_extensions.nvim',
-- Only required for debugging
requires = { {"nvim-lua/plenary.nvim", "mfussenegger/nvim-dap"} }
}
Using the defaults you just need to call this on any part of your init.lua:
require("codelens_extensions").setup()
Or directly on packer:
use {
'E-ricus/lsp_codelens_extensions.nvim',
-- Only required for debugging
requires = { {"nvim-lua/plenary.nvim", "mfussenegger/nvim-dap"} }
config = function ()
require("codelens_extensions").setup()
end,
}
You can change either the split behavior or the debug_adapter used to run dap
Defaults:
require("codelens_extensions").setup {
vertical_split = false,
rust_debug_adapter = "codelldb",
init_rust_commands = true,
}
By default, this plugin will add the handler to the lens command, and add this command to vim.lsp
.
But you can change this flag and add the specific command on any part of your configuration, for example:
-- On your init.lua
require("codelens_extensions").setup {
init_rust_commands = false,
}
-- On your lsp config
vim.lsp.commands["rust-analyzer.runSingle"] = function(command)
require("codelens_extensions.rust-runnables").run_command(command.arguments[1].args)
end
2021-10-03.20-11-27.mov
Note: in this example you see nvim-dap-ui as this configuration opens the ui on dap.start()
. This plugin will only start the debug adapter, not the ui.