summaryrefslogtreecommitdiff
path: root/lua/lsp/null-ls/linters.lua
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-10-08 08:57:11 +0200
committerGitHub <[email protected]>2021-10-08 08:57:11 +0200
commitf4899e316516fc6fc544b148cb7e9a04fbda130e (patch)
treeeab6114dd1ec03103aaa3839fb69abce392fa266 /lua/lsp/null-ls/linters.lua
parent68d2678af32cea932f4860f4144e9efd9ec03ed1 (diff)
fix: register null-ls providers per filetype (#1709)
Diffstat (limited to 'lua/lsp/null-ls/linters.lua')
-rw-r--r--lua/lsp/null-ls/linters.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/lua/lsp/null-ls/linters.lua b/lua/lsp/null-ls/linters.lua
index ea45fa87..34a78a65 100644
--- a/lua/lsp/null-ls/linters.lua
+++ b/lua/lsp/null-ls/linters.lua
@@ -23,7 +23,7 @@ function M.list_available(filetype)
return linters
end
-function M.list_configured(linter_configs)
+function M.list_configured(linter_configs, filetype)
local linters, errors = {}, {}
for _, lnt_config in pairs(linter_configs) do
@@ -39,7 +39,11 @@ function M.list_configured(linter_configs)
errors[lnt_config.exe] = {} -- Add data here when necessary
else
Log:debug("Using linter: " .. linter_cmd)
- linters[lnt_config.exe] = linter.with { command = linter_cmd, extra_args = lnt_config.args }
+ linters[lnt_config.exe] = linter.with {
+ command = linter_cmd,
+ extra_args = lnt_config.args,
+ filetypes = { filetype },
+ }
end
end
end
@@ -52,9 +56,8 @@ function M.setup(linter_configs, filetype)
return
end
- local linters_by_ft = {}
- linters_by_ft[filetype] = M.list_configured(linter_configs)
- null_ls.register { sources = linters_by_ft[filetype].supported }
+ local linters_by_ft = M.list_configured(linter_configs, filetype)
+ null_ls.register { sources = linters_by_ft.supported }
end
return M