mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-29 22:29:57 +02:00
fix: register null-ls providers per filetype (#1709)
This commit is contained in:
parent
68d2678af3
commit
f4899e3165
3 changed files with 21 additions and 15 deletions
|
@ -23,7 +23,7 @@ function M.list_available(filetype)
|
|||
return formatters
|
||||
end
|
||||
|
||||
function M.list_configured(formatter_configs)
|
||||
function M.list_configured(formatter_configs, filetype)
|
||||
local formatters, errors = {}, {}
|
||||
|
||||
for _, fmt_config in ipairs(formatter_configs) do
|
||||
|
@ -39,7 +39,11 @@ function M.list_configured(formatter_configs)
|
|||
errors[fmt_config.exe] = {} -- Add data here when necessary
|
||||
else
|
||||
Log:debug("Using formatter: " .. formatter_cmd)
|
||||
formatters[fmt_config.exe] = formatter.with { command = formatter_cmd, extra_args = fmt_config.args }
|
||||
formatters[fmt_config.exe] = formatter.with {
|
||||
command = formatter_cmd,
|
||||
extra_args = fmt_config.args,
|
||||
filetypes = { filetype },
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -52,9 +56,8 @@ function M.setup(formatter_configs, filetype)
|
|||
return
|
||||
end
|
||||
|
||||
local formatters_by_ft = {}
|
||||
formatters_by_ft[filetype] = M.list_configured(formatter_configs)
|
||||
null_ls.register { sources = formatters_by_ft[filetype].supported }
|
||||
local formatters_by_ft = M.list_configured(formatter_configs, filetype)
|
||||
null_ls.register { sources = formatters_by_ft.supported }
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue