mirror of
https://oauth2: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@github.com/m1ngsama/chopsticks.git
synced 2026-05-14 04:51:08 +08:00
Make Ctrl-S save opt-in (#42)
* Make Ctrl-S save opt in * Avoid hanging CI Vim installation * Keep Homebrew Vim on macOS CI
This commit is contained in:
parent
76aa3efd72
commit
fd081a2397
7 changed files with 22 additions and 7 deletions
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
|
|
@ -16,11 +16,15 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Vim
|
- name: Install Vim
|
||||||
|
timeout-minutes: 5
|
||||||
run: |
|
run: |
|
||||||
if [ "$(uname)" = "Darwin" ]; then
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
brew install vim
|
brew install vim
|
||||||
|
elif command -v vim >/dev/null 2>&1; then
|
||||||
|
vim --version | head -1
|
||||||
else
|
else
|
||||||
sudo apt-get update && sudo apt-get install -y vim
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y vim
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Install vim-plug
|
- name: Install vim-plug
|
||||||
|
|
|
||||||
2
.vimrc
2
.vimrc
|
|
@ -11,6 +11,8 @@ endif
|
||||||
if exists('g:chopsticks_loaded') | finish | endif
|
if exists('g:chopsticks_loaded') | finish | endif
|
||||||
let g:chopsticks_loaded = 1
|
let g:chopsticks_loaded = 1
|
||||||
|
|
||||||
|
let g:surround_no_insert_mappings = get(g:, 'surround_no_insert_mappings', 1)
|
||||||
|
|
||||||
function! s:load(mod) abort
|
function! s:load(mod) abort
|
||||||
execute 'source ' . fnameescape(g:chopsticks_dir . '/modules/' . a:mod . '.vim')
|
execute 'source ' . fnameescape(g:chopsticks_dir . '/modules/' . a:mod . '.vim')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ Esc back to Normal
|
||||||
,w save
|
,w save
|
||||||
,x save + quit
|
,x save + quit
|
||||||
:q! force quit
|
:q! force quit
|
||||||
Ctrl+s save from any mode
|
|
||||||
,? cheat sheet (toggle sidebar)
|
,? cheat sheet (toggle sidebar)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ 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
|
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
|
||||||
```
|
```
|
||||||
|
|
||||||
`minimal` avoids LSP, ALE, completion plugins, extra language syntax plugins,
|
`minimal` avoids LSP, ALE, completion plugins, extra language syntax plugins,
|
||||||
|
|
@ -217,7 +218,7 @@ Each module is self-contained. Comment out one line in `.vimrc` to disable it. A
|
||||||
| Plugins not loading | `:PlugInstall` then `:PlugUpdate` |
|
| Plugins not loading | `:PlugInstall` then `:PlugUpdate` |
|
||||||
| LSP not starting | `:LspInstallServer` for current filetype |
|
| LSP not starting | `:LspInstallServer` for current filetype |
|
||||||
| Colors wrong | `export COLORTERM=truecolor` in shell rc |
|
| Colors wrong | `export COLORTERM=truecolor` in shell rc |
|
||||||
| `Ctrl+s` freezes | `stty -ixon` in shell rc |
|
| Optional `Ctrl+s` freezes | `stty -ixon` in shell rc |
|
||||||
| Everything slow | Large file? Auto-disabled >10MB |
|
| Everything slow | Large file? Auto-disabled >10MB |
|
||||||
| What's installed? | `:ChopsticksStatus` shows tools, LSP, linters |
|
| What's installed? | `:ChopsticksStatus` shows tools, LSP, linters |
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -137,8 +137,10 @@ nnoremap N Nzzzv
|
||||||
|
|
||||||
vnoremap // y/\V<C-r>=escape(@",'/\')<CR><CR>
|
vnoremap // y/\V<C-r>=escape(@",'/\')<CR><CR>
|
||||||
|
|
||||||
|
if get(g:, 'chopsticks_enable_ctrl_s_save', 0)
|
||||||
nnoremap <silent> <C-s> :w<CR>
|
nnoremap <silent> <C-s> :w<CR>
|
||||||
inoremap <silent> <C-s> <C-o>:w<CR>
|
inoremap <silent> <C-s> <C-o>:w<CR>
|
||||||
|
endif
|
||||||
|
|
||||||
nnoremap <C-d> <C-d>zz
|
nnoremap <C-d> <C-d>zz
|
||||||
vnoremap <C-d> <C-d>zz
|
vnoremap <C-d> <C-d>zz
|
||||||
|
|
|
||||||
|
|
@ -422,7 +422,6 @@ function! s:CheatSheet() abort
|
||||||
\ ' ,w save',
|
\ ' ,w save',
|
||||||
\ ' ,q quit',
|
\ ' ,q quit',
|
||||||
\ ' ,x save + quit',
|
\ ' ,x save + quit',
|
||||||
\ ' Ctrl+s save (any mode)',
|
|
||||||
\ ' Esc exit insert',
|
\ ' Esc exit insert',
|
||||||
\ ' :w!! sudo save',
|
\ ' :w!! sudo save',
|
||||||
\ ' ,ev edit vimrc',
|
\ ' ,ev edit vimrc',
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,7 @@ 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("jk", "i") !=# "" | cquit | endif' \
|
||||||
|
-c 'if maparg("<C-s>", "n") !=# "" || maparg("<C-s>", "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' \
|
||||||
|
|
@ -215,6 +216,13 @@ check_vim() {
|
||||||
-c 'if maparg("jk", "i") !~# "<Esc>" | cquit | endif' \
|
-c 'if maparg("jk", "i") !~# "<Esc>" | 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_ctrl_s_save = 1' \
|
||||||
|
-c 'source .vimrc' \
|
||||||
|
-c 'if maparg("<C-s>", "n") !~# ":w" | cquit | endif' \
|
||||||
|
-c 'if maparg("<C-s>", "i") !~# ":w" | 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' \
|
||||||
|
|
@ -275,7 +283,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|jk exit insert|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|Ctrl\\+s save|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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue