|
@@ -24,16 +24,21 @@ if vim.fn.executable("node_modules/.bin/eslint") == 1 then
|
|
|
settings = {
|
|
|
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
|
|
|
-- dynamically but neovim does not support that yet
|
|
|
-- https://github.com/microsoft/vscode-eslint/pull/1307
|
|
|
client.server_capabilities.documentFormattingProvider = true
|
|
|
client.server_capabilities.documentRangeFormattingProvider = true
|
|
|
-
|
|
|
- -- mappings should have been attached by typescript and re-attaching can
|
|
|
- -- overwrite the typescript specific overrides
|
|
|
end,
|
|
|
+ -- mappings should have been attached by typescript and re-attaching can
|
|
|
+ -- overwrite the typescript specific overrides
|
|
|
})
|
|
|
end
|
|
|
|
|
@@ -67,12 +72,13 @@ else
|
|
|
flags = {
|
|
|
debounce_text_changes = 150,
|
|
|
},
|
|
|
- on_attach = function(client, bufnr)
|
|
|
+ on_init = function(client)
|
|
|
-- 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.documentRangeFormattingProvider = false
|
|
|
-
|
|
|
+ end,
|
|
|
+ on_attach = function(client, bufnr)
|
|
|
on_attach(client, bufnr)
|
|
|
|
|
|
-- override mappings for typescript
|
|
@@ -120,29 +126,6 @@ if vim.fn.executable("jdtls") == 1 then
|
|
|
});
|
|
|
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)
|
|
|
- end
|
|
|
- vim.api.nvim_create_autocmd('BufWritePre', {
|
|
|
- group = group,
|
|
|
- buffer = bufnr,
|
|
|
- callback = function()
|
|
|
- vim.lsp.buf.format()
|
|
|
- end,
|
|
|
- })
|
|
|
- end
|
|
|
- end,
|
|
|
-})
|
|
|
-
|
|
|
-- custom LSP servers
|
|
|
local configs = require('lspconfig.configs')
|
|
|
|