So, for example, I like kak-lsp a lot, but for somethings (.sh files) it can bog down everything sometimes, I really want a quick toggle to turn it on and off ,l or something. What is the best way to add a toggle in your kakrc?
Depending on what toggling.
For highlighters, you can check the implementation of toggle-highlighter.kak.
For plugin commands, there is no general solution if the author does not implement the -enable
and -disable
commands.
For your specific issue with kak-lsp, the best is probably to open an issue.
You can try this too:
remove-hooks <scope> lsp
Do you have a language-server for .sh
files? kak-lsp
should be pretty low-impact if you’re editing a file-type it doesn’t have a language-server for.
The Usage section of the kak-lsp
docs mentions that you can call lsp-enable
at startup to enable it everywhere, or lsp-enable-window
in a WinSetOption
hook to only enable it for that window. That ought to help keep things snappy.
As for toggling, how about something like this (untested)?
declare-command toggle-on %{
do-a-thing
map global normal %arg{1} ": toggle-off %arg{1}<ret>"
}
declare-command toggle-off %{
undo-a-thing
map global normal %arg{1} ": toggle-on %arg{1}<ret>"
}
toggle-on <f2>
Yeah, been trying to have it on for everything.
I mean, I didn’t realise “a language-server for .sh
files” was a thing that existed. Where did you get it? Is it any good?
I wonder if Kakoune should have a drop-module
or unrequire-module
which is an opposite of require-module
to unload plugins and modules that are no longer in use in the same way how scripts remove their hooks on certain conditions.