summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/lsp/null-ls
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/lsp/null-ls')
-rw-r--r--.config/nvim/lua/lsp/null-ls/formatters.lua2
-rw-r--r--.config/nvim/lua/lsp/null-ls/linters.lua2
-rw-r--r--.config/nvim/lua/lsp/null-ls/services.lua24
3 files changed, 10 insertions, 18 deletions
diff --git a/.config/nvim/lua/lsp/null-ls/formatters.lua b/.config/nvim/lua/lsp/null-ls/formatters.lua
index e69c824..cf62615 100644
--- a/.config/nvim/lua/lsp/null-ls/formatters.lua
+++ b/.config/nvim/lua/lsp/null-ls/formatters.lua
@@ -66,7 +66,7 @@ function M.list_configured(formatter_configs)
end
function M.setup(filetype, option)
- if formatters_by_ft[filetype] and not option.force_reload then
+ if not options.lang[filetype] or (formatters_by_ft[filetype] and not option.force_reload) then
return
end
diff --git a/.config/nvim/lua/lsp/null-ls/linters.lua b/.config/nvim/lua/lsp/null-ls/linters.lua
index a0675a7..a4eaa89 100644
--- a/.config/nvim/lua/lsp/null-ls/linters.lua
+++ b/.config/nvim/lua/lsp/null-ls/linters.lua
@@ -66,7 +66,7 @@ function M.list_configured(linter_configs)
end
function M.setup(filetype, option)
- if linters_by_ft[filetype] and not option.force_reload then
+ if not options.lang[filetype] or (linters_by_ft[filetype] and not option.force_reload) then
return
end
diff --git a/.config/nvim/lua/lsp/null-ls/services.lua b/.config/nvim/lua/lsp/null-ls/services.lua
index 80bf66e..a1e3a06 100644
--- a/.config/nvim/lua/lsp/null-ls/services.lua
+++ b/.config/nvim/lua/lsp/null-ls/services.lua
@@ -1,28 +1,20 @@
local M = {}
-local logger = require("core.log"):get_default()
-
local function find_root_dir()
- if options.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 root_dir = find_root_dir()
+
if not root_dir then
return nil
end