From b2835d3caed0262a16f5a3a40b1b20912772ab35 Mon Sep 17 00:00:00 2001 From: m1ngsama Date: Wed, 13 May 2026 17:24:45 +0800 Subject: [PATCH] Make terminal keymaps opt-in (#57) --- README.md | 1 + modules/env.vim | 2 ++ modules/navigation.vim | 12 +++++++----- scripts/test.sh | 7 +++++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index edc948c..357cd55 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ let g:chopsticks_enable_ctrl_s_save = 1 " optional: Ctrl-S saves let g:chopsticks_enable_sudo_save_bang = 1 " optional: :w!! sudo save let g:chopsticks_enable_completion_keymaps = 1 " optional: Tab/Enter completion let g:chopsticks_enable_auto_pairs = 1 " optional: automatic pair insertion +let g:chopsticks_enable_terminal_keymaps = 1 " optional: terminal Esc/Ctrl navigation ``` `minimal` avoids LSP, ALE, completion plugins, extra language syntax plugins, diff --git a/modules/env.vim b/modules/env.vim index ed07f60..94ee91f 100644 --- a/modules/env.vim +++ b/modules/env.vim @@ -26,6 +26,8 @@ let g:chopsticks_enable_markdown_preview = get(g:, \ 'chopsticks_enable_markdown_preview', !s:profile_minimal) let g:chopsticks_enable_auto_pairs = get(g:, \ 'chopsticks_enable_auto_pairs', 0) +let g:chopsticks_enable_terminal_keymaps = get(g:, + \ 'chopsticks_enable_terminal_keymaps', 0) let g:chopsticks_markdown_lint = get(g:, 'chopsticks_markdown_lint', \ s:profile_full) diff --git a/modules/navigation.vim b/modules/navigation.vim index 5cd36d0..45b2ad5 100644 --- a/modules/navigation.vim +++ b/modules/navigation.vim @@ -106,9 +106,11 @@ nnoremap z :call ToggleMaximize() if has('terminal') nnoremap tv :terminal nnoremap th :terminal ++rows=10 - tnoremap - tnoremap h - tnoremap j - tnoremap k - tnoremap l + if g:chopsticks_enable_terminal_keymaps + tnoremap + tnoremap h + tnoremap j + tnoremap k + tnoremap l + endif endif diff --git a/scripts/test.sh b/scripts/test.sh index 775f66a..218ae6e 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -205,6 +205,7 @@ check_vim() { -c 'let last_change_map = nr2char(96) . "[v" . nr2char(96) . "]"' \ -c 'if maparg("0", "n") !=# "" || maparg("0", "v") !=# "" || maparg("Y", "n") !=# "" || maparg("Q", "n") !=# "" || maparg("", "n") !=# "" || maparg("//", "v") !=# "" || maparg("gV", "n") !=# "" || maparg("jk", "i") !=# "" || maparg("", "n") !=# "" || maparg("", "i") !=# "" || maparg("", "n") !=# "" || maparg("", "n") !=# "" || maparg("", "n") !=# "" || maparg("", "n") !=# "" || maparg("", "n") !=# "" || maparg("", "c") !=# "" || maparg("", "c") !=# "" || maparg("w!!", "c") !=# "" | cquit | endif' \ -c 'if has_key(g:plugs, "auto-pairs") || maparg("", "i") =~# "pumvisible" || maparg("", "i") =~# "pumvisible" || maparg("", "i") =~# "asyncomplete#close_popup" || maparg("", "i") =~# "AutoPairs" | cquit | endif' \ + -c 'if maparg("", "t") !=# "" || maparg("", "t") !=# "" || maparg("", "t") !=# "" || maparg("", "t") !=# "" || maparg("", "t") !=# "" | cquit | endif' \ -c 'if maparg(",/", "v") !~# "escape" || maparg(",v", "n") !=# last_change_map || maparg(",ff", "n") !~# "SmartFiles" | cquit | endif' \ -c 'qa!' 2>&1 @@ -229,6 +230,12 @@ check_vim() { -c 'if !has_key(g:plugs, "auto-pairs") | cquit | endif' \ -c 'qa!' 2>&1 + XDG_CONFIG_HOME="$EMPTY_XDG" vim -u NONE -i NONE -es -N \ + -c 'let g:chopsticks_enable_terminal_keymaps = 1' \ + -c 'source .vimrc' \ + -c 'if has("terminal") && (maparg("", "t") !~# "" || maparg("", "t") !~# "h" || maparg("", "t") !~# "j" || maparg("", "t") !~# "k" || maparg("", "t") !~# "l") | cquit | endif' \ + -c 'qa!' 2>&1 + XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \ -c 'silent! delcommand LspStatus' \ -c 'silent! delcommand LspInstallServer' \