Comments (4)
It looks like the point of vim's completeopt = noinsert
is to make the first <c-x><c-n>
only show the menu but not insert the first candidate.
Kakoune provides autocompletion, so the menu is already shown without an explicit key, so I'm not sure if there is a scenario where this is needed?
If you turn off autocomplete
, you can use <c-o>
to show the menu.
If you want to use the same key for showing the menu and cycling through completions, that can be done by creating mappings in InsertCompletionShow
and InsertCompletionHide
hooks
from kakoune.
<c-x>
(or let completion menu pop up by itself)- scroll through available completions, some editors show additional "preview" with doc/signature of selected item in completion menu. Scrolling using
<tab>
/<s-tab>
or<up>
/<down>
- either exit using
<esc>
or select and apply/insert using<ret>
this way I don't have to remember to "commit undo" before selecting completion and I can decide when to insert selected completion, or abort. Currently I usually fumble it one way or the other and then need to bd
and try again, just not used to it.
I have never really used vim that much, so not used to that model either.
I suppose that I could maybe hook InsertCompletionShow
such that the word under cursor is somehow stored, then use the autocompletion menu as is, map <esc>
to some kind of local undo that restores that word and unmaps itself (like in "completion using tab" example) but I'm not sure how to do it reliably, if even possible
from kakoune.
I think it's possible we could improve the default UI here (change behavior of <esc>
and <ret>
to undo and accept).
But I'm not sure if the case for <esc>
is strong because it's easy and obvious to use u
afterwards.
These mappings try to match your expectations:
remove-hooks global my-completion
declare-option str on_esc_pressed
hook -group my-completion global InsertCompletionShow .* %{
echo -debug InsertCompletionShow %val{hook_param}
map window insert <esc> %{<a-semicolon>:set-option window on_esc_pressed <lt>a-semicolon>u; exec -with-hooks <lt>esc><ret>}
}
# Non-empty hook parameter means some completion was accepted.
hook -group my-completion global InsertCompletionHide .+ %{ execute-keys %opt{on_esc_pressed} }
hook -group my-completion global InsertCompletionHide .* %{ unset-option window on_esc_pressed }
with two problems
- it does not commit an undo point, so the
u
might undo too much. This can be worked around by first pressing<c-u>
. - it only does one
u
but a completion may create multiple undo points (for example LSP completions auto-insert imports when accepted)
Both are fixable with changes to the C++ core.
from kakoune.
Thank you so much for these suggestions and support!
from kakoune.
Related Issues (20)
- [BUG][CRASH] ctags-search crashes kakoune after trying to browse autocomplete options. HOT 2
- [BUG] %val{buflist} does not produce quoted output by default HOT 1
- [BUG] :w write paste wl-clipboard contents HOT 4
- [BUG] mv operation should not interfere with HOT 3
- [QUESTION] Text file busy make: *** [Makefile:181: install] Error 1 HOT 1
- [QUESTION] Cursor up/down navigation in soft-wrapped text (gj/gk in Vim) HOT 7
- Adding keybinding for `<c-/>` does not work HOT 2
- [BUG] Command completion stops to work when command is invoked in user-mode HOT 2
- [BUG] markdown highlighting cannot parse `` correctly
- [BUG] cannot use <ret> in *lint-output* buffer HOT 2
- [REQUEST] `close-daemonized-session` command HOT 4
- [BUG] Receiving `'vfork' is deprecated:` warnings while compiling Kakoune from source HOT 2
- [BUG] 2024.05.09 tests failing on Alpine Linux HOT 16
- [BUG] Tests failing on OpenBSD HOT 10
- [BUG] Files getting created when using autocomplete HOT 3
- [BUG] HOT 1
- [REQUEST] revert f26d4ea4 for putting tmux into background again HOT 7
- [BUG] Viewport motion no longer takes scrolloff into account
- [BUG] WhitespaceIndent face overridden by language highlighting HOT 1
- [BUG] setting a face to itself in kakrc causes hang HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kakoune.