fix(nvim): update config of language servers
This commit is contained in:
parent
9cd7091efc
commit
3089967448
13 changed files with 54 additions and 73 deletions
|
@ -1,6 +1,2 @@
|
|||
local common = require('lsp.common')
|
||||
|
||||
require('lspconfig').ansiblels.setup {
|
||||
capabilities = common.cap,
|
||||
on_attach = common.attach,
|
||||
}
|
||||
|
|
|
@ -1,6 +1,2 @@
|
|||
local common = require('lsp.common')
|
||||
|
||||
require('lspconfig').bashls.setup {
|
||||
capabilities = common.cap,
|
||||
on_attach = common.attach,
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
local common = require('lsp.common')
|
||||
--Enable (broadcasting) snippet capability for completion
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
require('lspconfig').cssls.setup {
|
||||
capabilities = common.cap,
|
||||
on_attach = common.attach,
|
||||
cmd = { "vscode-css-languageserver", "--stdio" },
|
||||
require'lspconfig'.cssls.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
local common = require('lsp.common')
|
||||
|
||||
require('lspconfig').dockerls.setup {
|
||||
capabilities = common.cap,
|
||||
on_attach = common.attach,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
local common = require('lsp.common')
|
||||
|
||||
local eslint = {
|
||||
lintCommand = 'eslint -f visualstudio --stdin --stdin-filename ${INPUT}',
|
||||
lintIgnoreExitCode = true,
|
||||
|
@ -56,8 +54,6 @@ local hadolint = {
|
|||
|
||||
|
||||
require('lspconfig').efm.setup {
|
||||
capabilities = common.cap,
|
||||
on_attach = common.attach,
|
||||
filetypes = {
|
||||
"bash",
|
||||
"css",
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
local common = require('lsp.common')
|
||||
|
||||
require('lspconfig').bashls.setup {
|
||||
capabilities = common.cap,
|
||||
on_attach = common.attach,
|
||||
require('lspconfig').ember.setup {
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
local common = require('lsp.common')
|
||||
|
||||
require('lspconfig').esbonio.setup {
|
||||
capabilities = common.cap,
|
||||
on_attach = common.attach,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,2 @@
|
|||
local common = require('lsp.common')
|
||||
|
||||
require('lspconfig').golangci_lint_ls.setup {
|
||||
capabilities = common.cap,
|
||||
on_attach = common.attach,
|
||||
init_options = {
|
||||
command = { "golangci-lint", "run", "--out-format", "json" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,3 @@
|
|||
local common = require('lsp.common')
|
||||
|
||||
function OrgImports(wait_ms)
|
||||
local params = vim.lsp.util.make_range_params()
|
||||
params.context = {only = {"source.organizeImports"}}
|
||||
local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, wait_ms)
|
||||
for _, res in pairs(result or {}) do
|
||||
for _, r in pairs(res.result or {}) do
|
||||
if r.edit then
|
||||
vim.lsp.util.apply_workspace_edit(r.edit, "utf-16")
|
||||
else
|
||||
vim.lsp.buf.execute_command(r.command)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function format_with_imports(timeout_ms)
|
||||
OrgImports(1000)
|
||||
vim.lsp.buf.format()
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
pattern = '*.go',
|
||||
callback = function()
|
||||
|
@ -29,8 +7,6 @@ vim.api.nvim_create_autocmd('BufWritePre', {
|
|||
})
|
||||
|
||||
require('lspconfig').gopls.setup {
|
||||
capabilities = common.cap,
|
||||
on_attach = common.attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
local common = require('lsp.common')
|
||||
--Enable (broadcasting) snippet capability for completion
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
require('lspconfig').html.setup {
|
||||
capabilities = common.cap,
|
||||
on_attach = common.attach,
|
||||
cmd = { "vscode-html-languageserver", "--stdio" },
|
||||
capabilities = capabilities,
|
||||
filetypes = { "html", "template", "handlebars" },
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
local common = require('lsp.common')
|
||||
|
||||
require('lspconfig').tsserver.setup {
|
||||
capabilities = common.cap,
|
||||
on_attach = common.attach,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require('dotenv').setup({
|
||||
enable_on_load = true, -- will load your .env file upon loading a buffer
|
||||
verbose = true, -- show error notification if .env file is not found and if .env is loaded
|
||||
})
|
||||
--require('dotenv').setup({
|
||||
-- enable_on_load = true, -- will load your .env file upon loading a buffer
|
||||
-- verbose = true, -- show error notification if .env file is not found and if .env is loaded
|
||||
--})
|
||||
|
|
|
@ -21,3 +21,43 @@ end
|
|||
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" })
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" })
|
||||
|
||||
-- diagnostics
|
||||
local opts = { noremap=true, silent=true }
|
||||
vim.keymap.set('n', '<space>d', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
|
||||
vim.keymap.set('n', '<space>dp', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
||||
vim.keymap.set('n', '<space>dn', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
||||
vim.keymap.set('n', '<space>dl', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
|
||||
|
||||
-- Use LspAttach autocommand to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
||||
callback = function(ev)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
||||
|
||||
-- Buffer local mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local opts = { buffer = ev.buf, noremap=true, silent=true }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, opts)
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
||||
vim.keymap.set('n', '<space>f', function()
|
||||
vim.lsp.buf.format { async = true }
|
||||
end, opts)
|
||||
vim.keymap.set('n', '<space>s', vim.lsp.buf.document_highlight, opts)
|
||||
vim.keymap.set('n', '<space>ss', vim.lsp.buf.clear_references, opts)
|
||||
end,
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue