mirror of
https://oauth2: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@github.com/m1ngsama/chopsticks.git
synced 2026-06-26 13:14:37 +08:00
Compare commits
3 commits
323bf4a6b3
...
6b8d691c61
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b8d691c61 | |||
| b329c5f301 | |||
| 43baa9753a |
3 changed files with 140 additions and 68 deletions
110
.vimrc
110
.vimrc
|
|
@ -106,9 +106,6 @@ set hid
|
||||||
" Configure backspace so it acts as it should act (enhanced from earlier basic setting)
|
" Configure backspace so it acts as it should act (enhanced from earlier basic setting)
|
||||||
set whichwrap+=<,>,h,l
|
set whichwrap+=<,>,h,l
|
||||||
|
|
||||||
" Don't redraw while executing macros (good performance config)
|
|
||||||
set lazyredraw
|
|
||||||
|
|
||||||
" For regular expressions turn magic on
|
" For regular expressions turn magic on
|
||||||
set magic
|
set magic
|
||||||
|
|
||||||
|
|
@ -324,8 +321,8 @@ map <C-k> <C-W>k
|
||||||
map <C-h> <C-W>h
|
map <C-h> <C-W>h
|
||||||
map <C-l> <C-W>l
|
map <C-l> <C-W>l
|
||||||
|
|
||||||
" Close the current buffer
|
" Close the current buffer (Bclose preserves window layout)
|
||||||
map <leader>bd :Bclose<cr>:tabclose<cr>gT
|
map <leader>bd :Bclose<cr>
|
||||||
|
|
||||||
" Close all the buffers
|
" Close all the buffers
|
||||||
map <leader>ba :bufdo bd<cr>
|
map <leader>ba :bufdo bd<cr>
|
||||||
|
|
@ -439,15 +436,40 @@ let NERDTreeIgnore=['\.pyc$', '\~$', '\.swp$', '\.git$', '\.DS_Store', 'node_mod
|
||||||
" NERDTree window size
|
" NERDTree window size
|
||||||
let NERDTreeWinSize=35
|
let NERDTreeWinSize=35
|
||||||
|
|
||||||
" Automatically open NERDTree when vim starts on a directory
|
" Track stdin reads so startup autocmds can skip pipe/heredoc input
|
||||||
" Disabled in TTY for faster startup
|
|
||||||
if !g:is_tty
|
|
||||||
autocmd StdinReadPre * let s:std_in=1
|
autocmd StdinReadPre * let s:std_in=1
|
||||||
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
|
|
||||||
|
" Startup layout (non-TTY only — keeps TTY startup instant)
|
||||||
|
if !g:is_tty
|
||||||
|
augroup ChopstickStartup
|
||||||
|
autocmd!
|
||||||
|
" vim <dir> → NERDTree on left + Startify (or blank buffer) on right
|
||||||
|
autocmd VimEnter *
|
||||||
|
\ if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') |
|
||||||
|
\ exe 'NERDTree ' . fnameescape(argv()[0]) |
|
||||||
|
\ exe 'cd ' . fnameescape(argv()[0]) |
|
||||||
|
\ wincmd p |
|
||||||
|
\ if exists(':Startify') == 2 | Startify | else | enew | endif |
|
||||||
|
\ endif
|
||||||
|
" vim (no args) → Startify renders first; open NERDTree alongside it
|
||||||
|
autocmd User Startified
|
||||||
|
\ if argc() == 0 && !exists('s:std_in') |
|
||||||
|
\ NERDTree |
|
||||||
|
\ wincmd p |
|
||||||
|
\ endif
|
||||||
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" --- FZF ---
|
" --- FZF ---
|
||||||
map <C-p> :Files<CR>
|
" Smart file search: use GFiles (respects .gitignore) inside git repos, Files elsewhere
|
||||||
|
function! s:SmartFiles() abort
|
||||||
|
if !empty(system('git rev-parse --show-toplevel 2>/dev/null'))
|
||||||
|
GFiles
|
||||||
|
else
|
||||||
|
Files
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
map <C-p> :call <SID>SmartFiles()<CR>
|
||||||
map <leader>b :Buffers<CR>
|
map <leader>b :Buffers<CR>
|
||||||
map <leader>rg :Rg<CR>
|
map <leader>rg :Rg<CR>
|
||||||
map <leader>rt :Tags<CR>
|
map <leader>rt :Tags<CR>
|
||||||
|
|
@ -521,6 +543,10 @@ let g:ale_linters = {
|
||||||
\ 'sh': ['shellcheck'],
|
\ 'sh': ['shellcheck'],
|
||||||
\ 'yaml': ['yamllint'],
|
\ 'yaml': ['yamllint'],
|
||||||
\ 'dockerfile': ['hadolint'],
|
\ 'dockerfile': ['hadolint'],
|
||||||
|
\ 'css': ['stylelint'],
|
||||||
|
\ 'scss': ['stylelint'],
|
||||||
|
\ 'markdown': ['markdownlint'],
|
||||||
|
\ 'sql': ['sqlfluff'],
|
||||||
\}
|
\}
|
||||||
|
|
||||||
let g:ale_fixers = {
|
let g:ale_fixers = {
|
||||||
|
|
@ -534,7 +560,10 @@ let g:ale_fixers = {
|
||||||
\ 'yaml': ['prettier'],
|
\ 'yaml': ['prettier'],
|
||||||
\ 'html': ['prettier'],
|
\ 'html': ['prettier'],
|
||||||
\ 'css': ['prettier'],
|
\ 'css': ['prettier'],
|
||||||
|
\ 'scss': ['prettier'],
|
||||||
|
\ 'less': ['prettier'],
|
||||||
\ 'markdown': ['prettier'],
|
\ 'markdown': ['prettier'],
|
||||||
|
\ 'sql': ['sqlfmt'],
|
||||||
\}
|
\}
|
||||||
|
|
||||||
" Don't fix on save if LSP is handling formatting (avoids double-format)
|
" Don't fix on save if LSP is handling formatting (avoids double-format)
|
||||||
|
|
@ -676,6 +705,13 @@ if g:use_vimlsp
|
||||||
let g:lsp_settings_filetype_typescript = ['typescript-language-server']
|
let g:lsp_settings_filetype_typescript = ['typescript-language-server']
|
||||||
let g:lsp_settings_filetype_javascript = ['typescript-language-server']
|
let g:lsp_settings_filetype_javascript = ['typescript-language-server']
|
||||||
let g:lsp_settings_filetype_sh = ['bash-language-server']
|
let g:lsp_settings_filetype_sh = ['bash-language-server']
|
||||||
|
let g:lsp_settings_filetype_html = ['vscode-html-language-server']
|
||||||
|
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']
|
||||||
|
|
||||||
" Performance: disable virtual text diagnostics in TTY
|
" Performance: disable virtual text diagnostics in TTY
|
||||||
let g:lsp_diagnostics_virtual_text_enabled = !g:is_tty
|
let g:lsp_diagnostics_virtual_text_enabled = !g:is_tty
|
||||||
|
|
@ -783,7 +819,8 @@ fun! CleanExtraSpaces()
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
if has("autocmd")
|
if has("autocmd")
|
||||||
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
|
" Run for all files; ALE trim_whitespace is idempotent so no conflict
|
||||||
|
autocmd BufWritePre * call CleanExtraSpaces()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
|
|
@ -815,7 +852,7 @@ autocmd FileType html,css setlocal expandtab shiftwidth=2 tabstop=2
|
||||||
autocmd FileType yaml setlocal expandtab shiftwidth=2 tabstop=2
|
autocmd FileType yaml setlocal expandtab shiftwidth=2 tabstop=2
|
||||||
|
|
||||||
" Markdown specific settings
|
" Markdown specific settings
|
||||||
autocmd FileType markdown setlocal wrap linebreak spell
|
autocmd FileType markdown setlocal wrap linebreak spell tw=0
|
||||||
|
|
||||||
" Shell script settings
|
" Shell script settings
|
||||||
autocmd FileType sh setlocal expandtab shiftwidth=2 tabstop=2
|
autocmd FileType sh setlocal expandtab shiftwidth=2 tabstop=2
|
||||||
|
|
@ -983,7 +1020,8 @@ if has('terminal')
|
||||||
nnoremap <leader>th :terminal ++rows=10<CR>
|
nnoremap <leader>th :terminal ++rows=10<CR>
|
||||||
|
|
||||||
" Terminal mode mappings
|
" Terminal mode mappings
|
||||||
tnoremap <Esc> <C-\><C-n>
|
" Double-Esc to exit terminal mode (single Esc passes through to the running program)
|
||||||
|
tnoremap <Esc><Esc> <C-\><C-n>
|
||||||
tnoremap <C-h> <C-\><C-n><C-w>h
|
tnoremap <C-h> <C-\><C-n><C-w>h
|
||||||
tnoremap <C-j> <C-\><C-n><C-w>j
|
tnoremap <C-j> <C-\><C-n><C-w>j
|
||||||
tnoremap <C-k> <C-\><C-n><C-w>k
|
tnoremap <C-k> <C-\><C-n><C-w>k
|
||||||
|
|
@ -1024,6 +1062,9 @@ if g:is_tty
|
||||||
|
|
||||||
" Reduce syntax highlighting complexity in TTY (global is 200, lower here)
|
" Reduce syntax highlighting complexity in TTY (global is 200, lower here)
|
||||||
set synmaxcol=120
|
set synmaxcol=120
|
||||||
|
|
||||||
|
" lazyredraw is safe in TTY; avoid globally as it causes CoC float flicker
|
||||||
|
set lazyredraw
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Provide helpful message on first run in TTY
|
" Provide helpful message on first run in TTY
|
||||||
|
|
@ -1065,10 +1106,11 @@ if exists('g:plugs["vim-which-key"]')
|
||||||
let g:which_key_map['y'] = 'clipboard-yank'
|
let g:which_key_map['y'] = 'clipboard-yank'
|
||||||
let g:which_key_map['Y'] = 'clipboard-yank-line'
|
let g:which_key_map['Y'] = 'clipboard-yank-line'
|
||||||
|
|
||||||
" [a]LE lint group ([e/]e navigate; <leader>aD for detail)
|
" [a]LE lint group ([e/]e navigate; <leader>aD for detail; <leader>ad for diagnostics)
|
||||||
let g:which_key_map['a'] = {
|
let g:which_key_map['a'] = {
|
||||||
\ 'name': '+ale-lint',
|
\ 'name': '+ale-lint',
|
||||||
\ 'D': 'ale-detail',
|
\ 'D': 'ale-detail',
|
||||||
|
\ 'd': 'diagnostics',
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
" [c]ode / [c]opy group
|
" [c]ode / [c]opy group
|
||||||
|
|
@ -1158,32 +1200,52 @@ endif
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
|
|
||||||
if exists('g:plugs["vim-startify"]')
|
if exists('g:plugs["vim-startify"]')
|
||||||
" Simple ASCII header, no icons (KISS)
|
" Dynamic header: config name, vim version, current dir, git branch, key tips
|
||||||
let g:startify_custom_header = [
|
function! StartifyHeader() abort
|
||||||
\ ' VIM - Vi IMproved',
|
let l:ver = 'Vim ' . (v:version / 100) . '.' . printf('%02d', v:version % 100)
|
||||||
\ ' Type :help if you are in trouble',
|
let l:cwd = fnamemodify(getcwd(), ':t')
|
||||||
|
let l:git = ''
|
||||||
|
if executable('git')
|
||||||
|
let l:branch = system('git -C ' . shellescape(getcwd()) .
|
||||||
|
\ ' rev-parse --abbrev-ref HEAD 2>/dev/null')
|
||||||
|
if v:shell_error == 0
|
||||||
|
let l:git = ' [' . substitute(l:branch, '\n\+$', '', '') . ']'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
return [
|
||||||
|
\ ' chopsticks | ' . l:ver . ' | ' . l:cwd . l:git,
|
||||||
|
\ ' , = leader | , + pause = key hints | Ctrl-p = files | ,rg = search',
|
||||||
\ '',
|
\ '',
|
||||||
\ ]
|
\ ]
|
||||||
|
endfunction
|
||||||
|
let g:startify_custom_header = 'StartifyHeader()'
|
||||||
|
|
||||||
" Sections shown on start screen
|
" Sessions first: restores full project state; dir + recent files below
|
||||||
let g:startify_lists = [
|
let g:startify_lists = [
|
||||||
\ { 'type': 'files', 'header': [' Recent Files'] },
|
|
||||||
\ { 'type': 'dir', 'header': [' Directory: '. getcwd()] },
|
|
||||||
\ { 'type': 'sessions', 'header': [' Sessions'] },
|
\ { 'type': 'sessions', 'header': [' Sessions'] },
|
||||||
|
\ { 'type': 'dir', 'header': [' Directory: ' . getcwd()] },
|
||||||
|
\ { 'type': 'files', 'header': [' Recent Files'] },
|
||||||
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
|
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
|
" Quick-access bookmarks for common config files
|
||||||
|
let g:startify_bookmarks = [
|
||||||
|
\ {'v': '~/.vimrc'},
|
||||||
|
\ {'z': '~/.zshrc'},
|
||||||
|
\ {'b': '~/.bashrc'},
|
||||||
|
\ ]
|
||||||
|
|
||||||
" Session integration
|
" Session integration
|
||||||
let g:startify_session_persistence = 1 " Auto-save session on quit
|
let g:startify_session_persistence = 1 " Auto-save session on quit
|
||||||
let g:startify_session_autoload = 1 " Auto-load Session.vim if present
|
let g:startify_session_autoload = 1 " Auto-load Session.vim if present
|
||||||
let g:startify_change_to_vcs_root = 1 " cd to git root on open
|
let g:startify_change_to_vcs_root = 1 " cd to git root on open
|
||||||
let g:startify_fortune_use_unicode = 0 " No unicode in fortune (KISS)
|
let g:startify_fortune_use_unicode = 0 " ASCII only (KISS)
|
||||||
let g:startify_enable_special = 0 " No <empty> / <quit> entries
|
let g:startify_enable_special = 0 " Hide <empty> / <quit> clutter
|
||||||
|
|
||||||
" Limit recent files shown
|
" Limit recent files shown
|
||||||
let g:startify_files_number = 10
|
let g:startify_files_number = 10
|
||||||
|
|
||||||
" Don't open NERDTree when startify is active
|
" Required for NERDTree compatibility (prevents buftype conflicts)
|
||||||
autocmd User Startified setlocal buftype=
|
autocmd User Startified setlocal buftype=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
||||||
23
README.md
23
README.md
|
|
@ -90,18 +90,22 @@ Install language server extensions from inside Vim:
|
||||||
:CocInstall coc-rust-analyzer " Rust
|
:CocInstall coc-rust-analyzer " Rust
|
||||||
:CocInstall coc-json coc-yaml " JSON, YAML
|
:CocInstall coc-json coc-yaml " JSON, YAML
|
||||||
:CocInstall coc-html coc-css " HTML, CSS
|
:CocInstall coc-html coc-css " HTML, CSS
|
||||||
|
:CocInstall coc-marksman " Markdown
|
||||||
|
:CocInstall coc-sql " SQL
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`install.sh` installs all of the above automatically when prompted.
|
||||||
|
|
||||||
### vim-lsp setup (without Node.js)
|
### vim-lsp setup (without Node.js)
|
||||||
|
|
||||||
Install language server binaries for your languages, then run:
|
Install language server binaries for your languages, then run:
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
:LspInstallServer " auto-installs servers for the current filetype
|
:LspInstallServer " auto-installs the right server for the current filetype
|
||||||
```
|
```
|
||||||
|
|
||||||
Supported: `pylsp`, `gopls`, `rust-analyzer`, `typescript-language-server`,
|
Supported languages: Python, Go, Rust, TypeScript, JavaScript, Shell,
|
||||||
`bash-language-server`, and all others covered by `vim-lsp-settings`.
|
HTML, CSS/SCSS, JSON, YAML, Markdown, SQL — via `vim-lsp-settings`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
@ -299,7 +303,7 @@ on a basic built-in terminal. In TTY mode:
|
||||||
## Language Support
|
## Language Support
|
||||||
|
|
||||||
| Language | Indent | Formatter | Linter |
|
| Language | Indent | Formatter | Linter |
|
||||||
|----------------|--------|---------------|---------------------|
|
|----------------|--------|------------------|--------------------------|
|
||||||
| Python | 4sp | black + isort | flake8, pylint |
|
| Python | 4sp | black + isort | flake8, pylint |
|
||||||
| JavaScript | 2sp | prettier | eslint |
|
| JavaScript | 2sp | prettier | eslint |
|
||||||
| TypeScript | 2sp | prettier | eslint, tsserver |
|
| TypeScript | 2sp | prettier | eslint, tsserver |
|
||||||
|
|
@ -307,13 +311,16 @@ on a basic built-in terminal. In TTY mode:
|
||||||
| Rust | 4sp | rustfmt | cargo |
|
| Rust | 4sp | rustfmt | cargo |
|
||||||
| Shell | 2sp | - | shellcheck |
|
| Shell | 2sp | - | shellcheck |
|
||||||
| YAML | 2sp | prettier | yamllint |
|
| YAML | 2sp | prettier | yamllint |
|
||||||
| HTML/CSS | 2sp | prettier | - |
|
| HTML | 2sp | prettier | - |
|
||||||
| Markdown | 2sp | prettier | - |
|
| CSS / SCSS | 2sp | prettier | stylelint |
|
||||||
|
| Less | 2sp | prettier | - |
|
||||||
| JSON | 2sp | prettier | - |
|
| JSON | 2sp | prettier | - |
|
||||||
|
| Markdown | 2sp | prettier | markdownlint |
|
||||||
|
| SQL | 4sp | sqlfmt | sqlfluff |
|
||||||
| Dockerfile | 2sp | - | hadolint |
|
| Dockerfile | 2sp | - | hadolint |
|
||||||
|
|
||||||
Install linters separately (e.g. `pip install black flake8`, `npm i -g prettier`).
|
Install linters separately — `install.sh` lists the exact commands.
|
||||||
ALE runs them asynchronously and auto-fixes on save.
|
ALE runs them asynchronously on save (`ale_fix_on_save = 1` when using CoC).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
11
install.sh
11
install.sh
|
|
@ -94,9 +94,8 @@ if [ "$HAS_NODE" -eq 1 ]; then
|
||||||
echo
|
echo
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
step "Installing CoC language servers"
|
step "Installing CoC language servers"
|
||||||
vim +'CocInstall -sync coc-json coc-tsserver coc-pyright coc-sh coc-html coc-css coc-yaml' +qall
|
vim +'CocInstall -sync coc-json coc-tsserver coc-pyright coc-sh coc-html coc-css coc-yaml coc-go coc-rust-analyzer coc-marksman coc-sql' +qall
|
||||||
ok "CoC language servers installed"
|
ok "CoC language servers installed"
|
||||||
echo " Add more with :CocInstall coc-go coc-rust-analyzer etc."
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo " To enable LSP without Node.js:"
|
echo " To enable LSP without Node.js:"
|
||||||
|
|
@ -126,11 +125,15 @@ echo " ctags (F8 tag browser)"
|
||||||
echo " Ubuntu: sudo apt install universal-ctags"
|
echo " Ubuntu: sudo apt install universal-ctags"
|
||||||
echo " macOS: brew install universal-ctags"
|
echo " macOS: brew install universal-ctags"
|
||||||
echo ""
|
echo ""
|
||||||
echo " Language linters:"
|
echo " Language linters and formatters:"
|
||||||
echo " Python: pip install black flake8 pylint isort"
|
echo " Python: pip install black flake8 pylint isort"
|
||||||
echo " JS/TS: npm install -g prettier eslint typescript"
|
echo " JS/TS: npm install -g prettier eslint typescript"
|
||||||
echo " Go: go install golang.org/x/tools/gopls@latest"
|
echo " Go: go install golang.org/x/tools/gopls@latest"
|
||||||
echo " Shell: sudo apt install shellcheck"
|
echo " Shell: sudo apt install shellcheck # or: brew install shellcheck"
|
||||||
|
echo " CSS/SCSS: npm install -g stylelint stylelint-config-standard"
|
||||||
|
echo " Markdown: npm install -g markdownlint-cli"
|
||||||
|
echo " SQL: pip install sqlfluff | npm install -g sqlfmt"
|
||||||
|
echo " Markdown LS: brew install marksman # or: https://github.com/artempyanykh/marksman"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Getting started:"
|
echo "Getting started:"
|
||||||
echo " See QUICKSTART.md for the 5-minute guide"
|
echo " See QUICKSTART.md for the 5-minute guide"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue