1
0
Fork 0

nvim: continue to support LSP config of <0.8.0

This commit is contained in:
tastytea 2022-10-29 07:06:29 +02:00
parent c0052e9c9f
commit c123a35457
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
1 changed files with 18 additions and 2 deletions

View File

@ -24,10 +24,26 @@ local on_attach = function(client, bufnr)
end, 'List workspace folders', bufnr)
map('n', '<Leader>lr', vim.lsp.buf.rename, 'Rename symbol', bufnr)
map('n', '<Leader>la', vim.lsp.buf.code_action, 'Code action', bufnr)
map('n', '<Leader>lf', vim.lsp.buf.format, 'Format buffer', bufnr)
if vim.fn.has('nvim-0.8.0') == 1 then
map('n', '<Leader>lf', vim.lsp.buf.format, 'Format buffer', bufnr)
else
map('n', '<Leader>lf', vim.lsp.buf.formatting, 'Format buffer', bufnr)
end
-- highlight symbol under cursor
if client.server_capabilities.documentHighlightProvider then
local has_highlight = false
if vim.fn.has('nvim-0.8.0') == 1 then
if client.server_capabilities.documentHighlightProvider then
has_highlight = true
end
else
if client.resolved_capabilities.document_highlight then
has_highlight = true
end
end
if has_highlight then
vim.api.nvim_create_augroup('config_lsp', { clear = false })
vim.api.nvim_clear_autocmds({
buffer = bufnr,