feat(nvim): accept completion with <CR>, indent 4
blink.cmp uses the `enter` preset with `completion.list.selection.preselect = false`, so an item is taken only once selected with `<Down>`/`<C-n>` and `<CR>` otherwise inserts a newline. `<C-y>` stays bound as vim's own confirm key. `<Esc>` and `<C-e>` both run `cancel` rather than the preset's `hide`: hiding leaves the auto_insert preview in the buffer without the `additionalTextEdits` and snippet expansion a real accept applies, and builtin ins-completion `<C-e>` likewise restores the typed text. `shiftwidth`/`tabstop` are 4, matching PHP's PSR-12. PHP's `indentkeys` carry `*<Return>`, which reindents the just-finished line on every newline; at width 2 that silently re-indented 4-space files. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015D4NsszUG7hy9ghKZ4nfhm
This commit is contained in:
+25
-4
@@ -86,8 +86,8 @@ in
|
|||||||
scrolloff = 8; # keep 8 lines of context around the cursor
|
scrolloff = 8; # keep 8 lines of context around the cursor
|
||||||
|
|
||||||
expandtab = true; # spaces, not tabs
|
expandtab = true; # spaces, not tabs
|
||||||
shiftwidth = 2;
|
shiftwidth = 4;
|
||||||
tabstop = 2;
|
tabstop = 4;
|
||||||
smartindent = true;
|
smartindent = true;
|
||||||
|
|
||||||
ignorecase = true; # case-insensitive search…
|
ignorecase = true; # case-insensitive search…
|
||||||
@@ -162,10 +162,31 @@ in
|
|||||||
blink-cmp = {
|
blink-cmp = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
keymap.preset = "default"; # C-space open, C-y confirm, C-n/C-p move
|
# "enter" preset: <CR> accepts, Up/Down and C-n/C-p move, Tab is
|
||||||
|
# left to snippet jumping. Custom keys below merge over the preset.
|
||||||
|
keymap = {
|
||||||
|
preset = "enter";
|
||||||
|
# Vim's own ins-completion confirm key, kept alongside <CR>.
|
||||||
|
"<C-y>" = [ "select_and_accept" "fallback" ];
|
||||||
|
# Dismiss the menu and undo the auto_insert preview, staying in
|
||||||
|
# insert mode. `cancel` rather than the preset's `hide`, which
|
||||||
|
# would leave the previewed text in the buffer without the
|
||||||
|
# additionalTextEdits (imports) and snippet expansion that a real
|
||||||
|
# accept applies — a degraded accept nobody wants. This also
|
||||||
|
# matches builtin ins-completion, where C-e restores the typed
|
||||||
|
# text. With no menu open both keys fall back to their native
|
||||||
|
# meaning (Esc leaves insert mode).
|
||||||
|
"<C-e>" = [ "cancel" "fallback" ];
|
||||||
|
"<Esc>" = [ "cancel" "fallback" ];
|
||||||
|
};
|
||||||
appearance.nerd_font_variant = "mono";
|
appearance.nerd_font_variant = "mono";
|
||||||
sources.default = [ "lsp" "path" "snippets" "buffer" ];
|
sources.default = [ "lsp" "path" "snippets" "buffer" ];
|
||||||
completion.documentation.auto_show = true;
|
completion = {
|
||||||
|
documentation.auto_show = true;
|
||||||
|
# No item is selected until one is picked with Down/C-n, so <CR>
|
||||||
|
# inserts a newline unless a completion was deliberately chosen.
|
||||||
|
list.selection.preselect = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user