null-ls.nvim icon indicating copy to clipboard operation
null-ls.nvim copied to clipboard

Allow to disable sources by default (to enable by shourtcut)

Open D00mch opened this issue 3 years ago • 7 comments
trafficstars

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

D00mch avatar Nov 19 '22 18:11 D00mch

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.

jose-elias-alvarez avatar Nov 23 '22 20:11 jose-elias-alvarez

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.

ehaynes99 avatar Dec 15 '22 21:12 ehaynes99

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.

jose-elias-alvarez avatar Dec 16 '22 03:12 jose-elias-alvarez

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/

ehaynes99 avatar Dec 17 '22 20:12 ehaynes99

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/

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.

jose-elias-alvarez avatar Dec 18 '22 00:12 jose-elias-alvarez

Gotcha. Sorry to hijack. Thanks!

ehaynes99 avatar Dec 18 '22 18:12 ehaynes99

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.

adrian5 avatar Apr 26 '23 13:04 adrian5