Skip to content

Commit

Permalink
chore: add deprecation notice to config.commands
Browse files Browse the repository at this point in the history
Add an example in help that demonstrates setting up the same
in an `on_attach` function
  • Loading branch information
ranjithshegde committed Aug 2, 2022
1 parent 431709d commit cf1c616
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions doc/lspconfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,31 @@ Example:
>
configs.texlab.buf_build = buf_build
<

Warning: Commands is deprecated and will be removed in future releases.
It is recommended to use `vim.api.nvim_create_user_command()` instead in an `on_attach` function.

Example:
>
local function organize_imports()
local params = {
command = 'pyright.organizeimports',
arguments = { vim.uri_from_bufnr(0) },
}
vim.lsp.buf.execute_command(params)
end
local on_attach = function(client, bufnr)
if client.name == "pyright" then
vim.api.nvim_create_user_command("PyrightOrganizeImports", organize_imports, {desc = 'Organize Imports'})
end
end
require("lspconfig")['pyright'].setup({
on_attach = on_attach
})
<

==============================================================================
ADDING NEW SERVERS *lspconfig-new*

Expand Down
1 change: 1 addition & 0 deletions lua/lspconfig/configs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function configs.__newindex(t, config_name, config_def)
commands = { config.commands, 't', true },
}
if config.commands then
vim.deprecate('lspconfig.[server].setup.commands', 'vim.api.nvim_create_user_command', '0.9', 'nvim-lspconfig')
for _, v in pairs(config.commands) do
validate {
name = { v.name, 's' },
Expand Down

0 comments on commit cf1c616

Please sign in to comment.