|
@@ -9,7 +9,6 @@ local nvim_lsp = require('lspconfig')
|
|
|
|
|
|
nvim_lsp.bashls.setup({
|
|
nvim_lsp.bashls.setup({
|
|
capabilities = capabilities,
|
|
capabilities = capabilities,
|
|
- on_attach = on_attach,
|
|
|
|
});
|
|
});
|
|
|
|
|
|
if vim.fn.executable("node_modules/.bin/eslint") == 1 then
|
|
if vim.fn.executable("node_modules/.bin/eslint") == 1 then
|
|
@@ -24,15 +23,18 @@ if vim.fn.executable("node_modules/.bin/eslint") == 1 then
|
|
settings = {
|
|
settings = {
|
|
options = options,
|
|
options = options,
|
|
},
|
|
},
|
|
- on_attach = function(client, bufnr)
|
|
|
|
|
|
+ handlers = {
|
|
|
|
+ ["client/registerCapability"] = function(err, result, ctx, config)
|
|
|
|
+ -- ignore as we can't handle any of this and it just spams the logs
|
|
|
|
+ return vim.NIL
|
|
|
|
+ end
|
|
|
|
+ },
|
|
|
|
+ on_init = function(client)
|
|
-- add formatting capability, the language server registers this
|
|
-- add formatting capability, the language server registers this
|
|
-- dynamically but neovim does not support that yet
|
|
-- dynamically but neovim does not support that yet
|
|
-- https://github.com/microsoft/vscode-eslint/pull/1307
|
|
-- https://github.com/microsoft/vscode-eslint/pull/1307
|
|
client.server_capabilities.documentFormattingProvider = true
|
|
client.server_capabilities.documentFormattingProvider = true
|
|
client.server_capabilities.documentRangeFormattingProvider = true
|
|
client.server_capabilities.documentRangeFormattingProvider = true
|
|
-
|
|
|
|
- -- mappings should have been attached by typescript and re-attaching can
|
|
|
|
- -- overwrite the typescript specific overrides
|
|
|
|
end,
|
|
end,
|
|
})
|
|
})
|
|
end
|
|
end
|
|
@@ -47,7 +49,6 @@ end
|
|
if vim.fn.executable("deno") == 1 then
|
|
if vim.fn.executable("deno") == 1 then
|
|
nvim_lsp.denols.setup({
|
|
nvim_lsp.denols.setup({
|
|
capabilities = capabilities,
|
|
capabilities = capabilities,
|
|
- on_attach = on_attach,
|
|
|
|
});
|
|
});
|
|
else
|
|
else
|
|
require('typescript').setup({
|
|
require('typescript').setup({
|
|
@@ -67,21 +68,12 @@ else
|
|
flags = {
|
|
flags = {
|
|
debounce_text_changes = 150,
|
|
debounce_text_changes = 150,
|
|
},
|
|
},
|
|
- on_attach = function(client, bufnr)
|
|
|
|
|
|
+ on_init = function(client)
|
|
-- mark tsserver as not having formatting available as we rely on
|
|
-- mark tsserver as not having formatting available as we rely on
|
|
- -- eslint for that
|
|
|
|
|
|
+ -- eslint and dprint for that
|
|
client.server_capabilities.documentFormattingProvider = false
|
|
client.server_capabilities.documentFormattingProvider = false
|
|
client.server_capabilities.documentRangeFormattingProvider = false
|
|
client.server_capabilities.documentRangeFormattingProvider = false
|
|
-
|
|
|
|
- on_attach(client, bufnr)
|
|
|
|
-
|
|
|
|
- -- override mappings for typescript
|
|
|
|
- local opts = { silent = true, buffer = bufnr }
|
|
|
|
- -- exclude import statements from reference search (may have false positives)
|
|
|
|
- vim.keymap.set('n', 'gr', '<cmd>Telescope lsp_references default_text=!import\\ <CR>', opts)
|
|
|
|
- vim.keymap.set('n', 'gD', '<cmd>Telescope lsp_definitions<CR>', opts)
|
|
|
|
- vim.keymap.set('n', 'gd', '<cmd>TypescriptGoToSourceDefinition<CR>', opts)
|
|
|
|
- end
|
|
|
|
|
|
+ end,
|
|
}
|
|
}
|
|
})
|
|
})
|
|
end
|
|
end
|
|
@@ -89,14 +81,12 @@ end
|
|
if vim.fn.executable("gopls") == 1 then
|
|
if vim.fn.executable("gopls") == 1 then
|
|
nvim_lsp.gopls.setup({
|
|
nvim_lsp.gopls.setup({
|
|
capabilities = capabilities,
|
|
capabilities = capabilities,
|
|
- on_attach = on_attach,
|
|
|
|
});
|
|
});
|
|
end
|
|
end
|
|
|
|
|
|
if vim.fn.executable("solargraph") == 1 then
|
|
if vim.fn.executable("solargraph") == 1 then
|
|
nvim_lsp.solargraph.setup({
|
|
nvim_lsp.solargraph.setup({
|
|
capabilities = capabilities,
|
|
capabilities = capabilities,
|
|
- on_attach = on_attach,
|
|
|
|
init_options = {
|
|
init_options = {
|
|
formatting = false,
|
|
formatting = false,
|
|
}
|
|
}
|
|
@@ -105,32 +95,20 @@ end
|
|
|
|
|
|
if vim.fn.executable("nil") == 1 then
|
|
if vim.fn.executable("nil") == 1 then
|
|
nvim_lsp.nil_ls.setup({
|
|
nvim_lsp.nil_ls.setup({
|
|
- on_attach = on_attach,
|
|
|
|
|
|
+ capabilities = capabilities,
|
|
});
|
|
});
|
|
end
|
|
end
|
|
|
|
|
|
--- format on save
|
|
|
|
-local group = vim.api.nvim_create_augroup('LspFormatting', { clear = false })
|
|
|
|
-
|
|
|
|
-vim.api.nvim_create_autocmd('LspAttach', {
|
|
|
|
- callback = function(args)
|
|
|
|
- local bufnr = args.buf
|
|
|
|
- local client = vim.lsp.get_client_by_id(args.data.client_id)
|
|
|
|
-
|
|
|
|
- if client.server_capabilities.documentFormattingProvider then
|
|
|
|
- for key, cmd in pairs(vim.api.nvim_get_autocmds({ group = group, buffer = bufnr })) do
|
|
|
|
- vim.api.nvim_del_autocmd(cmd.id)
|
|
|
|
|
|
+if vim.fn.executable("jdtls") == 1 then
|
|
|
|
+ nvim_lsp.jdtls.setup({
|
|
|
|
+ capabilities = capabilities,
|
|
|
|
+ handlers = {
|
|
|
|
+ ["$/progress"] = function()
|
|
|
|
+ -- this is quite noisy so just disable it
|
|
end
|
|
end
|
|
- vim.api.nvim_create_autocmd('BufWritePre', {
|
|
|
|
- group = group,
|
|
|
|
- buffer = bufnr,
|
|
|
|
- callback = function()
|
|
|
|
- vim.lsp.buf.format()
|
|
|
|
- end,
|
|
|
|
- })
|
|
|
|
- end
|
|
|
|
- end,
|
|
|
|
-})
|
|
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+end
|
|
|
|
|
|
-- custom LSP servers
|
|
-- custom LSP servers
|
|
local configs = require('lspconfig.configs')
|
|
local configs = require('lspconfig.configs')
|
|
@@ -148,5 +126,4 @@ end
|
|
|
|
|
|
nvim_lsp.elvish.setup({
|
|
nvim_lsp.elvish.setup({
|
|
capabilities = capabilities,
|
|
capabilities = capabilities,
|
|
- on_attach = on_attach,
|
|
|
|
})
|
|
})
|