Skip to content
This repository was archived by the owner on Aug 12, 2023. It is now read-only.

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

Open
1 task done
D00mch opened this issue Nov 19, 2022 · 7 comments
Open
1 task done

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

D00mch opened this issue Nov 19, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@D00mch
Copy link

D00mch commented Nov 19, 2022

Issues

  • 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 D00mch added the enhancement New feature or request label Nov 19, 2022
@jose-elias-alvarez
Copy link
Owner

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.

@ehaynes99
Copy link

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.

@jose-elias-alvarez
Copy link
Owner

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.

@ehaynes99
Copy link

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/

@jose-elias-alvarez
Copy link
Owner

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.

@ehaynes99
Copy link

Gotcha. Sorry to hijack. Thanks!

@adrian5
Copy link

adrian5 commented Apr 26, 2023

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants