nvim: lsp: Sync with upstream
vim.lsp.buf.formatting function is deprecated and now replaces all the below three functions with vim.lsp.buf.format. - vim.lsp.buf.formatting - vim.lsp.buf.formatting_sync - vim.lsp.buf.formatting_seq_sync client.resolved_capabilities is no longer used. One must now access client.server_capabilities which matches the same structure as the protocol. https://microsoft.github.io/language-server-protocol/specification See neovim commit c618b31.
This commit is contained in:
parent
6d9a0d22c4
commit
59c9556325
1 changed files with 10 additions and 9 deletions
|
@ -61,8 +61,8 @@ protocol.CompletionItemKind = {
|
|||
local ts_utils_setup = function(client, bufnr, opts)
|
||||
if client.name == 'tsserver' then
|
||||
-- Disable tsserver formatting, we want formatting via prettier
|
||||
client.resolved_capabilities.document_formatting = false
|
||||
client.resolved_capabilities.document_range_formatting = false
|
||||
client.server_capabilities.documentFormattingProvider = false
|
||||
client.server_capabilities.documentRangeFormattingProvider = false
|
||||
|
||||
ts_utils.setup {
|
||||
debug = false,
|
||||
|
@ -125,25 +125,26 @@ local on_attach = function(client, bufnr)
|
|||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<Leader>k', '<cmd>lua vim.lsp.buf.hover()<CR>' , opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<Leader>S', '<cmd>lua vim.lsp.buf.signature_help()<CR>' , opts)
|
||||
|
||||
if client.resolved_capabilities.code_action then
|
||||
if client.server_capabilities.codeActionProvider then
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ga' , '<cmd>lua vim.lsp.buf.code_action()<CR>' , opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'v', 'ga' , '<cmd>lua vim.lsp.buf.range_code_action()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<Leader>r', '<cmd>lua vim.lsp.buf.code_action{ only = \'refactor\' }<CR>' , opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'v', '<Leader>r', '<cmd>lua vim.lsp.buf.range_code_action{ only = \'refactor\' }<CR>', opts)
|
||||
end
|
||||
|
||||
if client.resolved_capabilities.document_range_formatting then
|
||||
if client.server_capabilities.documentRangeFormattingProvider then
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'x', 'gq', '<cmd>lua FormatRangeOperator()<CR>', opts)
|
||||
end
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gq', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
|
||||
if client.server_capabilities.documentFormattingProvider then
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gq', '<cmd>lua vim.lsp.buf.format({async=true})<CR>', opts)
|
||||
end
|
||||
|
||||
if client.resolved_capabilities.code_lens or client.resolved_capabilities.document_highlight then
|
||||
if client.server_capabilities.codeLensProvider or client.server_capabilities.documentHighlightProvider then
|
||||
vim.api.nvim_create_augroup("LSP", {clear = true})
|
||||
end
|
||||
|
||||
if client.resolved_capabilities.code_lens then
|
||||
if client.server_capabilities.codeLensProvider then
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<Leader>l", "<cmd>lua vim.lsp.codelens.run()<CR>", opts)
|
||||
vim.api.nvim_create_autocmd({"CursorHold", "CursorHoldI", "InsertLeave"}, {
|
||||
group = "LSP",
|
||||
|
@ -161,7 +162,7 @@ local on_attach = function(client, bufnr)
|
|||
})
|
||||
end
|
||||
|
||||
if client.resolved_capabilities.document_highlight then
|
||||
if client.server_capabilities.documentHighlightProvider then
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
group = "LSP",
|
||||
buffer = bufnr,
|
||||
|
|
Loading…
Reference in a new issue