From ecb02ba7feddc65564e83e8695b52d3139c82461 Mon Sep 17 00:00:00 2001 From: PBird Date: Mon, 19 Jul 2021 19:44:44 +0300 Subject: fix document highlight bug for javascript,typescript... (#1017) --- lua/lsp/init.lua | 4 ++-- lua/lsp/tsserver-ls.lua | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'lua') 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 = { -- cgit v1.2.3