feat(neovim): add tsserver config

mandlm 2022-07-27 16:23:11 +02:00
parent 91d13168c0
commit d9d60536bb
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7
1 changed files with 8 additions and 5 deletions

View File

@ -22,13 +22,14 @@ local on_attach = function(client, bufnr)
nnoremap("<C-p>", vim.diagnostic.goto_prev) nnoremap("<C-p>", vim.diagnostic.goto_prev)
nnoremap("<C-n>", vim.diagnostic.goto_next) nnoremap("<C-n>", vim.diagnostic.goto_next)
if client.supports_method("textDocument/formatting") then if client.name ~= "tsserver" and client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", { vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup, group = augroup,
buffer = bufnr, buffer = bufnr,
callback = function() callback = function()
vim.lsp.buf.formatting_sync({}, 3000) local params = vim.lsp.util.make_formatting_params({})
client.request("textDocument/formatting", params, nil, bufnr)
end, end,
}) })
end end
@ -54,6 +55,7 @@ local servers = {
["rnix"] = {}, ["rnix"] = {},
["terraformls"] = {}, ["terraformls"] = {},
["tflint"] = {}, ["tflint"] = {},
["tsserver"] = {},
["yamlls"] = {}, ["yamlls"] = {},
} }
@ -99,9 +101,10 @@ lspconfig["sumneko_lua"].setup(luadev)
local null_ls = require("null-ls") local null_ls = require("null-ls")
null_ls.setup({ null_ls.setup({
sources = { sources = {
null_ls.builtins.formatting.prettier.with({ null_ls.builtins.formatting.prettierd,
filetypes = { "markdown" } null_ls.builtins.code_actions.eslint_d,
}), null_ls.builtins.diagnostics.eslint_d,
null_ls.builtins.diagnostics.tsc,
}, },
on_attach = on_attach, on_attach = on_attach,