summaryrefslogtreecommitdiff
path: root/lua/lsp/null-ls/linters.lua
diff options
context:
space:
mode:
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