Respect profiles in local config and status

This commit is contained in:
m1ngsama 2026-04-30 13:45:05 +08:00
parent db9b96f577
commit a9e16d22d3
8 changed files with 65 additions and 31 deletions

9
.vimrc
View file

@ -1,8 +1,13 @@
let g:chopsticks_dir = fnamemodify(resolve(expand('<sfile>')), ':h')
let s:local_config = expand(get(g:, 'chopsticks_local_config',
\ '~/.config/chopsticks.vim'))
if filereadable(s:local_config)
execute 'source ' . fnameescape(s:local_config)
endif
if exists('g:chopsticks_loaded') | finish | endif
let g:chopsticks_loaded = 1
let g:chopsticks_dir = fnamemodify(resolve(expand('<sfile>')), ':h')
function! s:load(mod) abort
execute 'source ' . g:chopsticks_dir . '/modules/' . a:mod . '.vim'
endfunction

View file

@ -4,6 +4,8 @@
### Added
- `~/.config/chopsticks.vim` local pre-load config for profile and user choices
- `g:chopsticks_enable_markdown_preview` to control Previm independently
- `g:chopsticks_profile` with `minimal`, `engineer`, and `full` profiles
- `.markdownlint.json` aligned with the project's README/changelog style
- `:ChopsticksStatus` diagnostic command — checks system tools, LSP servers, linters, formatters
@ -24,6 +26,9 @@
- Swap files are enabled again and stored under `~/.vim/.swap` for crash recovery
- Installer defaults are slimmer: only core search tools stay selected by default;
language and lint suites are opt-in
- `:ChopsticksStatus` now respects disabled LSP/lint profiles instead of reporting
intentionally disabled tools as missing
- `,sv` now clears the load guard before sourcing `$MYVIMRC`
- CI now verifies key plugin directories, Markdown quiet defaults, markdownlint,
and an explicit startup-time threshold
- Skip 2 more built-in plugins: openPlugin, manpager (10 → 12 total)

View file

@ -10,8 +10,8 @@ curl -fsSL https://raw.githubusercontent.com/m1ngsama/chopsticks/main/get.sh | b
Open vim. First launch auto-installs plugins — **wait 30-60s, don't close vim**. Restart when done.
Default profile is `engineer`. Put `let g:chopsticks_profile = 'minimal'`
before loading chopsticks for a smaller core-only setup, or use `full` for the
Default profile is `engineer`. Put `let g:chopsticks_profile = 'minimal'` in
`~/.config/chopsticks.vim` for a smaller core-only setup, or use `full` for the
heavier Markdown/LSP feedback.
## Modes

View file

@ -67,15 +67,18 @@ First launch installs plugins automatically (30-60s). Restart vim when done.
Default profile: `engineer`.
```vim
" Put this before sourcing chopsticks.
" Put this in ~/.config/chopsticks.vim.
let g:chopsticks_profile = 'minimal' " core navigation/editing/git/markdown
let g:chopsticks_profile = 'engineer' " default: LSP, ALE, syntax extras
let g:chopsticks_profile = 'full' " engineer + heavier Markdown feedback
```
`minimal` avoids LSP, ALE, completion plugins, extra language syntax plugins,
Startify, and UndoTree. `full` keeps those and opts into Markdown lint, format,
spell, conceal, Marksman, and LSP virtual text.
Startify, UndoTree, and browser Markdown preview. `full` keeps those and opts
into Markdown lint, format, spell, conceal, Marksman, and LSP virtual text.
Project updates leave `~/.config/chopsticks.vim` alone, so put local choices
there instead of editing the managed `.vimrc`.
## Keys

View file

@ -2,7 +2,7 @@
# install.sh - chopsticks vim configuration installer
# Usage: cd /path/to/chopsticks && ./install.sh [--yes] [--help]
#
# --yes non-interactive: install all optional components automatically
# --yes non-interactive: use default component selections
# --help show this help and exit
set -eo pipefail
@ -16,7 +16,7 @@ for arg in "$@"; do
echo "Usage: ./install.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --yes Non-interactive mode: select all defaults automatically"
echo " --yes Non-interactive mode: use default component selections"
echo " --help Show this help and exit"
echo ""
echo "Supported platforms: macOS (brew), Debian/Ubuntu (apt), Arch (pacman), Fedora (dnf)"

View file

@ -22,6 +22,8 @@ let g:chopsticks_enable_extra_languages = get(g:,
\ 'chopsticks_enable_extra_languages', !s:profile_minimal)
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_markdown_lint = get(g:, 'chopsticks_markdown_lint',
\ s:profile_full)

View file

@ -44,10 +44,12 @@ endif
" ── Language Syntax ──────────────────────────────────────────────────────────
Plug 'preservim/vim-markdown', { 'for': 'markdown' }
if g:chopsticks_enable_markdown_preview
Plug 'previm/previm', { 'on': 'PrevimOpen' }
endif
if g:chopsticks_enable_extra_languages
Plug 'pangloss/vim-javascript', { 'for': ['javascript', 'javascript.jsx'] }
Plug 'HerringtonDarkholme/yats.vim', { 'for': ['typescript', 'typescript.tsx'] }
Plug 'previm/previm', { 'on': 'PrevimOpen' }
Plug 'fatih/vim-go', { 'for': 'go' }
endif

View file

@ -34,7 +34,7 @@ nnoremap <leader>W :%s/\s\+$//<CR>:let @/=''<CR>
vnoremap <leader>W :s/\s\+$//<CR>:let @/=''<CR>gv
nnoremap <leader>ev :edit $MYVIMRC<CR>
nnoremap <leader>sv :source $MYVIMRC<CR>:echo "vimrc reloaded"<CR>
nnoremap <leader>sv :unlet! g:chopsticks_loaded<CR>:source $MYVIMRC<CR>:echo "vimrc reloaded"<CR>
nnoremap <leader>* :%s/\<<C-r><C-w>\>//g<Left><Left>
vnoremap <leader>* :s///g<Left><Left><Left>
@ -123,7 +123,14 @@ function! s:Check(name, cmd) abort
return executable(a:cmd) ? ' OK ' . a:name : ' -- ' . a:name . ' (missing: ' . a:cmd . ')'
endfunction
function! s:Off(name, reason) abort
return ' off ' . a:name . ' (' . a:reason . ')'
endfunction
function! s:LspCheck(ft, server) abort
if !get(g:, 'chopsticks_enable_lsp', 1)
return s:Off(a:ft, 'LSP disabled by profile')
endif
if !exists('*lsp#get_server_names')
return ' -- ' . a:ft . ' (vim-lsp not loaded)'
endif
@ -165,32 +172,40 @@ function! s:ChopsticksStatus() abort
call add(l:lines, '')
call add(l:lines, '── linters ──')
call add(l:lines, s:Check('flake8 (python)', 'flake8'))
call add(l:lines, s:Check('pylint (python)', 'pylint'))
call add(l:lines, s:Check('eslint (js/ts)', 'eslint'))
call add(l:lines, s:Check('staticcheck (go)', 'staticcheck'))
call add(l:lines, s:Check('shellcheck (sh)', 'shellcheck'))
call add(l:lines, s:Check('yamllint (yaml)', 'yamllint'))
call add(l:lines, s:Check('hadolint (docker)', 'hadolint'))
if get(g:, 'chopsticks_markdown_lint', 0)
call add(l:lines, s:Check('markdownlint (md)', 'markdownlint'))
if get(g:, 'chopsticks_enable_lint', 1)
call add(l:lines, s:Check('flake8 (python)', 'flake8'))
call add(l:lines, s:Check('pylint (python)', 'pylint'))
call add(l:lines, s:Check('eslint (js/ts)', 'eslint'))
call add(l:lines, s:Check('staticcheck (go)', 'staticcheck'))
call add(l:lines, s:Check('shellcheck (sh)', 'shellcheck'))
call add(l:lines, s:Check('yamllint (yaml)', 'yamllint'))
call add(l:lines, s:Check('hadolint (docker)', 'hadolint'))
if get(g:, 'chopsticks_markdown_lint', 0)
call add(l:lines, s:Check('markdownlint (md)', 'markdownlint'))
else
call add(l:lines, s:Off('markdownlint (md)', 'disabled by default'))
endif
else
call add(l:lines, ' off markdownlint (md) (disabled by default)')
call add(l:lines, s:Off('ALE linters', 'lint disabled by profile'))
endif
call add(l:lines, '')
call add(l:lines, '── formatters ── (format-on-save is ' . (get(g:, 'ale_fix_on_save', 0) ? 'ON' : 'OFF') . ')')
call add(l:lines, s:Check('black (python)', 'black'))
call add(l:lines, s:Check('isort (python)', 'isort'))
call add(l:lines, s:Check('prettier (js/ts/json)', 'prettier'))
if get(g:, 'chopsticks_markdown_format_on_save', 0)
call add(l:lines, s:Check('prettier (md)', 'prettier'))
if get(g:, 'chopsticks_enable_lint', 1)
call add(l:lines, s:Check('black (python)', 'black'))
call add(l:lines, s:Check('isort (python)', 'isort'))
call add(l:lines, s:Check('prettier (js/ts/json)', 'prettier'))
if get(g:, 'chopsticks_markdown_format_on_save', 0)
call add(l:lines, s:Check('prettier (md)', 'prettier'))
else
call add(l:lines, s:Off('prettier (md)', 'disabled by default'))
endif
call add(l:lines, s:Check('goimports (go)', 'goimports'))
call add(l:lines, s:Check('rustfmt (rust)', 'rustfmt'))
call add(l:lines, s:Check('clang-format (c)', 'clang-format'))
else
call add(l:lines, ' off prettier (md) (disabled by default)')
call add(l:lines, s:Off('ALE formatters', 'lint disabled by profile'))
endif
call add(l:lines, s:Check('goimports (go)', 'goimports'))
call add(l:lines, s:Check('rustfmt (rust)', 'rustfmt'))
call add(l:lines, s:Check('clang-format (c)', 'clang-format'))
call add(l:lines, '')
let l:ok = len(filter(copy(l:lines), 'v:val =~# " OK "'))
@ -199,7 +214,9 @@ function! s:ChopsticksStatus() abort
call add(l:lines, ' ' . l:ok . ' ready, ' . l:miss . ' missing')
call add(l:lines, '')
call add(l:lines, ' Install missing tools with ./install.sh')
call add(l:lines, ' Install LSP servers with :LspInstallServer')
if get(g:, 'chopsticks_enable_lsp', 1)
call add(l:lines, ' Install LSP servers with :LspInstallServer')
endif
let l:name = '__ChopsticksStatus__'
if bufwinnr(l:name) > 0