Closed Zeioth closed 3 months ago
There is no problem in requiring a dependency, but it shouldn't be necessary to hardcode loading clients in the config. It beats the point of none-ls.
This is a problem only for external builtins. Native builtins don't suffer this problem.
In our case the native builtins are ok in 99% of cases, but we would still need to hardcode a couple of deprecated ones:
"gbprod/none-ls-shellcheck.nvim" -- to enable code actions on sh.
"gbprod/none-ls-luacheck.nvim" -- selene is not a viable replacement for us. It support considerably less lints. It would also imply migrating all our projects to selene, which is not viable.
In the end we just migrated from luacheck to selene, and from beautysh to shfmt. While it's true these projects were stable and powerful, they are probably abandoned forever.
Feel free to close this issue if you consider it.
@jay-babu do you have time to take a look at this?
Nevermind.... I found my answer: https://github.com/nvimtools/none-ls.nvim/discussions/81
I was thinking a possible solution would be not attaching a source
if the command
is not available on the terminal. I'm gonna see if I can pull it off during the weekend.
I already got a local workaround working:
-- none-ls [lsp code formatting]
-- https://github.com/nvimtools/none-ls.nvim
{
"nvimtools/none-ls.nvim",
dependencies = {
"jay-babu/mason-null-ls.nvim",
"nvimtools/none-ls-extras.nvim",
},
event = "VeryLazy",
opts = function()
-- fix: Register the extra builtin reformat_gherkin only if the command is available.
local gherkin_builtin = require("none-ls.formatting.reformat_gherkin")
local gherkin_cmd = gherkin_builtin._opts.command
if vim.fn.executable(gherkin_cmd) == 1 then
require("null-ls.sources").register(gherkin_builtin)
end
return {} -- opts are not necessary for this example
end
},
This code will only try to load the extra builtin if its command is executable.
I don't know if I can implement this into none-ls itself so the user doesn't have to use hacks such as this. I'm gonna try.
Issue located in null-ls-mason not having added support for external sources yet. Closing and moving the issue to https://github.com/nvimtools/none-ls.nvim/issues/125
FAQ
Issues
Neovim Version
v0.9.5
Dev Version?
Operating System
arch
Minimal Config
Steps to Reproduce
x
Reproducibility Check
minimal_init.lua
template and that my issue is reproducible by runningnvim --clean -u minimal_init.lua
and following the steps above.Expected Behavior
x
Actual Behavior
x
Debug Log
x
Help
No
Implementation Help
Loading external builtins in the new way
Suffices for end users, but it's not a good solution for distro maintainers.
Example
Result
Both shellcheck and the new installed linter are going to appear as loaded in
:LspInfo
, as shellcheck is now hardcoded in the config (which was not previously necessary).Requirements