Minimalistic alternative to the plugin mason-null-ls
with support for none-ls external sources.
Problem:
- Normally when you use none-ls you would have to manually register the sources you want to load.
- You would also have to manually deregister sources when you uninstall them, or none-ls will display errors.
Solution:
- By using
none-ls-autoload.nvim
, you don't have to worry about any of that. This plugin will take care of automatically load/unload all mason packages you install/uninstall when necessary.
{
"zeioth/none-ls-autoload.nvim",
event = "BufEnter",
dependencies = { "williamboman/mason.nvim", "nvimtools/none-ls.nvim" },
opts = {},
},
The none-ls
project stop supporting builtin sources when they have not been maintained for a while. Knowing that: External sources are packages you can install to use sources not oficially supported by none-ls
.
- You install the dependency.
- Then you tell
none-ls-autoload.nvim
where to find it with the optionexternal_sources
.
{
"zeioth/none-ls-autoload.nvim",
event = "BufEnter",
dependencies = {
"williamboman/mason.nvim",
"zeioth/none-ls-external-sources.nvim" -- To install a external sources library.
},
opts = {
external_sources = {
-- To specify where to find a external source.
'none-ls-external-sources.formatting.reformat_gherkin'
},
},
},
It's important to be aware a source is just a way to tell none-ls how to use a mason package. You HAVE to install the mason package to use it.
Option | Default | Description |
---|---|---|
external_sources |
{} |
If a mason package is not directly supported through a none-ls builtin source, you can specify a external source, so none-ls-autoload.nvim know how to load/unload it automatically when needed. |
methods |
{ diagnostics = true, formatting = true, code_actions = true, completion = true, hover = true } |
The type of sources we should load. This is handy in case you want to disable a certain kind of client. Or in case you want to manage a certain functionality using a different plugin. |
If you want to help me, please star this repository to increase the visibility of the project.
- Do I need mason for this plugin to work? Yes.
- Do this plugin interfere with my none-ls options? No.
- Do external sources have priority over builtin sources? Yes, if both are present, the external source you define will have priority.
- How is this plugin different from mason-null-ls? Only a couple things. We add a new feature: support for external sources. We remove a feature: We don't provide commands to manually load/unload sources, as we do it automatically anyway. Aditionally, we aim to keep the code easier to understand and contribute to.
- My external none-ls source doesn't load correctly: The source you pass must be formated like
'<anything-you-want>.<method>.<source-name>'
, as we extract the last two fields to load it. For example'package_name.subdirectory.formatting.reformat_gherkin'
. So if the external source you are trying to pass come from a repository not formatted that way, just fork it and fix its directory structure. - Where can I find external sources?: Here.