Make jk escape opt in (#40)

This commit is contained in:
m1ngsama 2026-05-13 14:05:22 +08:00 committed by GitHub
parent f278e9f3b6
commit 76aa3efd72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 17 additions and 7 deletions

View file

@ -29,13 +29,13 @@ cd ~/.vim && ./install.sh --configure-only --profile=full
| Mode | Enter | Leave | | Mode | Enter | Leave |
| ------ | --------------- | ------------- | | ------ | --------------- | ------------- |
| Normal | startup default | — | | Normal | startup default | — |
| Insert | `i` / `a` / `o` | `Esc` or `jk` | | Insert | `i` / `a` / `o` | `Esc` |
| Visual | `v` / `V` | `Esc` | | Visual | `v` / `V` | `Esc` |
## Survival ## Survival
``` ```
Esc / jk back to Normal Esc back to Normal
,w save ,w save
,x save + quit ,x save + quit
:q! force quit :q! force quit

View file

@ -81,6 +81,7 @@ profile or uses `engineer`.
let g:chopsticks_profile = 'minimal' " core navigation/editing/git/markdown let g:chopsticks_profile = 'minimal' " core navigation/editing/git/markdown
let g:chopsticks_profile = 'engineer' " default: LSP, ALE, syntax extras let g:chopsticks_profile = 'engineer' " default: LSP, ALE, syntax extras
let g:chopsticks_profile = 'full' " engineer + heavier Markdown feedback let g:chopsticks_profile = 'full' " engineer + heavier Markdown feedback
let g:chopsticks_enable_jk_escape = 1 " optional: insert-mode jk exits insert
``` ```
`minimal` avoids LSP, ALE, completion plugins, extra language syntax plugins, `minimal` avoids LSP, ALE, completion plugins, extra language syntax plugins,
@ -96,12 +97,12 @@ active profile and only shows keys for enabled features.
Leader: `,` Leader: `,`
``` ```
Ctrl+p fuzzy find file ,dd go to definition ,ff fuzzy find file ,dd go to definition
,rg ripgrep project ,dk hover docs ,rg ripgrep project ,dk hover docs
,e toggle file sidebar ,cr run current file ,e toggle file sidebar ,cr run current file
,gs git status ,f format ,gs git status ,f format
,w save ,q quit ,w save ,q quit
jk exit insert mode ,? cheat sheet Esc exit insert mode ,? cheat sheet
``` ```
<details> <details>

View file

@ -125,7 +125,9 @@ nnoremap <silent> <F3> :set invnumber<CR>:echo 'Line numbers: ' . (&number ? 'ON
nnoremap <silent> <F4> :set invrelativenumber<CR>:echo 'Relative numbers: ' . (&relativenumber ? 'ON' : 'OFF')<CR> nnoremap <silent> <F4> :set invrelativenumber<CR>:echo 'Relative numbers: ' . (&relativenumber ? 'ON' : 'OFF')<CR>
nnoremap <silent> <F6> :set list!<CR>:echo 'List chars: ' . (&list ? 'ON' : 'OFF')<CR> nnoremap <silent> <F6> :set list!<CR>:echo 'List chars: ' . (&list ? 'ON' : 'OFF')<CR>
if get(g:, 'chopsticks_enable_jk_escape', 0)
inoremap jk <Esc> inoremap jk <Esc>
endif
vnoremap < <gv vnoremap < <gv
vnoremap > >gv vnoremap > >gv

View file

@ -423,7 +423,7 @@ function! s:CheatSheet() abort
\ ' ,q quit', \ ' ,q quit',
\ ' ,x save + quit', \ ' ,x save + quit',
\ ' Ctrl+s save (any mode)', \ ' Ctrl+s save (any mode)',
\ ' jk exit insert', \ ' Esc exit insert',
\ ' :w!! sudo save', \ ' :w!! sudo save',
\ ' ,ev edit vimrc', \ ' ,ev edit vimrc',
\ ' ,sv reload vimrc', \ ' ,sv reload vimrc',

View file

@ -203,11 +203,18 @@ check_vim() {
XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \ XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \
-c 'if maparg("0", "n") !=# "" || maparg("0", "v") !=# "" || maparg("Y", "n") !=# "" || maparg("Q", "n") !=# "" || maparg("<Space>", "n") !=# "" | cquit | endif' \ -c 'if maparg("0", "n") !=# "" || maparg("0", "v") !=# "" || maparg("Y", "n") !=# "" || maparg("Q", "n") !=# "" || maparg("<Space>", "n") !=# "" | cquit | endif' \
-c 'if maparg("jk", "i") !=# "" | cquit | endif' \
-c 'if maparg("<C-h>", "n") !=# "" || maparg("<C-j>", "n") !=# "" || maparg("<C-k>", "n") !=# "" || maparg("<C-l>", "n") !=# "" | cquit | endif' \ -c 'if maparg("<C-h>", "n") !=# "" || maparg("<C-j>", "n") !=# "" || maparg("<C-k>", "n") !=# "" || maparg("<C-l>", "n") !=# "" | cquit | endif' \
-c 'if maparg("<C-p>", "n") !=# "" | cquit | endif' \ -c 'if maparg("<C-p>", "n") !=# "" | cquit | endif' \
-c 'if maparg(",ff", "n") !~# "SmartFiles" | cquit | endif' \ -c 'if maparg(",ff", "n") !~# "SmartFiles" | cquit | endif' \
-c 'qa!' 2>&1 -c 'qa!' 2>&1
XDG_CONFIG_HOME="$EMPTY_XDG" vim -u NONE -i NONE -es -N \
-c 'let g:chopsticks_enable_jk_escape = 1' \
-c 'source .vimrc' \
-c 'if maparg("jk", "i") !~# "<Esc>" | cquit | endif' \
-c 'qa!' 2>&1
XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \ XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \
-c 'silent! delcommand LspStatus' \ -c 'silent! delcommand LspStatus' \
-c 'silent! delcommand LspInstallServer' \ -c 'silent! delcommand LspInstallServer' \
@ -268,7 +275,7 @@ check_vim() {
grep -Fq ',dk hover docs' "$TMP_ROOT/cheat-default.txt" grep -Fq ',dk hover docs' "$TMP_ROOT/cheat-default.txt"
grep -Fq ',dp ,dn LSP diagnostics' "$TMP_ROOT/cheat-default.txt" grep -Fq ',dp ,dn LSP diagnostics' "$TMP_ROOT/cheat-default.txt"
grep -Fq '<C-w>hjkl navigate splits' "$TMP_ROOT/cheat-default.txt" grep -Fq '<C-w>hjkl navigate splits' "$TMP_ROOT/cheat-default.txt"
if grep -Eq 'Ctrl\\+p find file|Ctrl\\+hjkl navigate splits|gd definition|K hover docs|\\[g \\]g LSP diagnostics' "$TMP_ROOT/cheat-default.txt"; then if grep -Eq 'Ctrl\\+p find file|Ctrl\\+hjkl navigate splits|jk exit insert|gd definition|K hover docs|\\[g \\]g LSP diagnostics' "$TMP_ROOT/cheat-default.txt"; then
cat "$TMP_ROOT/cheat-default.txt" cat "$TMP_ROOT/cheat-default.txt"
exit 1 exit 1
fi fi