user/neovim: migrate to new lsp config syntax
This commit is contained in:
parent
892f9bfe73
commit
45a8eadeda
1 changed files with 40 additions and 35 deletions
|
|
@ -124,11 +124,15 @@ end
|
||||||
vim.cmd('au FileType javascript setlocal indentexpr=v:lua.javascript_indent()')
|
vim.cmd('au FileType javascript setlocal indentexpr=v:lua.javascript_indent()')
|
||||||
|
|
||||||
-- LSP
|
-- LSP
|
||||||
local nvim_lsp = require('lspconfig')
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
callback = function(args)
|
||||||
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||||
|
if not client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local on_attach = function(client, bufnr)
|
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(args.buf, ...) end
|
||||||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
local function buf_set_option(...) vim.api.nvim_buf_set_option(args.buf, ...) end
|
||||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
|
||||||
|
|
||||||
local opts = { noremap = true, silent = true }
|
local opts = { noremap = true, silent = true }
|
||||||
|
|
||||||
|
|
@ -149,7 +153,8 @@ local on_attach = function(client, bufnr)
|
||||||
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||||
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||||
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||||
end
|
end
|
||||||
|
})
|
||||||
|
|
||||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||||
|
|
@ -164,17 +169,15 @@ vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
|
||||||
vim.lsp.handlers.signature_help, { focusable = false }
|
vim.lsp.handlers.signature_help, { focusable = false }
|
||||||
)
|
)
|
||||||
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
||||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||||
|
|
||||||
local servers = { 'astro', 'clangd', 'cssls', 'html', 'nil_ls', 'tailwindcss', 'texlab', 'ts_ls', 'yamlls' }
|
local servers = { 'astro', 'clangd', 'cssls', 'html', 'nil_ls', 'tailwindcss', 'texlab', 'ts_ls', 'yamlls' }
|
||||||
for _, lsp in ipairs(servers) do
|
for _, lsp in ipairs(servers) do
|
||||||
nvim_lsp[lsp].setup {
|
vim.lsp.config(lsp, {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
|
||||||
flags = { debounce_text_changes = 150 }
|
flags = { debounce_text_changes = 150 }
|
||||||
}
|
})
|
||||||
|
vim.lsp.enable(lsp)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- nvim-cmp
|
-- nvim-cmp
|
||||||
|
|
@ -224,15 +227,16 @@ cmp.setup {
|
||||||
|
|
||||||
-- LSP/Omnisharp
|
-- LSP/Omnisharp
|
||||||
local pid = vim.fn.getpid()
|
local pid = vim.fn.getpid()
|
||||||
nvim_lsp.omnisharp.setup {
|
vim.lsp.config("omnisharp", {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
flags = { debounce_text_changes = 150 },
|
flags = { debounce_text_changes = 150 },
|
||||||
cmd = { "{{OMNISHARP_PATH}}", "--languageserver", "--hostPID", tostring(pid) }
|
cmd = { "{{OMNISHARP_PATH}}", "--languageserver", "--hostPID", tostring(pid) }
|
||||||
}
|
})
|
||||||
|
vim.lsp.enable("omnisharp")
|
||||||
|
|
||||||
-- LSP/rust_analyzer
|
-- LSP/rust_analyzer
|
||||||
nvim_lsp.rust_analyzer.setup {
|
vim.lsp.config("rust_analyzer", {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
flags = { debounce_text_changes = 150 },
|
flags = { debounce_text_changes = 150 },
|
||||||
|
|
@ -249,11 +253,11 @@ nvim_lsp.rust_analyzer.setup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
vim.lsp.enable("rust_analyzer")
|
||||||
|
|
||||||
-- LSP/Diagnostics
|
-- LSP/Diagnostics
|
||||||
nvim_lsp.diagnosticls.setup {
|
vim.lsp.config("diagnosticls", {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
flags = { debounce_text_changes = 150 },
|
flags = { debounce_text_changes = 150 },
|
||||||
|
|
@ -289,7 +293,8 @@ nvim_lsp.diagnosticls.setup {
|
||||||
vue = 'eslint'
|
vue = 'eslint'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
vim.lsp.enable("diagnosticls")
|
||||||
|
|
||||||
-- LSP/Signatures
|
-- LSP/Signatures
|
||||||
require("lsp_signature").setup {
|
require("lsp_signature").setup {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue