Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out what to do about abbreviations in modes other than insert mode #205

Open
Julian opened this issue Nov 18, 2021 · 6 comments
Open
Labels
enhancement New feature or request

Comments

@Julian
Copy link
Owner

Julian commented Nov 18, 2021

It's quite annoying to search for non-ASCII characters via /, for instance, because you have to have yanked the character you're looking for ahead of time.

Possibly there's some solution we can think of that'd allow abbreviations in more places. Nothing has occurred to me so far the past few months, but it may be there are things we can try.

@Julian Julian added the enhancement New feature or request label Nov 18, 2021
@rish987
Copy link
Collaborator

rish987 commented Nov 18, 2021

If you're looking for a quick partial solution, you could try digraphs (ctrl-K a * for example). Perhaps we can find some way to map abbreviations to digraphs?

@rish987
Copy link
Collaborator

rish987 commented Nov 18, 2021

Another option is finding a way to enable abbreviations in the q/buffer

@Julian
Copy link
Owner Author

Julian commented Dec 4, 2021

What I want to try here as a first pass is via https://github.com/hrsh7th/cmp-cmdline -- specifically after #140, it should be possible to expand abbreviations in cmdline or search mode by just enabling that (which seems to work well for other cmp sources).

@gebner
Copy link
Collaborator

gebner commented Dec 4, 2021

What nvim-cmp does (cmp-cmdline seems to be only configuration) is hook into CmdlineChanged and insert the completion via nvim_feedkeys, we could adopt that for the built-in expander as well.

@Julian
Copy link
Owner Author

Julian commented Dec 4, 2021

Yep I saw that, probably a good idea too.

@rish987
Copy link
Collaborator

rish987 commented Aug 15, 2022

I've taken a strong interest in this recently. I was thinking that abbreviations are a more lightweight kind of snippet, but of course there isn't a one-to-one correspondence -- for example snippet completion is triggered on command while abbreviation completion is automatic, and there's no notion of reverse-lookup for snippets.

The builtin :iabbrev command mentioned in #117 can be used to a very similar effect to what we have, it can be buffer-specific and :abbrev already works in the command line, however it will be more difficult to extend than something that lives in a Lua plugin.

Overall, I feel like the correct approach is to extend a plugin like LuaSnip for our purposes, then we could get other goodies like abbreviation autocompletion in the command line and search. And it has the "autotrigger" option we can use. But there's the question of how to get reverse-lookup to work in that context, which may not make sense for general snippets, but perhaps COULD if we were to generalize it to searching for a regex match to a visual selection (with snippet placeholders replaced by appropriate patterns, and optimized with a simple map for the plain string case).

So, I think that going in this direction could eventually get this and #117 working, but let me know if you had something else in mind.

Julian added a commit that referenced this issue Aug 29, 2022
Doesn't get all the way there for e.g. /, but at least
gives one simple way to search with abbreviation support.

See :h q/ if you haven't previously used the cmdline window.

Ref: #205
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants