diff options
| -rw-r--r-- | lua/lsp/null-ls/services.lua | 26 | ||||
| -rw-r--r-- | lua/lsp/utils.lua | 3 | 
2 files changed, 12 insertions, 17 deletions
| diff --git a/lua/lsp/null-ls/services.lua b/lua/lsp/null-ls/services.lua index 89073e5c..6f3516ad 100644 --- a/lua/lsp/null-ls/services.lua +++ b/lua/lsp/null-ls/services.lua @@ -1,29 +1,23 @@  local M = {} -local logger = require("core.log"):get_default() -  local function find_root_dir() -  if lvim.builtin.rooter.active then -    --- use vim-rooter to set root_dir -    vim.cmd "let root_dir = FindRootDirectory()" -    return vim.api.nvim_get_var "root_dir" -  end - -  -- TODO: Rework this to not make it javascript specific -  --- use LSP to set root_dir +  local util = require "lspconfig/util"    local lsp_utils = require "lsp.utils" -  local ts_client = lsp_utils.get_active_client_by_ft "typescript" -  if ts_client == nil then -    logger.error "Unable to determine root directory since tsserver didn't start correctly" -    return nil -  end -  return ts_client.config.root_dir +  local status_ok, ts_client = lsp_utils.is_client_active "typescript" +  if status_ok then +    return ts_client.config.root_dir +  end +  local dirname = vim.fn.expand "%:p:h" +  return util.root_pattern "package.json"(dirname)  end  local function from_node_modules(command) +  local logger = require("core.log"):get_default()    local root_dir = find_root_dir() +    if not root_dir then +    logger.error(string.format("Unable to find the [%s] node module.", command))      return nil    end diff --git a/lua/lsp/utils.lua b/lua/lsp/utils.lua index e28c6085..17b9c3bc 100644 --- a/lua/lsp/utils.lua +++ b/lua/lsp/utils.lua @@ -4,12 +4,13 @@ function M.is_client_active(name)    local clients = vim.lsp.get_active_clients()    for _, client in pairs(clients) do      if client.name == name then -      return true +      return true, client      end    end    return false  end +-- FIXME: this should return a list instead  function M.get_active_client_by_ft(filetype)    if not lvim.lang[filetype] or not lvim.lang[filetype].lsp then      return nil | 
