feat(neovim): add tsserver config

This commit is contained in:
mandlm 2022-07-27 16:23:11 +02:00
parent 91d13168c0
commit d9d60536bb
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7

View File

@ -22,13 +22,14 @@ local on_attach = function(client, bufnr)
nnoremap("<C-p>", vim.diagnostic.goto_prev)
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_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
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
@ -54,6 +55,7 @@ local servers = {
["rnix"] = {},
["terraformls"] = {},
["tflint"] = {},
["tsserver"] = {},
["yamlls"] = {},
}
@ -99,9 +101,10 @@ lspconfig["sumneko_lua"].setup(luadev)
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.prettier.with({
filetypes = { "markdown" }
}),
null_ls.builtins.formatting.prettierd,
null_ls.builtins.code_actions.eslint_d,
null_ls.builtins.diagnostics.eslint_d,
null_ls.builtins.diagnostics.tsc,
},
on_attach = on_attach,