Make ,F full-file reindent opt-in

`,F` in normal mode mapped `gg=G\`\`` — reindent the entire file with
no confirmation. A muscle-typo of `,F` instead of `,f` (LSP format)
rewrites the whole buffer, and `=` does not always produce sensible
indentation for languages where Vim's internal indent expression is
poor.

Gate the normal-mode binding behind `g:chopsticks_enable_reindent_file`
(default off). The visual-mode binding (`vnoremap <leader>F =`) is
bounded by the user's selection and stays as default.

README's all-keybindings table now marks `,F re-indent (v)` to reflect
the visual-only default.

Closes #68
This commit is contained in:
m1ngsama 2026-05-16 22:45:47 +08:00
parent fc872918a1
commit a69ac8c263
4 changed files with 19 additions and 2 deletions

View file

@ -36,6 +36,9 @@
- `set exrc`/`set secure` are now opt-in via `g:chopsticks_enable_exrc = 1`;
Vim no longer sources project-local `.vimrc`/`.exrc` from the working
directory by default
- Normal-mode `,F` (reindent the entire file with `gg=G`) is now opt-in
via `g:chopsticks_enable_reindent_file = 1`; visual-mode `,F` (reindent
selection) stays as the default since it's bounded by the user's pick
- `,?` cheat sheet is now profile-aware and hides LSP/ALE/preview/UndoTree keys
when those features are disabled
- Module reload/source paths now use `fnameescape()` so installs in paths with

View file

@ -88,6 +88,7 @@ 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
let g:chopsticks_enable_exrc = 1 " optional: source project-local .vimrc/.exrc from CWD
let g:chopsticks_enable_reindent_file = 1 " optional: ,F reindents the entire file
```
`minimal` avoids LSP, ALE, completion plugins, extra language syntax plugins,
@ -124,7 +125,7 @@ Esc exit insert mode ,? cheat sheet
### Edit
`,S`+2ch jump | `gc` comment | `cs"'` surround | `Alt+j/k` move line | `,u` undo tree | `,y` clipboard | `,*` replace word | `,F` re-indent | `,W` strip whitespace | `[<Space>` `]<Space>` blank lines
`,S`+2ch jump | `gc` comment | `cs"'` surround | `Alt+j/k` move line | `,u` undo tree | `,y` clipboard | `,*` replace word | `,F` re-indent (v) | `,W` strip whitespace | `[<Space>` `]<Space>` blank lines
### Git

View file

@ -21,7 +21,9 @@ endfunction
" ── Utilities ──────────────────────────────────────────────────────────────
nnoremap <leader>F gg=G``
if get(g:, 'chopsticks_enable_reindent_file', 0)
nnoremap <leader>F gg=G``
endif
vnoremap <leader>F =
nnoremap <leader>wa :wa<CR>

View file

@ -246,6 +246,17 @@ check_vim() {
-c 'if !&exrc || !&secure | cquit | endif' \
-c 'qa!' 2>&1
XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \
-c 'if maparg(",F", "n") !=# "" | cquit | endif' \
-c 'if maparg(",F", "v") !~# "=" | cquit | endif' \
-c 'qa!' 2>&1
XDG_CONFIG_HOME="$EMPTY_XDG" vim -u NONE -i NONE -es -N \
-c 'let g:chopsticks_enable_reindent_file = 1' \
-c 'source .vimrc' \
-c 'if maparg(",F", "n") !~# "gg=G" | 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' \