소스 검색

fix document highlight bug for javascript,typescript... (#1017)

PBird 4 년 전
부모
커밋
ecb02ba7fe
2개의 변경된 파일10개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 2
      lua/lsp/init.lua
  2. 8 2
      lua/lsp/tsserver-ls.lua

+ 2 - 2
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

+ 8 - 2
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 = {