Closed dontlaugh closed 1 month ago
I've got the right hand side printing with the Kakoune to_string
function. The output seems valid, but to_string
expands to the "named" values like <minus>
, which makes it look a little strange.
* lsp =: '<esc>:<space>lsp<minus>range<minus>formatting<ret>' format selections
Here's the change so far https://github.com/dontlaugh/kakoune/commit/039544d468b4245170e180643bf95d1d0767d437
We want the <named>
version in many cases like <ret>
, but not in cases like <minus>
. Maybe we need a new function to print things this way.
I guess <minus>
has a long name so you can use it at the beginning of the right-hand side of a mapping:
# This works
map global normal x <minus>blorp
# This fails with "unknown option '-blorp'"
map global normal x -blorp
It's not necessary in other circumstances, but at least it's unambiguous, and it might be preferable than trying to teach to_string()
about all the circumstances where escaping might be necessary.
Interesting. It is certainly a possibility to use the non-named (non-canonical) versions
for plus/minus/semicolon/percent in a multi-key context (which as of today is only used for recorded macros).
Unless minus is the very first character.
Raw ;
should be fine given that we also include raw "
and '
so the string must be escaped already before evaluation.
So I think that would be a fine workaround.
An alternative is to preserve the input sequence (store it separately from the parsed version).
I think your change is good but overall there are limits to what :debug mappings
can do.
I'm not sure if we want to encourage using it outside of some debugging scenarios (I've actually never used it).
If you instead navigate to the kakrc where you define your mapping, you will get a strictly better UI.
You get extra context from adjacent code and comments etc., exactly how you chose to lay it out in your config file.
Maybe the LSP plugin should stop pre-defining mappings.
Instead include recommended mappings in the documentation (perhaps viewable with doc lsp
or similar), suitable for pasting into your config.
That might simplify things - it's weird that some functionality is exposed both as default mapping and as command.
I'm not sure.
I agree that teaching to_string
to print a different way from what it does right now is not worth it.
Feature
Currently, when you run
:debug mappings
it prints something like the following to the*debug*
buffer.This is the corresponding kakscript mapping from my config
Here is the output that could be better:
Adding the right hand side to
:debug mappings
would tell me not only that a mapping was changed, but what it was changed to.For mappings to more complex commands, perhaps we introduce quotes. So this kakscript mapping
...becomes this output in
*debug*
This is a small, specific change spawned from the larger discussion in #5150