Coder Social home page Coder Social logo

Comments (4)

Screwtapello avatar Screwtapello commented on June 12, 2024 1

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.

from kakoune.

dontlaugh avatar dontlaugh commented on June 12, 2024

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 dontlaugh@039544d

debug mappings output
*** This is the debug buffer, where debug info will be written ***
Mappings:
 * normal <left>: 'h' 
 * normal <right>: 'l' 
 * normal <down>: 'j' 
 * normal <up>: 'k' 
 * normal <s-left>: 'H' 
 * normal <s-right>: 'L' 
 * normal <s-down>: 'J' 
 * normal <s-up>: 'K' 
 * normal <end>: '<a-l>' 
 * normal <home>: '<a-h>' 
 * normal <s-end>: '<a-L>' 
 * normal <s-home>: '<a-H>' 
 * normal m: 'h' 
 * normal n: 'j' 
 * normal e: 'k' 
 * normal i: 'l' 
 * normal M: 'H' 
 * normal N: 'J' 
 * normal E: 'K' 
 * normal I: 'L' 
 * normal k: 'n' 
 * normal K: 'N' 
 * normal ': 'm' 
 * normal h: 'i' 
 * normal H: 'I' 
 * normal l: 'e' 
 * normal L: 'E' 
 * goto d: '<esc>:lsp<minus>definition<ret>' definition
 * goto r: '<esc>:lsp<minus>references<ret>' references
 * goto y: '<esc>:lsp<minus>type<minus>definition<ret>' type definition
 * goto m: 'h' start of line
 * goto n: 'j' end of buffer
 * goto e: 'k' top of buffer
 * goto i: 'l' end of line
 * user s: ':siblings<minus>tree<minus>repl<ret>' List buffile siblings in repl
 * user /: ':comment<minus>line<ret>' comment line (toggle)
 * user c: ':' command prompt
 * user i: '<a-i>' select within
 * user w: ':w<ret>' write buffer
 * user q: ':q<ret>' quit
 * user Q: ':q!<ret>' quit without saving
 * man g: ':man<minus>jump<ret>' Jump to a man page using selected man page link
 * man j: ':man<minus>link<minus>next<ret>' Go to next man page link
 * man k: ':man<minus>link<minus>prev<ret>' Go to previous man page link
 * man m: ':man<space>' Look up a man page
 * lsp a: '<esc>:<space>lsp<minus>code<minus>actions<ret>' show code actions for current position
 * lsp c: '<esc>:<space>lsp<minus>capabilities<ret>' show language server capabilities
 * lsp d: '<esc>:<space>lsp<minus>definition<ret>' go to definition
 * lsp e: '<esc>:<space>lsp<minus>diagnostics<ret>' list project errors, info, hints and warnings
 * lsp f: '<esc>:<space>lsp<minus>formatting<ret>' format buffer
 * lsp h: '<esc>:<space>lsp<minus>hover<ret>' show info for current position
 * lsp H: '<esc>:<space>lsp<minus>hover<minus>buffer<ret>' show info for current position in a scratch buffer
 * lsp i: '<esc>:<space>lsp<minus>implementation<ret>' go to implementation
 * lsp j: '<esc>:<space>lsp<minus>outgoing<minus>calls<ret>' list outgoing call for function at cursor
 * lsp k: '<esc>:<space>lsp<minus>incoming<minus>calls<ret>' list incoming call for function at cursor
 * lsp l: '<esc>:<space>lsp<minus>code<minus>lens<ret>' apply a code lens from the current selection
 * lsp o: '<esc>:<space>lsp<minus>workspace<minus>symbol<minus>incr<ret>' search project symbols
 * lsp n: '<esc>:<space>lsp<minus>find<minus>error<ret>' find next error
 * lsp p: '<esc>:<space>lsp<minus>find<minus>error<space><minus><minus>previous<ret>' find previous error
 * lsp q: '<esc>:<space>lsp<minus>exit<ret>' exit session
 * lsp r: '<esc>:<space>lsp<minus>references<ret>' list symbol references
 * lsp R: '<esc>:<space>lsp<minus>rename<minus>prompt<ret>' rename symbol
 * lsp s: '<esc>:<space>lsp<minus>goto<minus>document<minus>symbol<ret>' jump to document symbol
 * lsp S: '<esc>:<space>lsp<minus>document<minus>symbol<ret>' list document symbols
 * lsp v: '<esc>:<space>lsp<minus>selection<minus>range<ret>' select inner/outer nodes
 * lsp V: '<esc>:<space>lsp<minus>selection<minus>range<space>cached<ret>' select inner/outer nodes (re-use previous call)
 * lsp y: '<esc>:<space>lsp<minus>type<minus>definition<ret>' go to type definition
 * lsp [: '<esc>:<space>lsp<minus>hover<minus>previous<minus>symbol<ret>' show hover for previous symbol
 * lsp ]: '<esc>:<space>lsp<minus>hover<minus>next<minus>symbol<ret>' show hover for next symbol
 * lsp {: '<esc>:<space>lsp<minus>previous<minus>symbol<ret>' goto previous symbol
 * lsp }: '<esc>:<space>lsp<minus>next<minus>symbol<ret>' goto next symbol
 * lsp 9: '<esc>:<space>lsp<minus>hover<minus>previous<minus>function<ret>' show hover for previous function
 * lsp 0: '<esc>:<space>lsp<minus>hover<minus>next<minus>function<ret>' show hover for next function
 * lsp (: '<esc>:<space>lsp<minus>previous<minus>function<ret>' goto previous function
 * lsp ): '<esc>:<space>lsp<minus>next<minus>function<ret>' goto next function
 * lsp &: '<esc>:<space>lsp<minus>highlight<minus>references<ret>' lsp-highlight-references
 * lsp =: '<esc>:<space>lsp<minus>range<minus>formatting<ret>' format selections
 * lsp-selection-range j: '<esc>:<space>lsp<minus>selection<minus>range<minus>select<space>down<ret>' select inner node
 * lsp-selection-range k: '<esc>:<space>lsp<minus>selection<minus>range<minus>select<space>up<ret>' select outer node
 * lsp-selection-range b: '<esc>:<space>lsp<minus>selection<minus>range<minus>select<space>bottom<ret>' select innermost node
 * lsp-selection-range t: '<esc>:<space>lsp<minus>selection<minus>range<minus>select<space>top<ret>' select outermost node
Error: buffer is read-only

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.

from kakoune.

krobelus avatar krobelus commented on June 12, 2024

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.

from kakoune.

dontlaugh avatar dontlaugh commented on June 12, 2024

I agree that teaching to_string to print a different way from what it does right now is not worth it.

from kakoune.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.