From 23f6ed98ec54bb8fd8c1896df59fc92fa525722f Mon Sep 17 00:00:00 2001 From: m1ngsama Date: Wed, 13 May 2026 17:18:01 +0800 Subject: [PATCH] Make auto-pairs opt-in (#55) --- README.md | 1 + modules/env.vim | 2 ++ modules/plugins.vim | 5 ++++- scripts/test.sh | 14 ++++++++++---- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fc47658..edc948c 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ let g:chopsticks_enable_jk_escape = 1 " optional: insert-mode jk exits insert 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 ``` `minimal` avoids LSP, ALE, completion plugins, extra language syntax plugins, diff --git a/modules/env.vim b/modules/env.vim index 004f019..ed07f60 100644 --- a/modules/env.vim +++ b/modules/env.vim @@ -24,6 +24,8 @@ let g:chopsticks_enable_ui_extras = get(g:, 'chopsticks_enable_ui_extras', \ !s:profile_minimal) 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_markdown_lint = get(g:, 'chopsticks_markdown_lint', \ s:profile_full) diff --git a/modules/plugins.vim b/modules/plugins.vim index 508f1f7..8eabba0 100644 --- a/modules/plugins.vim +++ b/modules/plugins.vim @@ -26,9 +26,12 @@ Plug 'tpope/vim-commentary' Plug 'tpope/vim-repeat' Plug 'tpope/vim-sleuth' Plug 'wellle/targets.vim' -Plug 'jiangmiao/auto-pairs' Plug 'easymotion/vim-easymotion', { 'on': '(easymotion' } +if g:chopsticks_enable_auto_pairs + Plug 'jiangmiao/auto-pairs' +endif + if g:chopsticks_enable_lint " ── Linting & Formatting ──────────────────────────────────────────────── Plug 'dense-analysis/ale' diff --git a/scripts/test.sh b/scripts/test.sh index 4967ce5..775f66a 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -168,7 +168,7 @@ check_vim() { vim -u NONE -i NONE -es -N \ -c 'let g:chopsticks_profile = "minimal"' \ -c 'source .vimrc' \ - -c 'if has_key(g:plugs, "ale") || has_key(g:plugs, "vim-lsp") || has_key(g:plugs, "vim-lsp-settings") || has_key(g:plugs, "asyncomplete.vim") | cquit | endif' \ + -c 'if has_key(g:plugs, "ale") || has_key(g:plugs, "vim-lsp") || has_key(g:plugs, "vim-lsp-settings") || has_key(g:plugs, "asyncomplete.vim") || has_key(g:plugs, "auto-pairs") | cquit | endif' \ -c 'qa!' 2>&1 mkdir -p "$TMP_ROOT/local" @@ -176,14 +176,14 @@ check_vim() { vim -u NONE -i NONE -es -N \ -c "let g:chopsticks_local_config = '$TMP_ROOT/local/config.vim'" \ -c 'source .vimrc' \ - -c 'if g:chopsticks_profile !=# "minimal" || has_key(g:plugs, "ale") || has_key(g:plugs, "vim-lsp") | cquit | endif' \ + -c 'if g:chopsticks_profile !=# "minimal" || has_key(g:plugs, "ale") || has_key(g:plugs, "vim-lsp") || has_key(g:plugs, "auto-pairs") | cquit | endif' \ -c 'qa!' 2>&1 mkdir -p "$TMP_ROOT/xdg" printf "%s\n" "let g:chopsticks_profile = 'minimal'" > "$TMP_ROOT/xdg/chopsticks.vim" XDG_CONFIG_HOME="$TMP_ROOT/xdg" vim -u NONE -i NONE -es -N \ -c 'source .vimrc' \ - -c 'if g:chopsticks_profile !=# "minimal" || has_key(g:plugs, "ale") || has_key(g:plugs, "vim-lsp") | cquit | endif' \ + -c 'if g:chopsticks_profile !=# "minimal" || has_key(g:plugs, "ale") || has_key(g:plugs, "vim-lsp") || has_key(g:plugs, "auto-pairs") | cquit | endif' \ -c 'qa!' 2>&1 XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \ @@ -204,7 +204,7 @@ check_vim() { XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \ -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 maparg("", "i") =~# "pumvisible" || maparg("", "i") =~# "pumvisible" || maparg("", "i") =~# "asyncomplete#close_popup" | 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(",/", "v") !~# "escape" || maparg(",v", "n") !=# last_change_map || maparg(",ff", "n") !~# "SmartFiles" | cquit | endif' \ -c 'qa!' 2>&1 @@ -223,6 +223,12 @@ check_vim() { -c 'if maparg("", "i") !~# "pumvisible" || maparg("", "i") !~# "pumvisible" || maparg("", "i") !~# "asyncomplete#close_popup" | cquit | endif' \ -c 'qa!' 2>&1 + XDG_CONFIG_HOME="$EMPTY_XDG" vim -u NONE -i NONE -es -N \ + -c 'let g:chopsticks_enable_auto_pairs = 1' \ + -c 'source .vimrc' \ + -c 'if !has_key(g:plugs, "auto-pairs") | 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' \