Closed Zeioth closed 4 months ago
I don't think its possible to dynamically load formatters and linters like that as both conform and nvim-lint only take the formatters_by_ft
/linters_by_ft
tables as options in their setup functions. setup functions are only run once on startup of nvim.
For reference the conform README only mentions the formatters_by_ft
in the setup function table. Similarly for nvim-lint adding the following snippet:
require("mason-registry"):on(
"package:install:success",
vim.schedule_wrap(function()
local lint = require("lint")
local bridge = require("mason-bridge")
bridge.force_reload()
print(vim.inspect(require("mason-bridge").get_linters()))
lint.linters_by_ft = bridge.get_linters()
end)
)
which sets the linters_by_ft
again when a new package gets installed results in the following error:
Error executing vim.schedule lua callback: ...share/nvim/lazy/mason.nvim/lua/mason-core/ui/display.lua:236: BufEnter Autocommands for "*": Vim(append):Error executing lua
callback: /Users/daniel/.local/share/nvim/lazy/nvim-lint/lua/lint.lua:84: attempt to index field 'linters_by_ft' (a nil value)
stack traceback:
/Users/daniel/.local/share/nvim/lazy/nvim-lint/lua/lint.lua:84: in function '_resolve_linter_by_ft'
/Users/daniel/.local/share/nvim/lazy/nvim-lint/lua/lint.lua:235: in function 'try_lint'
/Users/daniel/.config/nvim/lua/plugins/lsp-lint-format.lua:86: in function </Users/daniel/.config/nvim/lua/plugins/lsp-lint-format.lua:85>
[C]: in function 'nvim_win_close'
...share/nvim/lazy/mason.nvim/lua/mason-core/ui/display.lua:236: in function <...share/nvim/lazy/mason.nvim/lua/mason-core/ui/display.lua:233>
stack traceback:
[C]: in function 'nvim_win_close'
...share/nvim/lazy/mason.nvim/lua/mason-core/ui/display.lua:236: in function <...share/nvim/lazy/mason.nvim/lua/mason-core/ui/display.lua:233>
which leads me to believe that nvim-lint also doesnt support dynamically updating its table.
@Zeioth as of 1.2.0 its possible to dynamically load linters and formatters. Please refer to the README for instructions!
This snippet is present in mason-null-ls/none-ls-autoload.nvim and maybe we could use it here too:
Maybe we could achieve something similar on
mason-bridge.nvim
so the registered clients are registered/deregistered when installing/uninstalling a mason package.