소스 검색

fix(lsp): use correct check for formatter override (#1726)

kylo252 3 년 전
부모
커밋
195b07a464
2개의 변경된 파일1개의 추가작업 그리고 8개의 파일을 삭제
  1. 1 2
      lua/lsp/init.lua
  2. 0 6
      lua/lsp/utils.lua

+ 1 - 2
lua/lsp/init.lua

@@ -94,11 +94,10 @@ local function select_default_formater(client)
   Log:debug("Checking for formatter overriding for " .. client.name)
   Log:debug("Checking for formatter overriding for " .. client.name)
   local client_filetypes = client.config.filetypes or {}
   local client_filetypes = client.config.filetypes or {}
   for _, filetype in ipairs(client_filetypes) do
   for _, filetype in ipairs(client_filetypes) do
-    if not vim.tbl_isempty(lvim.lang[filetype].formatters) then
+    if lvim.lang[filetype] and #vim.tbl_keys(lvim.lang[filetype].formatters) > 0 then
       Log:debug("Formatter overriding detected. Disabling formatting capabilities for " .. client.name)
       Log:debug("Formatter overriding detected. Disabling formatting capabilities for " .. client.name)
       client.resolved_capabilities.document_formatting = false
       client.resolved_capabilities.document_formatting = false
       client.resolved_capabilities.document_range_formatting = false
       client.resolved_capabilities.document_range_formatting = false
-      return
     end
     end
   end
   end
 end
 end

+ 0 - 6
lua/lsp/utils.lua

@@ -10,12 +10,6 @@ function M.is_client_active(name)
   return false
   return false
 end
 end
 
 
-function M.disable_formatting_capability(client)
-  -- FIXME: figure out a reasonable way to do this
-  client.resolved_capabilities.document_formatting = false
-  require("core.log"):debug(string.format("Turning off formatting capability for language server [%s] ", client.name))
-end
-
 function M.get_active_client_by_ft(filetype)
 function M.get_active_client_by_ft(filetype)
   local matches = {}
   local matches = {}
   local clients = vim.lsp.get_active_clients()
   local clients = vim.lsp.get_active_clients()