diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4efdeff..2702bf0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,16 +36,33 @@ jobs: cp modules/*.vim ~/.vim/modules/ - 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 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" - name: Verify modules load 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:]') echo "Plugins registered: $PLUGS" if [ "$PLUGS" -lt 20 ]; then @@ -53,10 +70,35 @@ jobs: exit 1 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 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 + STARTUP_MS=$(tail -1 /tmp/startup.log | awk '{print $1}') + awk -v ms="$STARTUP_MS" 'BEGIN { if (ms > 150) exit 1 }' shellcheck: runs-on: ubuntu-latest @@ -64,3 +106,12 @@ jobs: - uses: actions/checkout@v4 - name: Shellcheck install.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 diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..1ff5dd7 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,13 @@ +{ + "default": true, + "MD013": false, + "MD022": false, + "MD024": { + "siblings_only": true + }, + "MD032": false, + "MD033": false, + "MD040": false, + "MD041": false, + "MD060": false +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 900a277..15580c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,15 +3,29 @@ ## Unreleased ### 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 - `,af` toggle format-on-save (ALE `fix_on_save`) - `,gL` git log graph (last 20 commits) - `,gC` FZF git commits search, `,gB` buffer commits ### Fixed + - `g:loaded_logipat` typo → `g:loaded_logiPat` — logiPat was loading fully (0.478ms wasted) ### 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) - Remove deprecated `set ttyfast` (no-op since Vim 8) - Add `grepprg=rg --vimgrep` — `:grep` now uses ripgrep + quickfix @@ -23,17 +37,20 @@ ## 2.1.0 — 2025-04-22 ### Added + - Cheat sheet (`,?`) — vertical sidebar, one key per line, section headers - Previm markdown preview restored (lazy-loaded, `,mp`) - `:LspInstallServer` added to cheat sheet ### Changed + - Plugin count: 25 (restored previm, dropped 5 bloat plugins) - QUICKSTART updated — removed stale references, improved first-launch guidance ## 2.0.0 — 2025-04-21 ### Added + - Sidebar toggle (`,e` / `,E`) — left-side netrw with `topleft vertical`, winfixwidth, proper toggle - Enriched statusline — SLMode, SLGit, SLAle, SLFlags - Toggle feedback — F2/F3/F4/F6/`,ss` echo current state @@ -41,6 +58,7 @@ - Interactive tutorial (`:ChopsticksLearn` — removed in later release) ### Removed (Unix minimalism refactor) + - **565 lines** of dead code and bloat - 5 plugins: Goyo, Limelight, vim-obsession, indentLine, vim-unimpaired - `modules/writing.vim` — folded into `languages.vim` @@ -50,6 +68,7 @@ - TTY welcome message, `,so`, `,ms`, `,sh` mappings ### Changed + - CI plugin threshold lowered to 20 - README: hero layout with demo GIF, badges, architecture diagram - vim-markdown settings absorbed from writing.vim into languages.vim @@ -57,6 +76,7 @@ ## 1.3.0 — 2025-04-20 ### Changed + - Startup: 39ms → 19ms (51% faster) - Dropped vim-unimpaired for performance - Runtime tuning across modules @@ -64,16 +84,19 @@ ## 1.2.0 — 2025-04-19 ### Added + - Hero README with demo GIF, CI badges - GitHub Actions CI (startup test on macOS + Ubuntu, shellcheck) - Issue/PR templates ### Changed + - Documentation rewrite — clean, short, for engineers ## 1.1.0 — 2025-04-18 ### Added + - 12-module architecture (env → plugins → core → ui → editing → navigation → lsp → lint → git → writing → languages → tools) - Zen mode (Goyo + Limelight) - Run file (`,cr`) with auto filetype detection @@ -82,12 +105,14 @@ - Robust installer (`get.sh`) with preflight checks ### Changed + - `.vimrc` split into 12 self-contained modules - Comprehensive bug audit (14 fixes) ## 1.0.0 — 2025-04-16 ### Added + - Initial Vim configuration — migrated from Neovim - vim-plug plugin manager - vim-lsp + asyncomplete (pure VimScript LSP) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eb4b4b9..b52edc6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,7 +3,7 @@ ## 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. -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`. 4. **One module, one concern.** Don't put git config in lsp.vim. @@ -18,6 +18,7 @@ ## Reporting bugs Open an issue. Include: + - OS and Vim version - Whether you're on SSH/TTY - Steps to reproduce @@ -25,6 +26,6 @@ Open an issue. Include: ## Code style - Named augroups with `autocmd!` -- No comments explaining *what* — only *why* +- No comments explaining _what_ — only _why_ - `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!` diff --git a/QUICKSTART.md b/QUICKSTART.md index 751e6e4..cc054d6 100644 --- a/QUICKSTART.md +++ b/QUICKSTART.md @@ -10,13 +10,17 @@ 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 +heavier Markdown/LSP feedback. + ## Modes -| Mode | Enter | Leave | -|------|-------|-------| -| Normal | startup default | — | +| Mode | Enter | Leave | +| ------ | --------------- | ------------- | +| Normal | startup default | — | | Insert | `i` / `a` / `o` | `Esc` or `jk` | -| Visual | `v` / `V` | `Esc` | +| Visual | `v` / `V` | `Esc` | ## Survival @@ -67,7 +71,7 @@ Tab / S-Tab cycle completions ## Edit ``` -s + 2 chars EasyMotion jump +,S + 2 chars EasyMotion jump gc toggle comment cs"' change surrounding " to ' Alt+j / Alt+k move line @@ -91,6 +95,9 @@ Ctrl+h/j/k/l splits + tmux panes ,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 ``` diff --git a/README.md b/README.md index e87d12d..927cca4 100644 --- a/README.md +++ b/README.md @@ -34,16 +34,16 @@ chopsticks gives you a production-ready Vim config in one command. Pure VimScrip ## What's in the box -| Feature | Description | -|---------|-------------| -| **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 | -| **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) | -| **Run file** | `,cr` — auto-detects Python, Go, Rust, JS, C, Shell, and more | -| **Markdown** | live preview in browser (`,mp`), table of contents (`,mt`) | -| **Diagnostics** | `:ChopsticksStatus` — see what's installed, what's missing, how to fix it | -| **TTY-aware** | degrades gracefully on SSH, console, slow links — never breaks | +| Feature | Description | +| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **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 | +| **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) | +| **Run file** | `,cr` — auto-detects Python, Go, Rust, JS, C, Shell, and more | +| **Markdown** | quiet writing defaults, browser preview (`,mp`), table of contents (`,mt`) | +| **Diagnostics** | `:ChopsticksStatus` — see what's installed, what's missing, how to fix it | +| **TTY-aware** | degrades gracefully on SSH, console, slow links — never breaks | ## Install @@ -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. +## 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 Leader: `,` @@ -88,7 +103,7 @@ jk 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 | `[` `]` 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 | `[` `]` blank lines ### Git @@ -120,10 +135,36 @@ jk exit insert mode ,? cheat sheet :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. +## 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 ``` @@ -147,23 +188,23 @@ Each module is self-contained. Comment out one line in `.vimrc` to disable it. A ## Performance -| Metric | Value | -|--------|-------| -| Lazy-loaded | 7 plugins (on command or filetype) | +| Metric | Value | +| ------------------------ | ------------------------------------------- | +| Lazy-loaded | 7 plugins (on command or filetype) | | Built-in plugins skipped | 12 (gzip, tar, zip, vimball, logiPat, etc.) | -| Large file threshold | 10MB (auto-disables syntax + undo) | -| TTY large file | 500KB (syntax disabled) | +| Large file threshold | 10MB (auto-disables syntax + undo) | +| TTY large file | 500KB (syntax disabled) | ## Troubleshooting -| Problem | Fix | -|---------|-----| -| Plugins not loading | `:PlugInstall` then `:PlugUpdate` | -| LSP not starting | `:LspInstallServer` for current filetype | -| Colors wrong | `export COLORTERM=truecolor` in shell rc | -| `Ctrl+s` freezes | `stty -ixon` in shell rc | -| Everything slow | Large file? Auto-disabled >10MB | -| What's installed? | `:ChopsticksStatus` shows tools, LSP, linters | +| Problem | Fix | +| ------------------- | --------------------------------------------- | +| Plugins not loading | `:PlugInstall` then `:PlugUpdate` | +| LSP not starting | `:LspInstallServer` for current filetype | +| Colors wrong | `export COLORTERM=truecolor` in shell rc | +| `Ctrl+s` freezes | `stty -ixon` in shell rc | +| Everything slow | Large file? Auto-disabled >10MB | +| What's installed? | `:ChopsticksStatus` shows tools, LSP, linters | More in the [wiki](https://github.com/m1ngsama/chopsticks/wiki). diff --git a/install.sh b/install.sh index b2b2a4e..1af57df 100755 --- a/install.sh +++ b/install.sh @@ -467,19 +467,19 @@ if [[ $HAS_PKG_MGR -eq 1 ]]; then : $(( _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++ )) _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++ )) _I_HADOLINT=$_idx - _ITEMS+=("hadolint|Dockerfile linting (ALE integration, on-save)|1") + _ITEMS+=("hadolint|Optional Dockerfile linting via ALE|0") : $(( _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++ )) else warn "No package manager available — system tools skipped" @@ -488,21 +488,21 @@ fi # ── npm tools ──────────────────────────────────────────────────────────────── if [[ $HAS_NODE -eq 1 ]]; then _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++ )) fi # ── Python tools ───────────────────────────────────────────────────────────── if [[ $HAS_PIP -eq 1 ]]; then _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++ )) fi # ── Go tools ───────────────────────────────────────────────────────────────── if [[ $HAS_GO -eq 1 ]]; then _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++ )) fi @@ -510,7 +510,7 @@ fi if command -v tmux >/dev/null 2>&1; then if ! grep -q 'vim-tmux-navigator' "$HOME/.tmux.conf" 2>/dev/null; then _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++ )) else ok "tmux integration (vim-tmux-navigator already configured)" diff --git a/modules/core.vim b/modules/core.vim index 6af7dca..c06a196 100644 --- a/modules/core.vim +++ b/modules/core.vim @@ -57,8 +57,14 @@ endif set display+=lastline set ffs=unix,dos,mac -set nowb -set noswapfile +set writebackup + +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') set undofile @@ -89,7 +95,7 @@ let mapleader = "," " ── Basic Keymaps ─────────────────────────────────────────────────────────── -nnoremap w :w! +nnoremap w :w nnoremap q :q nnoremap x :x diff --git a/modules/editing.vim b/modules/editing.vim index 8f91559..9a9dd0c 100644 --- a/modules/editing.vim +++ b/modules/editing.vim @@ -6,7 +6,7 @@ let g:EasyMotion_do_mapping = 0 let g:EasyMotion_smartcase = 1 if exists('g:plugs["vim-easymotion"]') - nmap s (easymotion-overwin-f2) + nmap S (easymotion-overwin-f2) nmap j (easymotion-j) nmap k (easymotion-k) endif diff --git a/modules/env.vim b/modules/env.vim index 396ce4c..99f83fe 100644 --- a/modules/env.vim +++ b/modules/env.vim @@ -6,6 +6,36 @@ let g:is_tty = empty($TERM) || $TERM ==# 'dumb' || $TERM =~# 'linux' \ || $TERM =~# 'screen' || &term =~# 'builtin' 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 let g:loaded_2html_plugin = 1 let g:loaded_getscriptPlugin = 1 diff --git a/modules/languages.vim b/modules/languages.vim index 055c55d..2c4688d 100644 --- a/modules/languages.vim +++ b/modules/languages.vim @@ -2,9 +2,10 @@ " ── 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_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_frontmatter = 1 let g:vim_markdown_toml_frontmatter = 1 @@ -22,7 +23,7 @@ if has('macunix') elseif executable('xdg-open') let g:previm_open_cmd = 'xdg-open' endif -let g:previm_enable_realtime = 1 +let g:previm_enable_realtime = get(g:, 'previm_enable_realtime', 0) if exists('g:plugs["previm"]') nnoremap mp :PrevimOpen endif @@ -40,6 +41,22 @@ let g:go_highlight_function_calls = 1 " ── 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 autocmd! @@ -60,8 +77,7 @@ augroup ChopstickFiletype \ setlocal expandtab shiftwidth=2 tabstop=2 autocmd FileType yaml \ setlocal expandtab shiftwidth=2 tabstop=2 - autocmd FileType markdown - \ setlocal wrap linebreak spell textwidth=0 conceallevel=2 + autocmd FileType markdown call s:MarkdownDefaults() autocmd FileType sh \ setlocal expandtab shiftwidth=2 tabstop=2 textwidth=80 autocmd FileType make diff --git a/modules/lint.vim b/modules/lint.vim index be6efa8..13fd572 100644 --- a/modules/lint.vim +++ b/modules/lint.vim @@ -1,8 +1,12 @@ " 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_linters = { +let s:ale_linters = { \ 'python': ['flake8', 'pylint'], \ 'javascript': ['eslint'], \ 'typescript': ['eslint'], @@ -14,11 +18,16 @@ let g:ale_linters = { \ 'dockerfile': ['hadolint'], \ 'css': ['stylelint'], \ 'scss': ['stylelint'], -\ 'markdown': ['markdownlint'], \ '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'], \ 'python': ['black', 'isort'], \ 'javascript': ['prettier', 'eslint'], @@ -32,10 +41,15 @@ let g:ale_fixers = { \ 'css': ['prettier'], \ 'scss': ['prettier'], \ 'less': ['prettier'], -\ 'markdown': ['prettier'], \ '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_python_isort_options = '--profile black' 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_delay = 200 let g:ale_echo_delay = 100 +let g:ale_virtualtext_cursor = get(g:, 'ale_virtualtext_cursor', 'disabled') if exists('g:plugs["ale"]') nnoremap [e :ALEPrevious diff --git a/modules/lsp.vim b/modules/lsp.vim index 8fd8c3a..52d415e 100644 --- a/modules/lsp.vim +++ b/modules/lsp.vim @@ -1,5 +1,9 @@ " 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_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_json = ['vscode-json-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_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_highlights_enabled = !g:is_tty let g:lsp_document_highlight_enabled = !g:is_tty @@ -52,7 +59,7 @@ inoremap pumvisible() ? asyncomplete#close_popup() : "\" function! s:on_lsp_buffer_enabled() abort setlocal omnifunc=lsp#complete - if !g:is_tty + if !g:is_tty && &filetype !=# 'markdown' setlocal signcolumn=yes endif diff --git a/modules/plugins.vim b/modules/plugins.vim index 93d18f1..ad5e82b 100644 --- a/modules/plugins.vim +++ b/modules/plugins.vim @@ -29,25 +29,33 @@ Plug 'wellle/targets.vim' Plug 'jiangmiao/auto-pairs' Plug 'easymotion/vim-easymotion', { 'on': '(easymotion' } -" ── Linting & Formatting ──────────────────────────────────────────────────── -Plug 'dense-analysis/ale' +if g:chopsticks_enable_lint + " ── Linting & Formatting ──────────────────────────────────────────────── + Plug 'dense-analysis/ale' +endif -" ── LSP + Completion ───────────────────────────────────────────────────────── -Plug 'prabirshrestha/vim-lsp' -Plug 'mattn/vim-lsp-settings' -Plug 'prabirshrestha/asyncomplete.vim' -Plug 'prabirshrestha/asyncomplete-lsp.vim' +if g:chopsticks_enable_lsp + " ── LSP + Completion ───────────────────────────────────────────────────── + Plug 'prabirshrestha/vim-lsp' + Plug 'mattn/vim-lsp-settings' + Plug 'prabirshrestha/asyncomplete.vim' + Plug 'prabirshrestha/asyncomplete-lsp.vim' +endif " ── 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 'previm/previm', { 'on': 'PrevimOpen' } -Plug 'fatih/vim-go', { 'for': 'go' } +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 " ── UI ─────────────────────────────────────────────────────────────────────── -Plug 'mbbill/undotree', { 'on': 'UndotreeToggle' } -Plug 'mhinz/vim-startify' +if g:chopsticks_enable_ui_extras + Plug 'mbbill/undotree', { 'on': 'UndotreeToggle' } + Plug 'mhinz/vim-startify' +endif Plug 'lifepillar/vim-solarized8' if !empty($TMUX) Plug 'christoomey/vim-tmux-navigator' diff --git a/modules/tools.vim b/modules/tools.vim index 35eef54..862604e 100644 --- a/modules/tools.vim +++ b/modules/tools.vim @@ -172,13 +172,22 @@ function! s:ChopsticksStatus() abort 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')) - call add(l:lines, s:Check('markdownlint (md)', 'markdownlint')) + 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)') + endif 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('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('rustfmt (rust)', 'rustfmt')) call add(l:lines, s:Check('clang-format (c)', 'clang-format')) @@ -256,7 +265,7 @@ function! s:CheatSheet() abort \ '', \ ' ── edit ──────────────────', \ ' gc comment', - \ ' s+2ch easymotion jump', + \ ' ,S+2ch easymotion jump', \ ' cs"'' surround', \ ' ,u undo tree', \ ' ,y ,p clipboard y/p (v)',