null-ls.nvim
null-ls.nvim copied to clipboard
Allow to disable sources by default (to enable by shourtcut)
Issues
- [X] I have checked existing issues and there are no existing ones with the same request.
Feature description
I set up shortcuts that allows toggling "_disabled" status, but I want to have some sources disabled by default.
Something like:
local sources = {
null_ls.builtins.diagnostics.vale.with({
filetypes = { "markdown" },
enabled = false -- true by default
}),
}
Now I have to press my shortcut to disable it after I open a markdown file.
Help
No
Implementation help
No response
You're probably aware of this, but you can just run null_ls.disable({ name = "vale" }) after registering the source. This seems like a pretty niche use case, but if you want to put together a PR it should be pretty straightforward.
I can open a new issue, but it would also be nice to be able to do it on a per-buffer basis, the immediate case I can think of is for very large files.
I can open a new issue, but it would also be nice to be able to do it on a per-buffer basis, the immediate case I can think of is for very large files.
To make sure I understand: you're saying that you'd like to be able to determine whether the source starts enabled or disabled per buffer? This is difficult with the current architecture, since _disabled is a property of the source itself and not associated with a given buffer. Depending on what kind of workflow you have in mind, you may be able to achieve something with runtime_condition.
Yeah, for example if you accidentally select a large compiled .js file in a telescope, you end up with eslint instances pegged at 100% cpu that don't properly shut down with the editor.
I really wish there was a more native type of check, but solutions for disabling various plugins based on file size are e.g.: https://www.reddit.com/r/neovim/comments/z85s1l/disable_lsp_for_very_large_files/
Yeah, for example if you accidentally select a large compiled
.jsfile in a telescope, you end up with eslint instances pegged at 100% cpu that don't properly shut down with the editor.I really wish there was a more native type of check, but solutions for disabling various plugins based on file size are e.g.: https://www.reddit.com/r/neovim/comments/z85s1l/disable_lsp_for_very_large_files/
If you just want to disable null-ls on large files, you can use the should_attach option. This doesn't achieve exactly the same result as the requested feature, though, since it's non-trivial to attach after the fact.
Gotcha. Sorry to hijack. Thanks!
You're probably aware of this, but you can just run
null_ls.disable({ name = "vale" })after registering the source. This seems like a pretty niche use case, but if you want to put together a PR it should be pretty straightforward.
~If one disables vale that way, which command would toggle (enable, re-disable) vale for the current buffer?~ I'm frankly surprised there's so little discussion/interest in the topic of manual toggling.
Edit: Apparently it's as simple as null_ls.toggle({ name = "vale" }). Relevant docs.