Refine Vim defaults and add profiles

This commit is contained in:
m1ngsama 2026-04-30 13:07:21 +08:00
parent cddb5fa725
commit db9b96f577
15 changed files with 307 additions and 78 deletions

View file

@ -36,16 +36,33 @@ jobs:
cp modules/*.vim ~/.vim/modules/ cp modules/*.vim ~/.vim/modules/
- name: Install plugins - name: Install plugins
run: vim -es -u .vimrc -c 'PlugInstall --sync' -c 'qa!' 2>&1 || true run: |
set +e
vim -i NONE -es -u .vimrc -N -c 'PlugInstall --sync' -c 'qa!' 2>&1
plug_status=$?
set -e
if [ "$plug_status" -ne 0 ]; then
echo "PlugInstall exited with $plug_status; validating plugin directories"
fi
for plugin in fzf fzf.vim vim-fugitive vim-gitgutter ale vim-lsp vim-lsp-settings asyncomplete.vim asyncomplete-lsp.vim vim-markdown; do
test -d "$HOME/.vim/plugged/$plugin" || {
echo "FAIL: missing plugin $plugin"
exit 1
}
done
- name: Test startup - name: Test startup
run: | run: |
vim -u .vimrc -es -N -c 'qa!' 2>&1 vim -u .vimrc -i NONE -es -N -c 'qa!' 2>&1
echo "Vim exited cleanly" echo "Vim exited cleanly"
- name: Verify modules load - name: Verify modules load
run: | run: |
vim -u .vimrc -N -c 'redir! > /tmp/test.txt | echo len(g:plugs) | redir END | qa!' 2>/dev/null vim -u .vimrc -i NONE -es -N \
-c 'redir! > /tmp/test.txt' \
-c 'silent echo len(g:plugs)' \
-c 'redir END' \
-c 'qa!' 2>/dev/null
PLUGS=$(cat /tmp/test.txt | tr -d '[:space:]') PLUGS=$(cat /tmp/test.txt | tr -d '[:space:]')
echo "Plugins registered: $PLUGS" echo "Plugins registered: $PLUGS"
if [ "$PLUGS" -lt 20 ]; then if [ "$PLUGS" -lt 20 ]; then
@ -53,10 +70,35 @@ jobs:
exit 1 exit 1
fi fi
- name: Verify minimal profile
run: |
vim -u NONE -i NONE -es -N \
-c 'let g:chopsticks_profile = "minimal"' \
-c 'source .vimrc' \
-c 'if has_key(g:plugs, "ale") || has_key(g:plugs, "vim-lsp") || has_key(g:plugs, "vim-lsp-settings") || has_key(g:plugs, "asyncomplete.vim") | cquit | endif' \
-c 'qa!' 2>&1
- name: Verify Markdown quiet defaults
run: |
vim -u .vimrc -i NONE -es -N README.md \
-c 'set filetype=markdown' \
-c 'if &l:spell || &l:conceallevel != 0 || &l:signcolumn !=# "no" || exists("g:lsp_settings_filetype_markdown") | cquit | endif' \
-c 'qa!' 2>&1
- name: Verify ergonomic defaults
run: |
vim -u .vimrc -i NONE -es -N \
-c 'if maparg("s", "n") !=# "" | cquit | endif' \
-c 'if maparg(",w", "n") =~# "!" | cquit | endif' \
-c 'if !&swapfile || !&writebackup || &directory !~# "\.vim/.swap" | cquit | endif' \
-c 'qa!' 2>&1
- name: Measure startup time - name: Measure startup time
run: | run: |
vim -u .vimrc --startuptime /tmp/startup.log -c 'qa!' 2>/dev/null vim -u .vimrc -i NONE --startuptime /tmp/startup.log -es -N -c 'qa!' 2>/dev/null
tail -1 /tmp/startup.log tail -1 /tmp/startup.log
STARTUP_MS=$(tail -1 /tmp/startup.log | awk '{print $1}')
awk -v ms="$STARTUP_MS" 'BEGIN { if (ms > 150) exit 1 }'
shellcheck: shellcheck:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -64,3 +106,12 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Shellcheck install.sh - name: Shellcheck install.sh
run: shellcheck install.sh get.sh run: shellcheck install.sh get.sh
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install markdownlint
run: npm install -g markdownlint-cli
- name: Lint Markdown
run: markdownlint README.md QUICKSTART.md CONTRIBUTING.md CHANGELOG.md

13
.markdownlint.json Normal file
View file

@ -0,0 +1,13 @@
{
"default": true,
"MD013": false,
"MD022": false,
"MD024": {
"siblings_only": true
},
"MD032": false,
"MD033": false,
"MD040": false,
"MD041": false,
"MD060": false
}

View file

@ -3,15 +3,29 @@
## Unreleased ## Unreleased
### Added ### Added
- `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 - `:ChopsticksStatus` diagnostic command — checks system tools, LSP servers, linters, formatters
- `,af` toggle format-on-save (ALE `fix_on_save`) - `,af` toggle format-on-save (ALE `fix_on_save`)
- `,gL` git log graph (last 20 commits) - `,gL` git log graph (last 20 commits)
- `,gC` FZF git commits search, `,gB` buffer commits - `,gC` FZF git commits search, `,gB` buffer commits
### Fixed ### Fixed
- `g:loaded_logipat` typo → `g:loaded_logiPat` — logiPat was loading fully (0.478ms wasted) - `g:loaded_logipat` typo → `g:loaded_logiPat` — logiPat was loading fully (0.478ms wasted)
### Changed ### Changed
- Markdown now opens in quiet writing mode by default: no real-time markdownlint,
no Marksman LSP, no spell noise, no conceal, no sign column, and no realtime preview
- Native `s` is no longer shadowed by EasyMotion; use `,S` for the two-character jump
- `,w` now uses a normal `:write` instead of forced `:write!`
- 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
- 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) - Skip 2 more built-in plugins: openPlugin, manpager (10 → 12 total)
- Remove deprecated `set ttyfast` (no-op since Vim 8) - Remove deprecated `set ttyfast` (no-op since Vim 8)
- Add `grepprg=rg --vimgrep``:grep` now uses ripgrep + quickfix - Add `grepprg=rg --vimgrep``:grep` now uses ripgrep + quickfix
@ -23,17 +37,20 @@
## 2.1.0 — 2025-04-22 ## 2.1.0 — 2025-04-22
### Added ### Added
- Cheat sheet (`,?`) — vertical sidebar, one key per line, section headers - Cheat sheet (`,?`) — vertical sidebar, one key per line, section headers
- Previm markdown preview restored (lazy-loaded, `,mp`) - Previm markdown preview restored (lazy-loaded, `,mp`)
- `:LspInstallServer` added to cheat sheet - `:LspInstallServer` added to cheat sheet
### Changed ### Changed
- Plugin count: 25 (restored previm, dropped 5 bloat plugins) - Plugin count: 25 (restored previm, dropped 5 bloat plugins)
- QUICKSTART updated — removed stale references, improved first-launch guidance - QUICKSTART updated — removed stale references, improved first-launch guidance
## 2.0.0 — 2025-04-21 ## 2.0.0 — 2025-04-21
### Added ### Added
- Sidebar toggle (`,e` / `,E`) — left-side netrw with `topleft vertical`, winfixwidth, proper toggle - Sidebar toggle (`,e` / `,E`) — left-side netrw with `topleft vertical`, winfixwidth, proper toggle
- Enriched statusline — SLMode, SLGit, SLAle, SLFlags - Enriched statusline — SLMode, SLGit, SLAle, SLFlags
- Toggle feedback — F2/F3/F4/F6/`,ss` echo current state - Toggle feedback — F2/F3/F4/F6/`,ss` echo current state
@ -41,6 +58,7 @@
- Interactive tutorial (`:ChopsticksLearn` — removed in later release) - Interactive tutorial (`:ChopsticksLearn` — removed in later release)
### Removed (Unix minimalism refactor) ### Removed (Unix minimalism refactor)
- **565 lines** of dead code and bloat - **565 lines** of dead code and bloat
- 5 plugins: Goyo, Limelight, vim-obsession, indentLine, vim-unimpaired - 5 plugins: Goyo, Limelight, vim-obsession, indentLine, vim-unimpaired
- `modules/writing.vim` — folded into `languages.vim` - `modules/writing.vim` — folded into `languages.vim`
@ -50,6 +68,7 @@
- TTY welcome message, `,so`, `,ms`, `,sh` mappings - TTY welcome message, `,so`, `,ms`, `,sh` mappings
### Changed ### Changed
- CI plugin threshold lowered to 20 - CI plugin threshold lowered to 20
- README: hero layout with demo GIF, badges, architecture diagram - README: hero layout with demo GIF, badges, architecture diagram
- vim-markdown settings absorbed from writing.vim into languages.vim - vim-markdown settings absorbed from writing.vim into languages.vim
@ -57,6 +76,7 @@
## 1.3.0 — 2025-04-20 ## 1.3.0 — 2025-04-20
### Changed ### Changed
- Startup: 39ms → 19ms (51% faster) - Startup: 39ms → 19ms (51% faster)
- Dropped vim-unimpaired for performance - Dropped vim-unimpaired for performance
- Runtime tuning across modules - Runtime tuning across modules
@ -64,16 +84,19 @@
## 1.2.0 — 2025-04-19 ## 1.2.0 — 2025-04-19
### Added ### Added
- Hero README with demo GIF, CI badges - Hero README with demo GIF, CI badges
- GitHub Actions CI (startup test on macOS + Ubuntu, shellcheck) - GitHub Actions CI (startup test on macOS + Ubuntu, shellcheck)
- Issue/PR templates - Issue/PR templates
### Changed ### Changed
- Documentation rewrite — clean, short, for engineers - Documentation rewrite — clean, short, for engineers
## 1.1.0 — 2025-04-18 ## 1.1.0 — 2025-04-18
### Added ### Added
- 12-module architecture (env → plugins → core → ui → editing → navigation → lsp → lint → git → writing → languages → tools) - 12-module architecture (env → plugins → core → ui → editing → navigation → lsp → lint → git → writing → languages → tools)
- Zen mode (Goyo + Limelight) - Zen mode (Goyo + Limelight)
- Run file (`,cr`) with auto filetype detection - Run file (`,cr`) with auto filetype detection
@ -82,12 +105,14 @@
- Robust installer (`get.sh`) with preflight checks - Robust installer (`get.sh`) with preflight checks
### Changed ### Changed
- `.vimrc` split into 12 self-contained modules - `.vimrc` split into 12 self-contained modules
- Comprehensive bug audit (14 fixes) - Comprehensive bug audit (14 fixes)
## 1.0.0 — 2025-04-16 ## 1.0.0 — 2025-04-16
### Added ### Added
- Initial Vim configuration — migrated from Neovim - Initial Vim configuration — migrated from Neovim
- vim-plug plugin manager - vim-plug plugin manager
- vim-lsp + asyncomplete (pure VimScript LSP) - vim-lsp + asyncomplete (pure VimScript LSP)

View file

@ -3,7 +3,7 @@
## Rules ## Rules
1. **No Node.js dependencies.** The LSP engine is pure VimScript. Some language servers need Node — that's fine. The config itself must not. 1. **No Node.js dependencies.** The LSP engine is pure VimScript. Some language servers need Node — that's fine. The config itself must not.
2. **Startup matters.** Run `vim --startuptime /tmp/s.log -c qa!` before and after. If your change adds >1ms, it needs a good reason. 2. **Startup matters.** Run `vim -u .vimrc -i NONE --startuptime /tmp/s.log -es -N -c qa!` before and after. If your change adds >1ms, it needs a good reason.
3. **Works on TTY.** Test over SSH. If it breaks in a terminal without true color, fix it or gate it behind `g:is_tty`. 3. **Works on TTY.** Test over SSH. If it breaks in a terminal without true color, fix it or gate it behind `g:is_tty`.
4. **One module, one concern.** Don't put git config in lsp.vim. 4. **One module, one concern.** Don't put git config in lsp.vim.
@ -18,6 +18,7 @@
## Reporting bugs ## Reporting bugs
Open an issue. Include: Open an issue. Include:
- OS and Vim version - OS and Vim version
- Whether you're on SSH/TTY - Whether you're on SSH/TTY
- Steps to reproduce - Steps to reproduce
@ -25,6 +26,6 @@ Open an issue. Include:
## Code style ## Code style
- Named augroups with `autocmd!` - Named augroups with `autocmd!`
- No comments explaining *what* — only *why* - No comments explaining _what_ — only _why_
- `exists('g:plugs["..."]')` guards for plugin-dependent config - `exists('g:plugs["..."]')` guards for plugin-dependent config
- Test with `vim -u .vimrc --startuptime /tmp/s.log -c qa!` - Test with `vim -u .vimrc -i NONE --startuptime /tmp/s.log -es -N -c qa!`

View file

@ -10,10 +10,14 @@ 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. 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
heavier Markdown/LSP feedback.
## Modes ## Modes
| Mode | Enter | Leave | | Mode | Enter | Leave |
|------|-------|-------| | ------ | --------------- | ------------- |
| Normal | startup default | — | | Normal | startup default | — |
| Insert | `i` / `a` / `o` | `Esc` or `jk` | | Insert | `i` / `a` / `o` | `Esc` or `jk` |
| Visual | `v` / `V` | `Esc` | | Visual | `v` / `V` | `Esc` |
@ -67,7 +71,7 @@ Tab / S-Tab cycle completions
## Edit ## Edit
``` ```
s + 2 chars EasyMotion jump ,S + 2 chars EasyMotion jump
gc toggle comment gc toggle comment
cs"' change surrounding " to ' cs"' change surrounding " to '
Alt+j / Alt+k move line Alt+j / Alt+k move line
@ -91,6 +95,9 @@ Ctrl+h/j/k/l splits + tmux panes
,mt table of contents ,mt table of contents
``` ```
Markdown is quiet by default: no real-time lint, no spell noise, no concealed
syntax. Enable the heavier Markdown tools only when you want them.
## Health check ## Health check
``` ```

View file

@ -35,13 +35,13 @@ chopsticks gives you a production-ready Vim config in one command. Pure VimScrip
## What's in the box ## What's in the box
| Feature | Description | | Feature | Description |
|---------|-------------| | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **LSP** | completion, go-to-def, hover, rename, code actions — pure VimScript ([vim-lsp](https://github.com/prabirshrestha/vim-lsp)) | | **LSP** | completion, go-to-def, hover, rename, code actions — pure VimScript ([vim-lsp](https://github.com/prabirshrestha/vim-lsp)) |
| **Lint + format** | [ALE](https://github.com/dense-analysis/ale) runs black, prettier, goimports, rustfmt on save | | **Lint + format** | [ALE](https://github.com/dense-analysis/ale) runs black, prettier, goimports, rustfmt on save |
| **Fuzzy find** | files, buffers, grep, tags, marks, commands — [FZF](https://github.com/junegunn/fzf.vim) | | **Fuzzy find** | files, buffers, grep, tags, marks, commands — [FZF](https://github.com/junegunn/fzf.vim) |
| **Git** | status, diff, blame, push, pull, conflict markers — [fugitive](https://github.com/tpope/vim-fugitive) + [gitgutter](https://github.com/airblade/vim-gitgutter) | | **Git** | status, diff, blame, push, pull, conflict markers — [fugitive](https://github.com/tpope/vim-fugitive) + [gitgutter](https://github.com/airblade/vim-gitgutter) |
| **Run file** | `,cr` — auto-detects Python, Go, Rust, JS, C, Shell, and more | | **Run file** | `,cr` — auto-detects Python, Go, Rust, JS, C, Shell, and more |
| **Markdown** | live preview in browser (`,mp`), table of contents (`,mt`) | | **Markdown** | quiet writing defaults, browser preview (`,mp`), table of contents (`,mt`) |
| **Diagnostics** | `:ChopsticksStatus` — see what's installed, what's missing, how to fix it | | **Diagnostics** | `:ChopsticksStatus` — see what's installed, what's missing, how to fix it |
| **TTY-aware** | degrades gracefully on SSH, console, slow links — never breaks | | **TTY-aware** | degrades gracefully on SSH, console, slow links — never breaks |
@ -62,6 +62,21 @@ Supports macOS (brew), Debian/Ubuntu (apt), Arch (pacman), Fedora (dnf).
First launch installs plugins automatically (30-60s). Restart vim when done. First launch installs plugins automatically (30-60s). Restart vim when done.
## Profiles
Default profile: `engineer`.
```vim
" Put this before sourcing chopsticks.
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.
## Keys ## Keys
Leader: `,` Leader: `,`
@ -88,7 +103,7 @@ jk exit insert mode ,? cheat sheet
### Edit ### 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 | `,W` strip whitespace | `[<Space>` `]<Space>` blank lines
### Git ### Git
@ -120,10 +135,36 @@ jk exit insert mode ,? cheat sheet
:ChopsticksStatus " see all tools + LSP + linters at a glance :ChopsticksStatus " see all tools + LSP + linters at a glance
``` ```
pylsp, gopls, rust-analyzer, clangd, marksman, sqls — no Node.js. JS/TS servers need Node. pylsp, gopls, rust-analyzer, clangd, sqls — no Node.js. JS/TS servers need Node.
Markdown LSP (`marksman`) is opt-in so prose buffers stay quiet by default.
ALE and vim-lsp coexist cleanly (`ale_disable_lsp=1`). ALE handles linting + formatting. vim-lsp handles everything else. ALE and vim-lsp coexist cleanly (`ale_disable_lsp=1`). ALE handles linting + formatting. vim-lsp handles everything else.
## Markdown
Markdown opens in writing mode: wrapped text, no spell noise, no concealed
syntax, no sign column, no real-time markdownlint, and no Marksman diagnostics.
The explicit commands still work:
```vim
,mp " preview in browser
,mt " table of contents
```
Opt into heavier Markdown tooling from your own vimrc before loading
chopsticks:
```vim
let g:chopsticks_markdown_lint = 1
let g:chopsticks_markdown_format_on_save = 1
let g:chopsticks_markdown_lsp = 1
let g:chopsticks_markdown_spell = 1
let g:chopsticks_markdown_conceal = 1
let g:previm_enable_realtime = 1
```
For Markdown LSP, install or select `marksman` first.
## Architecture ## Architecture
``` ```
@ -148,7 +189,7 @@ Each module is self-contained. Comment out one line in `.vimrc` to disable it. A
## Performance ## Performance
| Metric | Value | | Metric | Value |
|--------|-------| | ------------------------ | ------------------------------------------- |
| Lazy-loaded | 7 plugins (on command or filetype) | | Lazy-loaded | 7 plugins (on command or filetype) |
| Built-in plugins skipped | 12 (gzip, tar, zip, vimball, logiPat, etc.) | | Built-in plugins skipped | 12 (gzip, tar, zip, vimball, logiPat, etc.) |
| Large file threshold | 10MB (auto-disables syntax + undo) | | Large file threshold | 10MB (auto-disables syntax + undo) |
@ -157,7 +198,7 @@ Each module is self-contained. Comment out one line in `.vimrc` to disable it. A
## Troubleshooting ## Troubleshooting
| Problem | Fix | | Problem | Fix |
|---------|-----| | ------------------- | --------------------------------------------- |
| 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 |

View file

@ -467,19 +467,19 @@ if [[ $HAS_PKG_MGR -eq 1 ]]; then
: $(( _idx++ )) : $(( _idx++ ))
_I_CTAGS=$_idx _I_CTAGS=$_idx
_ITEMS+=("universal-ctags|code symbol index (backing engine for ,rt tag jumps)|1") _ITEMS+=("universal-ctags|Optional symbol index for ,rt tag jumps|0")
: $(( _idx++ )) : $(( _idx++ ))
_I_SHELLCHECK=$_idx _I_SHELLCHECK=$_idx
_ITEMS+=("shellcheck|shell script static analysis (ALE integration, on-save)|1") _ITEMS+=("shellcheck|Optional shell script static analysis via ALE|0")
: $(( _idx++ )) : $(( _idx++ ))
_I_HADOLINT=$_idx _I_HADOLINT=$_idx
_ITEMS+=("hadolint|Dockerfile linting (ALE integration, on-save)|1") _ITEMS+=("hadolint|Optional Dockerfile linting via ALE|0")
: $(( _idx++ )) : $(( _idx++ ))
_I_MARKSMAN=$_idx _I_MARKSMAN=$_idx
_ITEMS+=("marksman|Markdown LSP — completion · go-to-definition · live diagnostics|1") _ITEMS+=("marksman|Optional Markdown LSP — enable with g:chopsticks_markdown_lsp|0")
: $(( _idx++ )) : $(( _idx++ ))
else else
warn "No package manager available — system tools skipped" warn "No package manager available — system tools skipped"
@ -488,21 +488,21 @@ fi
# ── npm tools ──────────────────────────────────────────────────────────────── # ── npm tools ────────────────────────────────────────────────────────────────
if [[ $HAS_NODE -eq 1 ]]; then if [[ $HAS_NODE -eq 1 ]]; then
_I_NPM=$_idx _I_NPM=$_idx
_ITEMS+=("npm formatter suite|prettier / eslint / markdownlint / stylelint / tsc — ALE fix-on-save|1") _ITEMS+=("npm formatter suite|Optional prettier / eslint / markdownlint / stylelint / tsc|0")
: $(( _idx++ )) : $(( _idx++ ))
fi fi
# ── Python tools ───────────────────────────────────────────────────────────── # ── Python tools ─────────────────────────────────────────────────────────────
if [[ $HAS_PIP -eq 1 ]]; then if [[ $HAS_PIP -eq 1 ]]; then
_I_PYTHON=$_idx _I_PYTHON=$_idx
_ITEMS+=("Python tool suite|black / isort / flake8 / pylint / yamllint / sqlfluff — ALE fix-on-save|1") _ITEMS+=("Python tool suite|Optional black / isort / flake8 / pylint / yamllint / sqlfluff|0")
: $(( _idx++ )) : $(( _idx++ ))
fi fi
# ── Go tools ───────────────────────────────────────────────────────────────── # ── Go tools ─────────────────────────────────────────────────────────────────
if [[ $HAS_GO -eq 1 ]]; then if [[ $HAS_GO -eq 1 ]]; then
_I_GO=$_idx _I_GO=$_idx
_ITEMS+=("Go tool suite|gopls (LSP) / goimports / staticcheck — completion · format · analysis|1") _ITEMS+=("Go tool suite|Optional gopls / goimports / staticcheck|0")
: $(( _idx++ )) : $(( _idx++ ))
fi fi
@ -510,7 +510,7 @@ fi
if command -v tmux >/dev/null 2>&1; then if command -v tmux >/dev/null 2>&1; then
if ! grep -q 'vim-tmux-navigator' "$HOME/.tmux.conf" 2>/dev/null; then if ! grep -q 'vim-tmux-navigator' "$HOME/.tmux.conf" 2>/dev/null; then
_I_TMUX=$_idx _I_TMUX=$_idx
_ITEMS+=("tmux integration|seamless Ctrl+h/j/k/l navigation between vim and tmux panes|1") _ITEMS+=("tmux integration|Optional Ctrl+h/j/k/l navigation between vim and tmux panes|0")
: $(( _idx++ )) : $(( _idx++ ))
else else
ok "tmux integration (vim-tmux-navigator already configured)" ok "tmux integration (vim-tmux-navigator already configured)"

View file

@ -57,8 +57,14 @@ endif
set display+=lastline set display+=lastline
set ffs=unix,dos,mac set ffs=unix,dos,mac
set nowb set writebackup
set noswapfile
if has('unix')
let s:swap_dir = expand(get(g:, 'chopsticks_swap_dir', '~/.vim/.swap'))
let &directory = s:swap_dir . '//,/tmp//'
silent! call mkdir(s:swap_dir, 'p', 0700)
endif
set swapfile
if has('persistent_undo') if has('persistent_undo')
set undofile set undofile
@ -89,7 +95,7 @@ let mapleader = ","
" ── Basic Keymaps ─────────────────────────────────────────────────────────── " ── Basic Keymaps ───────────────────────────────────────────────────────────
nnoremap <leader>w :w!<cr> nnoremap <leader>w :w<cr>
nnoremap <leader>q :q<cr> nnoremap <leader>q :q<cr>
nnoremap <leader>x :x<cr> nnoremap <leader>x :x<cr>

View file

@ -6,7 +6,7 @@ let g:EasyMotion_do_mapping = 0
let g:EasyMotion_smartcase = 1 let g:EasyMotion_smartcase = 1
if exists('g:plugs["vim-easymotion"]') if exists('g:plugs["vim-easymotion"]')
nmap s <Plug>(easymotion-overwin-f2) nmap <Leader>S <Plug>(easymotion-overwin-f2)
nmap <Leader>j <Plug>(easymotion-j) nmap <Leader>j <Plug>(easymotion-j)
nmap <Leader>k <Plug>(easymotion-k) nmap <Leader>k <Plug>(easymotion-k)
endif endif

View file

@ -6,6 +6,36 @@ let g:is_tty = empty($TERM) || $TERM ==# 'dumb' || $TERM =~# 'linux'
\ || $TERM =~# 'screen' || &term =~# 'builtin' \ || $TERM =~# 'screen' || &term =~# 'builtin'
let g:has_true_color = ($COLORTERM ==# 'truecolor' || $COLORTERM ==# '24bit') let g:has_true_color = ($COLORTERM ==# 'truecolor' || $COLORTERM ==# '24bit')
let g:chopsticks_profile = get(g:, 'chopsticks_profile', 'engineer')
if index(['minimal', 'engineer', 'full'], g:chopsticks_profile) < 0
let g:chopsticks_profile = 'engineer'
endif
let s:profile_full = g:chopsticks_profile ==# 'full'
let s:profile_minimal = g:chopsticks_profile ==# 'minimal'
let g:chopsticks_enable_lsp = get(g:, 'chopsticks_enable_lsp',
\ !s:profile_minimal)
let g:chopsticks_enable_lint = get(g:, 'chopsticks_enable_lint',
\ !s:profile_minimal)
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_markdown_lint = get(g:, 'chopsticks_markdown_lint',
\ s:profile_full)
let g:chopsticks_markdown_format_on_save = get(g:,
\ 'chopsticks_markdown_format_on_save', s:profile_full)
let g:chopsticks_markdown_lsp = get(g:, 'chopsticks_markdown_lsp',
\ s:profile_full)
let g:chopsticks_markdown_spell = get(g:, 'chopsticks_markdown_spell',
\ s:profile_full)
let g:chopsticks_markdown_conceal = get(g:, 'chopsticks_markdown_conceal',
\ s:profile_full)
let g:chopsticks_lsp_virtual_text = get(g:, 'chopsticks_lsp_virtual_text',
\ s:profile_full && !g:is_tty)
" Skip built-in plugins we never use " Skip built-in plugins we never use
let g:loaded_2html_plugin = 1 let g:loaded_2html_plugin = 1
let g:loaded_getscriptPlugin = 1 let g:loaded_getscriptPlugin = 1

View file

@ -2,9 +2,10 @@
" ── vim-markdown ─────────────────────────────────────────────────────────── " ── vim-markdown ───────────────────────────────────────────────────────────
let g:vim_markdown_conceal = 1 let g:vim_markdown_conceal = get(g:, 'vim_markdown_conceal',
\ g:chopsticks_markdown_conceal)
let g:vim_markdown_conceal_code_blocks = 0 let g:vim_markdown_conceal_code_blocks = 0
let g:vim_markdown_folding_disabled = 0 let g:vim_markdown_folding_disabled = get(g:, 'vim_markdown_folding_disabled', 1)
let g:vim_markdown_folding_level = 2 let g:vim_markdown_folding_level = 2
let g:vim_markdown_frontmatter = 1 let g:vim_markdown_frontmatter = 1
let g:vim_markdown_toml_frontmatter = 1 let g:vim_markdown_toml_frontmatter = 1
@ -22,7 +23,7 @@ if has('macunix')
elseif executable('xdg-open') elseif executable('xdg-open')
let g:previm_open_cmd = 'xdg-open' let g:previm_open_cmd = 'xdg-open'
endif endif
let g:previm_enable_realtime = 1 let g:previm_enable_realtime = get(g:, 'previm_enable_realtime', 0)
if exists('g:plugs["previm"]') if exists('g:plugs["previm"]')
nnoremap <leader>mp :PrevimOpen<CR> nnoremap <leader>mp :PrevimOpen<CR>
endif endif
@ -40,6 +41,22 @@ let g:go_highlight_function_calls = 1
" ── Filetype Detection ────────────────────────────────────────────────────── " ── Filetype Detection ──────────────────────────────────────────────────────
function! s:MarkdownDefaults() abort
setlocal wrap linebreak textwidth=0 colorcolumn=0 signcolumn=no
let &l:conceallevel = get(g:, 'chopsticks_markdown_conceal', 0) ? 2 : 0
if get(g:, 'chopsticks_markdown_spell', 0)
setlocal spell
else
setlocal nospell
endif
if !get(g:, 'chopsticks_markdown_lint', 0)
\ && !get(g:, 'chopsticks_markdown_format_on_save', 0)
let b:ale_enabled = 0
endif
endfunction
augroup ChopstickFiletype augroup ChopstickFiletype
autocmd! autocmd!
@ -60,8 +77,7 @@ augroup ChopstickFiletype
\ setlocal expandtab shiftwidth=2 tabstop=2 \ setlocal expandtab shiftwidth=2 tabstop=2
autocmd FileType yaml autocmd FileType yaml
\ setlocal expandtab shiftwidth=2 tabstop=2 \ setlocal expandtab shiftwidth=2 tabstop=2
autocmd FileType markdown autocmd FileType markdown call s:MarkdownDefaults()
\ setlocal wrap linebreak spell textwidth=0 conceallevel=2
autocmd FileType sh autocmd FileType sh
\ setlocal expandtab shiftwidth=2 tabstop=2 textwidth=80 \ setlocal expandtab shiftwidth=2 tabstop=2 textwidth=80
autocmd FileType make autocmd FileType make

View file

@ -1,8 +1,12 @@
" lint.vim — ALE async linting and format-on-save " lint.vim — ALE async linting and format-on-save
if !g:chopsticks_enable_lint
finish
endif
let g:ale_disable_lsp = 1 let g:ale_disable_lsp = 1
let g:ale_linters = { let s:ale_linters = {
\ 'python': ['flake8', 'pylint'], \ 'python': ['flake8', 'pylint'],
\ 'javascript': ['eslint'], \ 'javascript': ['eslint'],
\ 'typescript': ['eslint'], \ 'typescript': ['eslint'],
@ -14,11 +18,16 @@ let g:ale_linters = {
\ 'dockerfile': ['hadolint'], \ 'dockerfile': ['hadolint'],
\ 'css': ['stylelint'], \ 'css': ['stylelint'],
\ 'scss': ['stylelint'], \ 'scss': ['stylelint'],
\ 'markdown': ['markdownlint'],
\ 'sql': ['sqlfluff'], \ 'sql': ['sqlfluff'],
\} \}
let g:ale_fixers = { if g:chopsticks_markdown_lint
let s:ale_linters.markdown = ['markdownlint']
endif
let g:ale_linters = s:ale_linters
let s:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'], \ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'python': ['black', 'isort'], \ 'python': ['black', 'isort'],
\ 'javascript': ['prettier', 'eslint'], \ 'javascript': ['prettier', 'eslint'],
@ -32,10 +41,15 @@ let g:ale_fixers = {
\ 'css': ['prettier'], \ 'css': ['prettier'],
\ 'scss': ['prettier'], \ 'scss': ['prettier'],
\ 'less': ['prettier'], \ 'less': ['prettier'],
\ 'markdown': ['prettier'],
\ 'sql': ['sqlfluff'], \ 'sql': ['sqlfluff'],
\} \}
if g:chopsticks_markdown_format_on_save
let s:ale_fixers.markdown = ['prettier']
endif
let g:ale_fixers = s:ale_fixers
let g:ale_fix_on_save = 1 let g:ale_fix_on_save = 1
let g:ale_python_isort_options = '--profile black' let g:ale_python_isort_options = '--profile black'
let g:ale_sign_error = 'X' let g:ale_sign_error = 'X'
@ -45,6 +59,7 @@ let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_enter = 1 let g:ale_lint_on_enter = 1
let g:ale_lint_delay = 200 let g:ale_lint_delay = 200
let g:ale_echo_delay = 100 let g:ale_echo_delay = 100
let g:ale_virtualtext_cursor = get(g:, 'ale_virtualtext_cursor', 'disabled')
if exists('g:plugs["ale"]') if exists('g:plugs["ale"]')
nnoremap <silent> [e :ALEPrevious<cr> nnoremap <silent> [e :ALEPrevious<cr>

View file

@ -1,5 +1,9 @@
" lsp.vim — vim-lsp settings, asyncomplete, LSP buffer keymaps " lsp.vim — vim-lsp settings, asyncomplete, LSP buffer keymaps
if !g:chopsticks_enable_lsp
finish
endif
let g:lsp_settings_lazyload = 1 let g:lsp_settings_lazyload = 1
let g:lsp_settings_filetype_python = ['pylsp'] let g:lsp_settings_filetype_python = ['pylsp']
@ -14,10 +18,13 @@ let g:lsp_settings_filetype_css = ['vscode-css-language-server']
let g:lsp_settings_filetype_scss = ['vscode-css-language-server'] let g:lsp_settings_filetype_scss = ['vscode-css-language-server']
let g:lsp_settings_filetype_json = ['vscode-json-language-server'] let g:lsp_settings_filetype_json = ['vscode-json-language-server']
let g:lsp_settings_filetype_yaml = ['yaml-language-server'] let g:lsp_settings_filetype_yaml = ['yaml-language-server']
let g:lsp_settings_filetype_markdown = ['marksman']
let g:lsp_settings_filetype_sql = ['sqls'] let g:lsp_settings_filetype_sql = ['sqls']
let g:lsp_diagnostics_virtual_text_enabled = !g:is_tty if g:chopsticks_markdown_lsp
let g:lsp_settings_filetype_markdown = ['marksman']
endif
let g:lsp_diagnostics_virtual_text_enabled = g:chopsticks_lsp_virtual_text
let g:lsp_diagnostics_virtual_text_delay = 200 let g:lsp_diagnostics_virtual_text_delay = 200
let g:lsp_diagnostics_highlights_enabled = !g:is_tty let g:lsp_diagnostics_highlights_enabled = !g:is_tty
let g:lsp_document_highlight_enabled = !g:is_tty let g:lsp_document_highlight_enabled = !g:is_tty
@ -52,7 +59,7 @@ inoremap <expr> <CR> pumvisible() ? asyncomplete#close_popup() : "\<CR>"
function! s:on_lsp_buffer_enabled() abort function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete setlocal omnifunc=lsp#complete
if !g:is_tty if !g:is_tty && &filetype !=# 'markdown'
setlocal signcolumn=yes setlocal signcolumn=yes
endif endif

View file

@ -29,25 +29,33 @@ Plug 'wellle/targets.vim'
Plug 'jiangmiao/auto-pairs' Plug 'jiangmiao/auto-pairs'
Plug 'easymotion/vim-easymotion', { 'on': '<Plug>(easymotion' } Plug 'easymotion/vim-easymotion', { 'on': '<Plug>(easymotion' }
" ── Linting & Formatting ──────────────────────────────────────────────────── if g:chopsticks_enable_lint
Plug 'dense-analysis/ale' " ── Linting & Formatting ────────────────────────────────────────────────
Plug 'dense-analysis/ale'
endif
" ── LSP + Completion ───────────────────────────────────────────────────────── if g:chopsticks_enable_lsp
Plug 'prabirshrestha/vim-lsp' " ── LSP + Completion ─────────────────────────────────────────────────────
Plug 'mattn/vim-lsp-settings' Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/asyncomplete.vim' Plug 'mattn/vim-lsp-settings'
Plug 'prabirshrestha/asyncomplete-lsp.vim' Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
endif
" ── Language Syntax ────────────────────────────────────────────────────────── " ── Language Syntax ──────────────────────────────────────────────────────────
Plug 'pangloss/vim-javascript', { 'for': ['javascript', 'javascript.jsx'] }
Plug 'HerringtonDarkholme/yats.vim', { 'for': ['typescript', 'typescript.tsx'] }
Plug 'preservim/vim-markdown', { 'for': 'markdown' } Plug 'preservim/vim-markdown', { 'for': 'markdown' }
Plug 'previm/previm', { 'on': 'PrevimOpen' } if g:chopsticks_enable_extra_languages
Plug 'fatih/vim-go', { 'for': 'go' } 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
" ── UI ─────────────────────────────────────────────────────────────────────── " ── UI ───────────────────────────────────────────────────────────────────────
Plug 'mbbill/undotree', { 'on': 'UndotreeToggle' } if g:chopsticks_enable_ui_extras
Plug 'mhinz/vim-startify' Plug 'mbbill/undotree', { 'on': 'UndotreeToggle' }
Plug 'mhinz/vim-startify'
endif
Plug 'lifepillar/vim-solarized8' Plug 'lifepillar/vim-solarized8'
if !empty($TMUX) if !empty($TMUX)
Plug 'christoomey/vim-tmux-navigator' Plug 'christoomey/vim-tmux-navigator'

View file

@ -172,13 +172,22 @@ function! s:ChopsticksStatus() abort
call add(l:lines, s:Check('shellcheck (sh)', 'shellcheck')) call add(l:lines, s:Check('shellcheck (sh)', 'shellcheck'))
call add(l:lines, s:Check('yamllint (yaml)', 'yamllint')) call add(l:lines, s:Check('yamllint (yaml)', 'yamllint'))
call add(l:lines, s:Check('hadolint (docker)', 'hadolint')) 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')) call add(l:lines, s:Check('markdownlint (md)', 'markdownlint'))
else
call add(l:lines, ' off markdownlint (md) (disabled by default)')
endif
call add(l:lines, '') call add(l:lines, '')
call add(l:lines, '── formatters ── (format-on-save is ON)') 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('black (python)', 'black'))
call add(l:lines, s:Check('isort (python)', 'isort')) call add(l:lines, s:Check('isort (python)', 'isort'))
call add(l:lines, s:Check('prettier (js/ts/json/md)', 'prettier')) 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)')
endif
call add(l:lines, s:Check('goimports (go)', 'goimports')) call add(l:lines, s:Check('goimports (go)', 'goimports'))
call add(l:lines, s:Check('rustfmt (rust)', 'rustfmt')) call add(l:lines, s:Check('rustfmt (rust)', 'rustfmt'))
call add(l:lines, s:Check('clang-format (c)', 'clang-format')) call add(l:lines, s:Check('clang-format (c)', 'clang-format'))
@ -256,7 +265,7 @@ function! s:CheatSheet() abort
\ '', \ '',
\ ' ── edit ──────────────────', \ ' ── edit ──────────────────',
\ ' gc comment', \ ' gc comment',
\ ' s+2ch easymotion jump', \ ' ,S+2ch easymotion jump',
\ ' cs"'' surround', \ ' cs"'' surround',
\ ' ,u undo tree', \ ' ,u undo tree',
\ ' ,y ,p clipboard y/p (v)', \ ' ,y ,p clipboard y/p (v)',