diff --git a/README.md b/README.md index 5e78f4b..9c661c4 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ let g:chopsticks_profile = 'engineer' " default: LSP, ALE, syntax extras let g:chopsticks_profile = 'full' " engineer + heavier Markdown feedback 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 ``` `minimal` avoids LSP, ALE, completion plugins, extra language syntax plugins, diff --git a/modules/tools.vim b/modules/tools.vim index 0aa1ca6..098bb75 100644 --- a/modules/tools.vim +++ b/modules/tools.vim @@ -128,7 +128,9 @@ nnoremap cr :call RunFile() " ── Sudo Save ─────────────────────────────────────────────────────────────── -cnoremap w!! w !sudo tee > /dev/null % +if get(g:, 'chopsticks_enable_sudo_save_bang', 0) + cnoremap w!! w !sudo tee > /dev/null % +endif " ── QuickFix ──────────────────────────────────────────────────────────────── @@ -423,7 +425,6 @@ function! s:CheatSheet() abort \ ' ,q quit', \ ' ,x save + quit', \ ' Esc exit insert', - \ ' :w!! sudo save', \ ' ,ev edit vimrc', \ ' ,sv reload vimrc', \ ' :ChopsticksStatus health', diff --git a/scripts/test.sh b/scripts/test.sh index 77a48c6..96acb19 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -203,7 +203,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") !=# "" | cquit | endif' \ + -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(",/", "v") !~# "escape" || maparg(",v", "n") !=# last_change_map || maparg(",ff", "n") !~# "SmartFiles" | cquit | endif' \ -c 'qa!' 2>&1 @@ -215,9 +215,9 @@ check_vim() { XDG_CONFIG_HOME="$EMPTY_XDG" vim -u NONE -i NONE -es -N \ -c 'let g:chopsticks_enable_ctrl_s_save = 1' \ + -c 'let g:chopsticks_enable_sudo_save_bang = 1' \ -c 'source .vimrc' \ - -c 'if maparg("", "n") !~# ":w" | cquit | endif' \ - -c 'if maparg("", "i") !~# ":w" | cquit | endif' \ + -c 'if maparg("", "n") !~# ":w" || maparg("", "i") !~# ":w" || maparg("w!!", "c") !~# "sudo tee" | cquit | endif' \ -c 'qa!' 2>&1 XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \