jupyterlab-vimrc icon indicating copy to clipboard operation
jupyterlab-vimrc copied to clipboard

iabbr support

Open quantum-booty opened this issue 3 years ago • 5 comments

Is it possible to add iabbr support? For example the following commands would automatically insert a colon for def, class, if, etc...


iabbr def def:<Left>
iabbr class class:<Left>
iabbr if if:<Left>
iabbr elif elif:<Left>
iabbr while while:<Left>
iabbr for for:<Left>

iabbr else else:<CR>
iabbr try try:<CR>
iabbr except except:<CR>

quantum-booty avatar Sep 22 '20 23:09 quantum-booty

Hi @quantum-booty that's a good suggestion!

However, I'm not sure that the codemirror vim api will easily support this. That said, if we can figure a way to implement this that is not too involved I would love to see it be part of this library as it is very useful.

A related thing you may be interested in is: https://github.com/ryanhomer/jupyterext-text-shortcuts though looking at it it doesn't seem to have the same behavior as iabbr

handy link for future me (or someone else)

https://stackoverflow.com/questions/1988163/when-to-use-abbr-vs-map-in-vi-vim

ianhi avatar Sep 22 '20 23:09 ianhi

There is some prior art for abbreviations in codemirror https://github.com/emmetio/codemirror-plugin. Although looking at their implementation(https://github.com/emmetio/codemirror-plugin/blob/master/src/abbreviation.ts) I wonder if this would make more sense as a feature request to jupyterlab. The reasons for this are:

  1. This would also be useful to non-vim users
  2. probably easier to implement there
  3. may make sense to connect with the machinery behind for tab autocomplete

I also wonder if this is something that jupyterlab-lsp might be useful for

ianhi avatar Sep 22 '20 23:09 ianhi

I also asked about this on jupyterlab gitter: https://gitter.im/jupyterlab/jupyterlab?at=5f6a89971c5b0d210ac57892 I will update this comment if it gets any responses

ianhi avatar Sep 22 '20 23:09 ianhi

Thank you so much for your work and you quick reply! I had a look at the jupyterext-text-shortcuts, but indeed its not the same. I will open an issue on jupyterlab for the feature request.

quantum-booty avatar Sep 23 '20 13:09 quantum-booty

related topic discussed on gitter here: https://gitter.im/jupyterlab/jupyterlab?at=601876aeaa6a6f319dfaaa18

I definitely think that jupyterlab-lsp is ultimately th ebest way forward here.

ianhi avatar Feb 02 '21 19:02 ianhi