diff options
-rw-r--r-- | lua/lsp/init.lua | 4 | ||||
-rw-r--r-- | lua/lsp/tsserver-ls.lua | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index efc2f30d..7e6982b5 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -196,8 +196,8 @@ function lsp_config.PeekImplementation() end end -if O.lsp.document_highlight then - function lsp_config.common_on_attach(client, bufnr) +function lsp_config.common_on_attach(client, bufnr) + if O.lsp.document_highlight then documentHighlight(client, bufnr) end end diff --git a/lua/lsp/tsserver-ls.lua b/lua/lsp/tsserver-ls.lua index 01db611c..18e56dae 100644 --- a/lua/lsp/tsserver-ls.lua +++ b/lua/lsp/tsserver-ls.lua @@ -47,6 +47,13 @@ end -- require'completion'.on_attach(client) -- require'illuminate'.on_attach(client) -- end + +local on_attach = function(client, bufnr) + local lsp = require "lsp" + lsp.common_on_attach(client, bufnr) + lsp.tsserver_on_attach(client, bufnr) +end + require("lspconfig").tsserver.setup { cmd = { DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", @@ -60,8 +67,7 @@ require("lspconfig").tsserver.setup { "typescriptreact", "typescript.tsx", }, - on_attach = require("lsp").tsserver_on_attach, - -- on_attach = require'lsp'.common_on_attach, + on_attach = on_attach, -- This makes sure tsserver is not used for formatting (I prefer prettier) settings = { documentFormatting = false }, handlers = { |