lean.nvim icon indicating copy to clipboard operation
lean.nvim copied to clipboard

Extract abbreviations functionality so that other languages can use it as well

Open clason opened this issue 4 years ago • 10 comments

For example, Julia REPL supports entering Unicode chars via, e.g., \alpha -> α or \:beer: -> 🍺, which looks quite similar to Lean.

(You can see a full list here, which is generated from https://github.com/nvim-telescope/telescope-symbols.nvim/blob/master/script/julia_symbols.jl.)

Also see: https://github.com/GoldsteinE/compe-latex-symbols

clason avatar Aug 16 '21 13:08 clason

Also, any interest in adding https://github.com/L3MON4D3/LuaSnip support?

clason avatar Aug 16 '21 13:08 clason

I've seen LuaSnip but not tried it myself -- definitely open to adding it though yeah.

(And yeah like I said definitely happy to extract this piece too, though it'll take a bit of generalizing I think, but yeah it's a good idea!)

Julian avatar Aug 16 '21 14:08 Julian

The thought occurs that this (Unicode input) is a relatively common task, and that vim already has a similar feature: digraphs. Maybe the way to go here is to add some tooling around that (for loading custom, filetype dependent, digraphs, better input suggestions/previews)?

clason avatar Aug 16 '21 15:08 clason

I think that's quite interesting!

I'm aware of digraphs but I've essentially never used them myself even before this plugin (for some of the reasons you mentioned -- worst of which is the input suggestion thing, where if you type stuff you have no idea what you typed already, which symbol you're on the way to, etc.)

We'd need upstream changes though obviously -- probably that's part of what you're suggesting right? If so could definitely do some thinking about what that'd look like, I think the list you just gave is a pretty decent one on stuff that'd be needed, along with maybe being able to configure how to enter digraph entry mode (e.g. here we need it super often and want to trigger it with \ rather than reaching for c-k).

Julian avatar Aug 16 '21 16:08 Julian

I'm aware of digraphs but I've essentially never used them myself even before this plugin (for some of the reasons you mentioned -- worst of which is the input suggestion thing, where if you type stuff you have no idea what you typed already, which symbol you're on the way to, etc.)

Same here...

We'd need upstream changes though obviously -- probably that's part of what you're suggesting right? If so could definitely do some thinking about what that'd look like, I think the list you just gave is a pretty decent one on stuff that'd be needed, along with maybe being able to configure how to enter digraph entry mode (e.g. here we need it super often and want to trigger it with \ rather than reaching for c-k).

Yes, the hooks for digraph would have to go upstream (maybe even to vim?) Also agreed on exposing that feature so it's mappable/triggerable from a script.

It's probably not going to be a full replacement for autocomplete or snippet UX, but it's interesting as a sort of "vim-sneak for unicode"...

clason avatar Aug 16 '21 16:08 clason

If one were to go down that route, it might make sense to even generalize this to "ngraphs" (which may short-circuit) -- this way you can actually type alpha? (But this starts to sound like a completely different feature...)

Actually, a new complete mode ("symbols", <c-x><c-s>?) might be a more appropriate...

And there's also iabbrev (which however doesn't work (easily) with leading backslashes...), which (as abbrev) also easily works on the command line.

clason avatar Aug 16 '21 16:08 clason

Yeah, the more I think about it, the more abbrev sounds like what would be easiest to (ab)use. Just needs a good preview :)

clason avatar Aug 16 '21 16:08 clason

If anyone wants the abbreviations in vscode format for luasnip etc.

https://github.com/ram02z/dotfiles/blob/7429b91a601e0efa4a889b5cd16ec697c8139850/dot_config/nvim/snippets/maths_abbr.json

ram02z avatar Oct 25 '21 20:10 ram02z

Before this repo, I had something which did that essentially. It live(d) here https://github.com/Julian/lean-unicode.vim/

Julian avatar Oct 25 '21 20:10 Julian

Ups, hit space bar which GitHub decided to focus on the "Close with comment button"...

But yeah the above was a previous attempt -- we can do better than both I think (which is what Christian was requesting)

Julian avatar Oct 25 '21 20:10 Julian