mirror of
https://oauth2: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@github.com/m1ngsama/chopsticks.git
synced 2026-05-10 19:10:59 +08:00
Respect profiles in local config and status
This commit is contained in:
parent
db9b96f577
commit
a9e16d22d3
8 changed files with 65 additions and 31 deletions
9
.vimrc
9
.vimrc
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)"
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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,6 +172,7 @@ function! s:ChopsticksStatus() abort
|
|||
call add(l:lines, '')
|
||||
|
||||
call add(l:lines, '── linters ──')
|
||||
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'))
|
||||
|
|
@ -175,22 +183,29 @@ function! s:ChopsticksStatus() abort
|
|||
if get(g:, 'chopsticks_markdown_lint', 0)
|
||||
call add(l:lines, s:Check('markdownlint (md)', 'markdownlint'))
|
||||
else
|
||||
call add(l:lines, ' off markdownlint (md) (disabled by default)')
|
||||
call add(l:lines, s:Off('markdownlint (md)', 'disabled by default'))
|
||||
endif
|
||||
else
|
||||
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') . ')')
|
||||
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, ' off prettier (md) (disabled by default)')
|
||||
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, s:Off('ALE formatters', 'lint disabled by profile'))
|
||||
endif
|
||||
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')
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue