From d9d60536bb3e028ecb6e10720cbb9e74bfb6a6e3 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Wed, 27 Jul 2022 16:23:11 +0200 Subject: [PATCH] feat(neovim): add tsserver config --- home-manager/neovim/lspconfig.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/home-manager/neovim/lspconfig.lua b/home-manager/neovim/lspconfig.lua index db099e2..7b27c0b 100644 --- a/home-manager/neovim/lspconfig.lua +++ b/home-manager/neovim/lspconfig.lua @@ -22,13 +22,14 @@ local on_attach = function(client, bufnr) nnoremap("", vim.diagnostic.goto_prev) nnoremap("", 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,