summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchristianchiarulli <[email protected]>2021-08-03 23:02:09 -0400
committerchristianchiarulli <[email protected]>2021-08-03 23:02:09 -0400
commit6c6fb67a8835cdcf911ef48ec2c19d553fe7d1a1 (patch)
tree2916fefe91c43be9c17e9f8f4f59152c4effc22c
parent4c3c3f388557a182794bffdbf923129c66af885a (diff)
use old vim rooter logic, fallback on new way if vimrooter is disabled
-rw-r--r--lua/lsp/null-ls.lua20
1 files changed, 15 insertions, 5 deletions
diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua
index d3f7931b..8bdea227 100644
--- a/lua/lsp/null-ls.lua
+++ b/lua/lsp/null-ls.lua
@@ -24,12 +24,22 @@ function M.get_registered_providers_by_filetype(ft)
end
local function validate_nodejs_provider(requests, provider)
- local ts_client = require("utils").get_active_client_by_ft "typescript"
- if ts_client == nil then
- u.lvim_log "Unable to determine root directory since tsserver didn't start correctly"
- return
+ local root_dir = ""
+ if lvim.builtin.rooter.active then
+ --- old logic to set root_dir
+ vim.cmd "let root_dir = FindRootDirectory()"
+ root_dir = vim.api.nvim_get_var "root_dir"
+ else
+ --- new logic to set root_dir
+ local ts_client = require("utils").get_active_client_by_ft "typescript"
+ if ts_client then
+ local root_dir = ts_client.config.root_dir
+ end
+ if ts_client == nil then
+ u.lvim_log "Unable to determine root directory since tsserver didn't start correctly"
+ return
+ end
end
- local root_dir = ts_client.config.root_dir
local local_nodejs_command = root_dir .. "/node_modules/.bin/" .. provider._opts.command
u.lvim_log(string.format("checking [%s] for local node module: [%s]", local_nodejs_command, vim.inspect(provider)))
if vim.fn.executable(local_nodejs_command) == 1 then