mirror of
https://github.com/m1ngsama/chopsticks.git
synced 2026-02-08 06:54:05 +00:00
工程化优化:添加快速安装脚本和企业级开发功能
新增功能: ✨ 一键安装脚本 (install.sh) - 自动备份现有配置 - 自动安装 vim-plug - 自动安装所有插件 - 可选安装 CoC 语言服务器 - 美化的安装界面和详细提示 ✨ 快速开始指南 (QUICKSTART.md) - 5分钟上手教程 - 常用工作流程示例 - 语言特定配置说明 - 故障排除指南 - 快速参考卡片 配置增强: 📦 新增插件 - vim-obsession: 会话管理 - vim-prosession: 项目会话 - vim-unimpaired: 便捷的括号映射 - targets.vim: 额外的文本对象 - vim-snippets: 代码片段集合 🛠️ 工程化特性 - 项目特定配置支持 (.vimrc in project root) - 大文件自动优化 (>10MB) - 终端集成 (,tv, ,th) - 会话自动保存 - 父目录自动创建 ⌨️ 新增快捷键 Git 工作流: ,gs - Git status ,gc - Git commit ,gp - Git push ,gl - Git pull ,gd - Git diff ,gb - Git blame 工程实用工具: ,ev - 编辑 .vimrc ,sv - 重载 .vimrc ,F - 格式化整个文件 ,wa - 保存所有缓冲区 ,cp - 复制文件路径 ,cf - 复制文件名 ,* - 搜索并替换光标下的单词 ,, - 切换到上一个文件 窗口管理: ,= - 增大窗口高度 ,- - 减小窗口高度 ,+ - 增大窗口宽度 ,_ - 减小窗口宽度 🌐 语言支持增强 新增语言配置: - Rust (rustfmt, cargo) - Shell (shellcheck) - YAML (yamllint) - Docker (hadolint) - HTML/CSS (prettier) - Markdown (spell check, prettier) 改进的 ALE 配置: - 更多语言的 linters - 优化的性能设置 - 详细错误显示 (,ad) 🔍 增强的 FZF 集成 - 改进的预览窗口 - Git 文件搜索命令 - 更好的 Ripgrep 集成 - 自定义布局 📝 NERDTree 优化 - 自动打开项目目录 - 忽略 node_modules, __pycache__ 等 - 可配置窗口大小 文档改进: 📚 README.md 重大更新 - 添加快速开始章节 - 详细的工程特性说明 - 完整的键位映射表 - 项目配置示例 - 会话管理说明 - 大文件处理说明 - 终端集成文档 适用场景: ✅ 企业级开发团队 ✅ 多语言项目 ✅ 大型代码库 ✅ 持续集成环境 ✅ 远程开发 ✅ 代码审查 性能优化: ⚡ 大文件自动禁用重度功能 ⚡ ALE 按需 lint (不在输入时) ⚡ 优化的语法高亮 ⚡ 更快的启动时间
This commit is contained in:
parent
ff27025cbb
commit
2941614b45
4 changed files with 734 additions and 17 deletions
196
.vimrc
196
.vimrc
|
|
@ -242,6 +242,15 @@ if has('vim9') || has('nvim')
|
||||||
Plug 'neoclide/coc.nvim', {'branch': 'release'} " LSP & Completion
|
Plug 'neoclide/coc.nvim', {'branch': 'release'} " LSP & Completion
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" ===== Session Management =====
|
||||||
|
Plug 'tpope/vim-obsession' " Continuous session save
|
||||||
|
Plug 'dhruvasagar/vim-prosession' " Better session management
|
||||||
|
|
||||||
|
" ===== Additional Utilities =====
|
||||||
|
Plug 'tpope/vim-unimpaired' " Handy bracket mappings
|
||||||
|
Plug 'wellle/targets.vim' " Additional text objects
|
||||||
|
Plug 'honza/vim-snippets' " Snippet collection
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
|
|
@ -395,7 +404,14 @@ autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isT
|
||||||
let NERDTreeShowHidden=1
|
let NERDTreeShowHidden=1
|
||||||
|
|
||||||
" Ignore files in NERDTree
|
" Ignore files in NERDTree
|
||||||
let NERDTreeIgnore=['\.pyc$', '\~$', '\.swp$', '\.git$', '\.DS_Store']
|
let NERDTreeIgnore=['\.pyc$', '\~$', '\.swp$', '\.git$', '\.DS_Store', 'node_modules', '__pycache__', '\.egg-info$']
|
||||||
|
|
||||||
|
" NERDTree window size
|
||||||
|
let NERDTreeWinSize=35
|
||||||
|
|
||||||
|
" Automatically open NERDTree when vim starts on a directory
|
||||||
|
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
|
||||||
|
|
||||||
" --- FZF ---
|
" --- FZF ---
|
||||||
map <C-p> :Files<CR>
|
map <C-p> :Files<CR>
|
||||||
|
|
@ -403,6 +419,19 @@ map <leader>b :Buffers<CR>
|
||||||
map <leader>rg :Rg<CR>
|
map <leader>rg :Rg<CR>
|
||||||
map <leader>t :Tags<CR>
|
map <leader>t :Tags<CR>
|
||||||
|
|
||||||
|
" FZF customization for better project search
|
||||||
|
let g:fzf_layout = { 'down': '40%' }
|
||||||
|
let g:fzf_preview_window = ['right:50%', 'ctrl-/']
|
||||||
|
|
||||||
|
" Advanced FZF commands
|
||||||
|
command! -bang -nargs=* Rg
|
||||||
|
\ call fzf#vim#grep(
|
||||||
|
\ 'rg --column --line-number --no-heading --color=always --smart-case -- '.shellescape(<q-args>), 1,
|
||||||
|
\ fzf#vim#with_preview(), <bang>0)
|
||||||
|
|
||||||
|
" Search in git files
|
||||||
|
command! -bang GFiles call fzf#vim#gitfiles('', fzf#vim#with_preview(), <bang>0)
|
||||||
|
|
||||||
" --- CtrlP ---
|
" --- CtrlP ---
|
||||||
let g:ctrlp_working_path_mode = 'ra'
|
let g:ctrlp_working_path_mode = 'ra'
|
||||||
let g:ctrlp_show_hidden = 1
|
let g:ctrlp_show_hidden = 1
|
||||||
|
|
@ -430,23 +459,39 @@ let g:gitgutter_sign_modified_removed = '~'
|
||||||
let g:ale_linters = {
|
let g:ale_linters = {
|
||||||
\ 'python': ['flake8', 'pylint'],
|
\ 'python': ['flake8', 'pylint'],
|
||||||
\ 'javascript': ['eslint'],
|
\ 'javascript': ['eslint'],
|
||||||
|
\ 'typescript': ['eslint', 'tsserver'],
|
||||||
\ 'go': ['gopls', 'golint'],
|
\ 'go': ['gopls', 'golint'],
|
||||||
|
\ 'rust': ['cargo'],
|
||||||
|
\ 'sh': ['shellcheck'],
|
||||||
|
\ 'yaml': ['yamllint'],
|
||||||
|
\ 'dockerfile': ['hadolint'],
|
||||||
\}
|
\}
|
||||||
|
|
||||||
let g:ale_fixers = {
|
let g:ale_fixers = {
|
||||||
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
|
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
|
||||||
\ 'python': ['black', 'isort'],
|
\ 'python': ['black', 'isort'],
|
||||||
\ 'javascript': ['prettier', 'eslint'],
|
\ 'javascript': ['prettier', 'eslint'],
|
||||||
|
\ 'typescript': ['prettier', 'eslint'],
|
||||||
\ 'go': ['gofmt', 'goimports'],
|
\ 'go': ['gofmt', 'goimports'],
|
||||||
|
\ 'rust': ['rustfmt'],
|
||||||
|
\ 'json': ['prettier'],
|
||||||
|
\ 'yaml': ['prettier'],
|
||||||
|
\ 'html': ['prettier'],
|
||||||
|
\ 'css': ['prettier'],
|
||||||
|
\ 'markdown': ['prettier'],
|
||||||
\}
|
\}
|
||||||
|
|
||||||
let g:ale_fix_on_save = 1
|
let g:ale_fix_on_save = 1
|
||||||
let g:ale_sign_error = '✗'
|
let g:ale_sign_error = '✗'
|
||||||
let g:ale_sign_warning = '⚠'
|
let g:ale_sign_warning = '⚠'
|
||||||
|
let g:ale_lint_on_text_changed = 'never'
|
||||||
|
let g:ale_lint_on_insert_leave = 0
|
||||||
|
let g:ale_lint_on_enter = 0
|
||||||
|
|
||||||
" Navigate between errors
|
" Navigate between errors
|
||||||
nmap <silent> <leader>aj :ALENext<cr>
|
nmap <silent> <leader>aj :ALENext<cr>
|
||||||
nmap <silent> <leader>ak :ALEPrevious<cr>
|
nmap <silent> <leader>ak :ALEPrevious<cr>
|
||||||
|
nmap <silent> <leader>ad :ALEDetail<cr>
|
||||||
|
|
||||||
" --- Tagbar ---
|
" --- Tagbar ---
|
||||||
nmap <F8> :TagbarToggle<CR>
|
nmap <F8> :TagbarToggle<CR>
|
||||||
|
|
@ -588,6 +633,28 @@ autocmd FileType javascript,typescript setlocal expandtab shiftwidth=2 tabstop=2
|
||||||
" Go specific settings
|
" Go specific settings
|
||||||
autocmd FileType go setlocal noexpandtab shiftwidth=4 tabstop=4
|
autocmd FileType go setlocal noexpandtab shiftwidth=4 tabstop=4
|
||||||
|
|
||||||
|
" HTML/CSS specific settings
|
||||||
|
autocmd FileType html,css setlocal expandtab shiftwidth=2 tabstop=2
|
||||||
|
|
||||||
|
" YAML specific settings
|
||||||
|
autocmd FileType yaml setlocal expandtab shiftwidth=2 tabstop=2
|
||||||
|
|
||||||
|
" Markdown specific settings
|
||||||
|
autocmd FileType markdown setlocal wrap linebreak spell
|
||||||
|
|
||||||
|
" Shell script settings
|
||||||
|
autocmd FileType sh setlocal expandtab shiftwidth=2 tabstop=2
|
||||||
|
|
||||||
|
" Makefile settings (must use tabs)
|
||||||
|
autocmd FileType make setlocal noexpandtab shiftwidth=8 tabstop=8
|
||||||
|
|
||||||
|
" JSON specific settings
|
||||||
|
autocmd FileType json setlocal expandtab shiftwidth=2 tabstop=2
|
||||||
|
|
||||||
|
" Docker specific settings
|
||||||
|
autocmd BufNewFile,BufRead Dockerfile* setlocal filetype=dockerfile
|
||||||
|
autocmd FileType dockerfile setlocal expandtab shiftwidth=2 tabstop=2
|
||||||
|
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
" => Status Line
|
" => Status Line
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
|
|
@ -642,6 +709,133 @@ else
|
||||||
set signcolumn=yes
|
set signcolumn=yes
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" ============================================================================
|
||||||
|
" => Project-Specific Settings
|
||||||
|
" ============================================================================
|
||||||
|
|
||||||
|
" Load project-specific vimrc if it exists
|
||||||
|
" This allows per-project customization
|
||||||
|
set exrc
|
||||||
|
set secure
|
||||||
|
|
||||||
|
" ============================================================================
|
||||||
|
" => Additional Engineering Utilities
|
||||||
|
" ============================================================================
|
||||||
|
|
||||||
|
" Quick format entire file
|
||||||
|
nnoremap <leader>F gg=G``
|
||||||
|
|
||||||
|
" Toggle between source and header files (for C/C++)
|
||||||
|
nnoremap <leader>a :A<CR>
|
||||||
|
|
||||||
|
" Quick save all buffers
|
||||||
|
nnoremap <leader>wa :wa<CR>
|
||||||
|
|
||||||
|
" Easier window resizing
|
||||||
|
nnoremap <silent> <Leader>= :exe "resize " . (winheight(0) * 3/2)<CR>
|
||||||
|
nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>
|
||||||
|
nnoremap <silent> <Leader>+ :exe "vertical resize " . (winwidth(0) * 3/2)<CR>
|
||||||
|
nnoremap <silent> <Leader>_ :exe "vertical resize " . (winwidth(0) * 2/3)<CR>
|
||||||
|
|
||||||
|
" Quick switch between last two files
|
||||||
|
nnoremap <leader><leader> <c-^>
|
||||||
|
|
||||||
|
" Clear whitespace on empty lines
|
||||||
|
nnoremap <leader>W :%s/\s\+$//<CR>:let @/=''<CR>
|
||||||
|
|
||||||
|
" Source current file
|
||||||
|
nnoremap <leader>so :source %<CR>
|
||||||
|
|
||||||
|
" Edit vimrc quickly
|
||||||
|
nnoremap <leader>ev :edit $MYVIMRC<CR>
|
||||||
|
|
||||||
|
" Reload vimrc
|
||||||
|
nnoremap <leader>sv :source $MYVIMRC<CR>
|
||||||
|
|
||||||
|
" Search and replace word under cursor
|
||||||
|
nnoremap <leader>* :%s/\<<C-r><C-w>\>//g<Left><Left>
|
||||||
|
|
||||||
|
" Copy file path to clipboard
|
||||||
|
nnoremap <leader>cp :let @+ = expand("%:p")<CR>:echo "Copied path: " . expand("%:p")<CR>
|
||||||
|
nnoremap <leader>cf :let @+ = expand("%:t")<CR>:echo "Copied filename: " . expand("%:t")<CR>
|
||||||
|
|
||||||
|
" Create parent directories on save if they don't exist
|
||||||
|
function! s:MkNonExDir(file, buf)
|
||||||
|
if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
|
||||||
|
let dir=fnamemodify(a:file, ':h')
|
||||||
|
if !isdirectory(dir)
|
||||||
|
call mkdir(dir, 'p')
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
augroup BWCCreateDir
|
||||||
|
autocmd!
|
||||||
|
autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
" ============================================================================
|
||||||
|
" => Debugging Helpers
|
||||||
|
" ============================================================================
|
||||||
|
|
||||||
|
" Show syntax highlighting groups for word under cursor
|
||||||
|
nmap <leader>sp :call <SID>SynStack()<CR>
|
||||||
|
function! <SID>SynStack()
|
||||||
|
if !exists("*synstack")
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" ============================================================================
|
||||||
|
" => Git Workflow Enhancements
|
||||||
|
" ============================================================================
|
||||||
|
|
||||||
|
" Git shortcuts
|
||||||
|
nnoremap <leader>gs :Git status<CR>
|
||||||
|
nnoremap <leader>gc :Git commit<CR>
|
||||||
|
nnoremap <leader>gp :Git push<CR>
|
||||||
|
nnoremap <leader>gl :Git pull<CR>
|
||||||
|
nnoremap <leader>gd :Gdiff<CR>
|
||||||
|
nnoremap <leader>gb :Git blame<CR>
|
||||||
|
|
||||||
|
" ============================================================================
|
||||||
|
" => Terminal Integration
|
||||||
|
" ============================================================================
|
||||||
|
|
||||||
|
" Better terminal navigation
|
||||||
|
if has('terminal')
|
||||||
|
" Open terminal in split
|
||||||
|
nnoremap <leader>tv :terminal<CR>
|
||||||
|
nnoremap <leader>th :terminal ++rows=10<CR>
|
||||||
|
|
||||||
|
" Terminal mode mappings
|
||||||
|
tnoremap <Esc> <C-\><C-n>
|
||||||
|
tnoremap <C-h> <C-\><C-n><C-w>h
|
||||||
|
tnoremap <C-j> <C-\><C-n><C-w>j
|
||||||
|
tnoremap <C-k> <C-\><C-n><C-w>k
|
||||||
|
tnoremap <C-l> <C-\><C-n><C-w>l
|
||||||
|
endif
|
||||||
|
|
||||||
|
" ============================================================================
|
||||||
|
" => Large File Handling
|
||||||
|
" ============================================================================
|
||||||
|
|
||||||
|
" Disable syntax highlighting and other features for large files (>10MB)
|
||||||
|
let g:LargeFile = 1024 * 1024 * 10
|
||||||
|
augroup LargeFile
|
||||||
|
autocmd!
|
||||||
|
autocmd BufReadPre * let f=getfsize(expand("<afile>")) | if f > g:LargeFile || f == -2 | call LargeFileSettings() | endif
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
function! LargeFileSettings()
|
||||||
|
setlocal bufhidden=unload
|
||||||
|
setlocal undolevels=-1
|
||||||
|
setlocal eventignore+=FileType
|
||||||
|
setlocal noswapfile
|
||||||
|
setlocal buftype=nowrite
|
||||||
|
echo "Large file detected. Some features disabled for performance."
|
||||||
|
endfunction
|
||||||
|
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
" End of Configuration
|
" End of Configuration
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
|
|
|
||||||
271
QUICKSTART.md
Normal file
271
QUICKSTART.md
Normal file
|
|
@ -0,0 +1,271 @@
|
||||||
|
# Quick Start Guide
|
||||||
|
|
||||||
|
Get up and running with this Vim configuration in 5 minutes!
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### One-Line Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/m1ngsama/chopsticks.git ~/.vim && cd ~/.vim && ./install.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
That's it! The script will:
|
||||||
|
- ✓ Backup your existing .vimrc
|
||||||
|
- ✓ Create symlink to the new configuration
|
||||||
|
- ✓ Install vim-plug
|
||||||
|
- ✓ Install all plugins automatically
|
||||||
|
|
||||||
|
### Manual Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Clone the repository
|
||||||
|
git clone https://github.com/m1ngsama/chopsticks.git ~/.vim
|
||||||
|
|
||||||
|
# 2. Create symlink
|
||||||
|
ln -sf ~/.vim/.vimrc ~/.vimrc
|
||||||
|
|
||||||
|
# 3. Install vim-plug
|
||||||
|
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
|
||||||
|
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||||
|
|
||||||
|
# 4. Open Vim and install plugins
|
||||||
|
vim +PlugInstall +qall
|
||||||
|
```
|
||||||
|
|
||||||
|
## Essential Key Mappings
|
||||||
|
|
||||||
|
### File Operations
|
||||||
|
| Key | Action |
|
||||||
|
|-----|--------|
|
||||||
|
| `,w` | Quick save |
|
||||||
|
| `,q` | Quick quit |
|
||||||
|
| `,x` | Save and quit |
|
||||||
|
|
||||||
|
### Navigation
|
||||||
|
| Key | Action |
|
||||||
|
|-----|--------|
|
||||||
|
| `Ctrl+n` | Toggle file explorer (NERDTree) |
|
||||||
|
| `Ctrl+p` | Fuzzy file search (FZF) |
|
||||||
|
| `Ctrl+h/j/k/l` | Navigate between windows |
|
||||||
|
| `,b` | Search open buffers |
|
||||||
|
|
||||||
|
### Code Intelligence
|
||||||
|
| Key | Action |
|
||||||
|
|-----|--------|
|
||||||
|
| `gd` | Go to definition |
|
||||||
|
| `gr` | Find references |
|
||||||
|
| `K` | Show documentation |
|
||||||
|
| `Tab` | Autocomplete (when popup is visible) |
|
||||||
|
|
||||||
|
### Editing
|
||||||
|
| Key | Action |
|
||||||
|
|-----|--------|
|
||||||
|
| `gc` | Comment/uncomment (in visual mode) |
|
||||||
|
| `Space` | Toggle fold |
|
||||||
|
| `,,+Enter` | Clear search highlight |
|
||||||
|
|
||||||
|
## Common Workflows
|
||||||
|
|
||||||
|
### Opening a Project
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Navigate to your project directory
|
||||||
|
cd ~/my-project
|
||||||
|
|
||||||
|
# Open Vim
|
||||||
|
vim
|
||||||
|
|
||||||
|
# Press Ctrl+n to open file explorer
|
||||||
|
# Press Ctrl+p to fuzzy search files
|
||||||
|
```
|
||||||
|
|
||||||
|
### Editing Code
|
||||||
|
|
||||||
|
1. Open a file with `Ctrl+p` or through NERDTree
|
||||||
|
2. Use `gd` to jump to definitions
|
||||||
|
3. Use `K` to view documentation
|
||||||
|
4. Use `Tab` for autocomplete while typing
|
||||||
|
5. Save with `,w`
|
||||||
|
|
||||||
|
### Working with Git
|
||||||
|
|
||||||
|
| Command | Action |
|
||||||
|
|---------|--------|
|
||||||
|
| `:Git status` | View git status |
|
||||||
|
| `:Git diff` | View changes |
|
||||||
|
| `:Git commit` | Commit changes |
|
||||||
|
| `:Git push` | Push to remote |
|
||||||
|
| `,gb` | Open git blame window |
|
||||||
|
|
||||||
|
### Search and Replace
|
||||||
|
|
||||||
|
```vim
|
||||||
|
" Search in current file
|
||||||
|
/searchterm
|
||||||
|
|
||||||
|
" Search across project (with FZF)
|
||||||
|
,rg
|
||||||
|
|
||||||
|
" Replace in file
|
||||||
|
:%s/old/new/g
|
||||||
|
|
||||||
|
" Replace with confirmation
|
||||||
|
:%s/old/new/gc
|
||||||
|
```
|
||||||
|
|
||||||
|
## Language-Specific Features
|
||||||
|
|
||||||
|
### Python
|
||||||
|
|
||||||
|
- Auto-formatting with Black (on save)
|
||||||
|
- Linting with flake8/pylint
|
||||||
|
- 4-space indentation
|
||||||
|
- 88-character line limit
|
||||||
|
|
||||||
|
**Setup:**
|
||||||
|
```bash
|
||||||
|
pip install black flake8 pylint
|
||||||
|
vim -c "CocInstall coc-pyright" -c "q"
|
||||||
|
```
|
||||||
|
|
||||||
|
### JavaScript/TypeScript
|
||||||
|
|
||||||
|
- Prettier formatting (on save)
|
||||||
|
- ESLint integration
|
||||||
|
- 2-space indentation
|
||||||
|
|
||||||
|
**Setup:**
|
||||||
|
```bash
|
||||||
|
npm install -g prettier eslint
|
||||||
|
vim -c "CocInstall coc-tsserver coc-prettier coc-eslint" -c "q"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Go
|
||||||
|
|
||||||
|
- Auto-formatting with gofmt
|
||||||
|
- Auto-imports with goimports
|
||||||
|
- Tab indentation
|
||||||
|
|
||||||
|
**Setup:**
|
||||||
|
```bash
|
||||||
|
go install golang.org/x/tools/gopls@latest
|
||||||
|
vim -c "CocInstall coc-go" -c "q"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Plugins not working?
|
||||||
|
|
||||||
|
```vim
|
||||||
|
:PlugInstall
|
||||||
|
:PlugUpdate
|
||||||
|
```
|
||||||
|
|
||||||
|
### Autocomplete not working?
|
||||||
|
|
||||||
|
Make sure Node.js is installed:
|
||||||
|
```bash
|
||||||
|
node --version # Should be >= 14.14
|
||||||
|
```
|
||||||
|
|
||||||
|
Then install CoC language servers:
|
||||||
|
```vim
|
||||||
|
:CocInstall coc-json coc-tsserver coc-pyright
|
||||||
|
```
|
||||||
|
|
||||||
|
### FZF not finding files?
|
||||||
|
|
||||||
|
Install FZF and ripgrep:
|
||||||
|
```bash
|
||||||
|
# Ubuntu/Debian
|
||||||
|
sudo apt install fzf ripgrep
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
brew install fzf ripgrep
|
||||||
|
```
|
||||||
|
|
||||||
|
### Colors look weird?
|
||||||
|
|
||||||
|
Add to your `~/.bashrc` or `~/.zshrc`:
|
||||||
|
```bash
|
||||||
|
export TERM=xterm-256color
|
||||||
|
```
|
||||||
|
|
||||||
|
## Customization
|
||||||
|
|
||||||
|
The `.vimrc` file is well-organized into sections:
|
||||||
|
|
||||||
|
1. **General Settings** (lines 1-150) - Basic Vim behavior
|
||||||
|
2. **Plugin Management** (lines 151-230) - Plugin list
|
||||||
|
3. **Key Mappings** (lines 300-400) - Custom shortcuts
|
||||||
|
4. **Plugin Settings** (lines 400-600) - Plugin configurations
|
||||||
|
|
||||||
|
To customize:
|
||||||
|
1. Open `~/.vim/.vimrc`
|
||||||
|
2. Find the section you want to modify
|
||||||
|
3. Make your changes
|
||||||
|
4. Reload with `:source ~/.vimrc` or restart Vim
|
||||||
|
|
||||||
|
### Common Customizations
|
||||||
|
|
||||||
|
**Change colorscheme:**
|
||||||
|
```vim
|
||||||
|
" In .vimrc, find the colorscheme line and change to:
|
||||||
|
colorscheme dracula
|
||||||
|
" or: solarized, onedark, gruvbox
|
||||||
|
```
|
||||||
|
|
||||||
|
**Change leader key:**
|
||||||
|
```vim
|
||||||
|
" Default is comma (,), change to space:
|
||||||
|
let mapleader = " "
|
||||||
|
```
|
||||||
|
|
||||||
|
**Disable relative line numbers:**
|
||||||
|
```vim
|
||||||
|
set norelativenumber
|
||||||
|
```
|
||||||
|
|
||||||
|
## Next Steps
|
||||||
|
|
||||||
|
1. Read the full [README.md](README.md) for complete documentation
|
||||||
|
2. Check out `:help` in Vim for built-in documentation
|
||||||
|
3. Customize the configuration to your needs
|
||||||
|
4. Share your improvements!
|
||||||
|
|
||||||
|
## Quick Reference Card
|
||||||
|
|
||||||
|
Print this for your desk:
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────────────────────────────────┐
|
||||||
|
│ Vim Quick Reference │
|
||||||
|
├─────────────────────────────────────────────┤
|
||||||
|
│ FILES │
|
||||||
|
│ Ctrl+n File explorer │
|
||||||
|
│ Ctrl+p Fuzzy find files │
|
||||||
|
│ ,w Save │
|
||||||
|
│ ,q Quit │
|
||||||
|
├─────────────────────────────────────────────┤
|
||||||
|
│ NAVIGATION │
|
||||||
|
│ gd Go to definition │
|
||||||
|
│ gr Find references │
|
||||||
|
│ K Show docs │
|
||||||
|
│ Ctrl+o Jump back │
|
||||||
|
│ Ctrl+i Jump forward │
|
||||||
|
├─────────────────────────────────────────────┤
|
||||||
|
│ EDITING │
|
||||||
|
│ gc Comment (visual mode) │
|
||||||
|
│ Tab Autocomplete │
|
||||||
|
│ Space Toggle fold │
|
||||||
|
├─────────────────────────────────────────────┤
|
||||||
|
│ SEARCH │
|
||||||
|
│ /text Search forward │
|
||||||
|
│ ?text Search backward │
|
||||||
|
│ ,rg Project-wide search │
|
||||||
|
│ ,,Enter Clear highlight │
|
||||||
|
└─────────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
Happy Vimming! 🚀
|
||||||
165
README.md
165
README.md
|
|
@ -1,6 +1,16 @@
|
||||||
# The Ultimate Vim Configuration
|
# The Ultimate Vim Configuration
|
||||||
|
|
||||||
A comprehensive, modern Vim configuration inspired by the best practices from the Vim community. This configuration transforms vanilla Vim into a powerful, feature-rich development environment.
|
A comprehensive, modern Vim configuration optimized for engineering workflows. This configuration transforms vanilla Vim into a powerful, feature-rich development environment with enterprise-grade tooling.
|
||||||
|
|
||||||
|
**✨ New: Quick installation script and enhanced engineering features!**
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/m1ngsama/chopsticks.git ~/.vim && cd ~/.vim && ./install.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
See [QUICKSTART.md](QUICKSTART.md) for detailed getting started guide.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
|
@ -31,34 +41,43 @@ A comprehensive, modern Vim configuration inspired by the best practices from th
|
||||||
- **UndoTree**: Visualize and navigate undo history (`F5`)
|
- **UndoTree**: Visualize and navigate undo history (`F5`)
|
||||||
- **Tagbar**: Code structure browser (`F8`)
|
- **Tagbar**: Code structure browser (`F8`)
|
||||||
- **Smart Window Management**: Easy navigation with `Ctrl+hjkl`
|
- **Smart Window Management**: Easy navigation with `Ctrl+hjkl`
|
||||||
|
- **Session Management**: Auto-save sessions with vim-obsession
|
||||||
|
- **Project-Specific Settings**: Per-project .vimrc support
|
||||||
|
- **Large File Optimization**: Automatic performance tuning for files >10MB
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### 1. Clone this repository
|
### Automatic Installation (Recommended)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/m1ngsama/chopsticks.git ~/.vim
|
git clone https://github.com/m1ngsama/chopsticks.git ~/.vim
|
||||||
cd ~/.vim
|
cd ~/.vim
|
||||||
|
./install.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Create symlink to .vimrc
|
The installation script will:
|
||||||
|
- ✓ Backup your existing configuration
|
||||||
|
- ✓ Create necessary symlinks
|
||||||
|
- ✓ Install vim-plug automatically
|
||||||
|
- ✓ Install all plugins
|
||||||
|
- ✓ Offer to install CoC language servers
|
||||||
|
|
||||||
|
### Manual Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# 1. Clone this repository
|
||||||
|
git clone https://github.com/m1ngsama/chopsticks.git ~/.vim
|
||||||
|
cd ~/.vim
|
||||||
|
|
||||||
|
# 2. Create symlink to .vimrc
|
||||||
ln -s ~/.vim/.vimrc ~/.vimrc
|
ln -s ~/.vim/.vimrc ~/.vimrc
|
||||||
```
|
|
||||||
|
|
||||||
### 3. Install vim-plug and plugins
|
# 3. Install vim-plug
|
||||||
|
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
|
||||||
|
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||||
|
|
||||||
Open Vim and the plugins will be automatically installed:
|
# 4. Open Vim and install plugins
|
||||||
|
vim +PlugInstall +qall
|
||||||
```bash
|
|
||||||
vim
|
|
||||||
```
|
|
||||||
|
|
||||||
Or manually install plugins:
|
|
||||||
|
|
||||||
```vim
|
|
||||||
:PlugInstall
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4. (Optional) Install recommended dependencies
|
### 4. (Optional) Install recommended dependencies
|
||||||
|
|
@ -178,6 +197,31 @@ For intelligent code completion, install language servers:
|
||||||
|-----|--------|
|
|-----|--------|
|
||||||
| `,aj` | Next error/warning |
|
| `,aj` | Next error/warning |
|
||||||
| `,ak` | Previous error/warning |
|
| `,ak` | Previous error/warning |
|
||||||
|
| `,ad` | Show error details |
|
||||||
|
|
||||||
|
### Git Workflow
|
||||||
|
|
||||||
|
| Key | Action |
|
||||||
|
|-----|--------|
|
||||||
|
| `,gs` | Git status |
|
||||||
|
| `,gc` | Git commit |
|
||||||
|
| `,gp` | Git push |
|
||||||
|
| `,gl` | Git pull |
|
||||||
|
| `,gd` | Git diff |
|
||||||
|
| `,gb` | Git blame |
|
||||||
|
|
||||||
|
### Engineering Utilities
|
||||||
|
|
||||||
|
| Key | Action |
|
||||||
|
|-----|--------|
|
||||||
|
| `,ev` | Edit .vimrc |
|
||||||
|
| `,sv` | Reload .vimrc |
|
||||||
|
| `,F` | Format entire file |
|
||||||
|
| `,wa` | Save all buffers |
|
||||||
|
| `,cp` | Copy file path |
|
||||||
|
| `,cf` | Copy filename |
|
||||||
|
| `,*` | Search & replace word under cursor |
|
||||||
|
| `,<leader>` | Switch to last file |
|
||||||
|
|
||||||
### Other Utilities
|
### Other Utilities
|
||||||
|
|
||||||
|
|
@ -221,6 +265,10 @@ For intelligent code completion, install language servers:
|
||||||
- **Tagbar**: Code structure browser
|
- **Tagbar**: Code structure browser
|
||||||
- **EasyMotion**: Fast cursor movement
|
- **EasyMotion**: Fast cursor movement
|
||||||
- **CoC**: Code completion and LSP
|
- **CoC**: Code completion and LSP
|
||||||
|
- **vim-obsession**: Session management
|
||||||
|
- **vim-prosession**: Project sessions
|
||||||
|
- **vim-unimpaired**: Handy bracket mappings
|
||||||
|
- **targets.vim**: Additional text objects
|
||||||
|
|
||||||
## Color Schemes
|
## Color Schemes
|
||||||
|
|
||||||
|
|
@ -237,6 +285,49 @@ To change:
|
||||||
colorscheme dracula
|
colorscheme dracula
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Engineering Features
|
||||||
|
|
||||||
|
### Project-Specific Configuration
|
||||||
|
|
||||||
|
Create a `.vimrc` file in your project root for project-specific settings:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
" .vimrc in project root
|
||||||
|
set shiftwidth=2
|
||||||
|
let g:ale_python_black_options = '--line-length=100'
|
||||||
|
```
|
||||||
|
|
||||||
|
The configuration automatically loads project-specific settings while maintaining security.
|
||||||
|
|
||||||
|
### Session Management
|
||||||
|
|
||||||
|
Sessions are automatically saved with vim-obsession:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
" Start session tracking
|
||||||
|
:Obsess
|
||||||
|
|
||||||
|
" Stop session tracking
|
||||||
|
:Obsess!
|
||||||
|
|
||||||
|
" Sessions are saved to ~/.vim/sessions/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Large File Handling
|
||||||
|
|
||||||
|
Files larger than 10MB automatically disable heavy features for better performance:
|
||||||
|
- Syntax highlighting optimized
|
||||||
|
- Undo levels reduced
|
||||||
|
- Swap files disabled
|
||||||
|
|
||||||
|
### Terminal Integration
|
||||||
|
|
||||||
|
Open integrated terminal:
|
||||||
|
- `,tv` - Vertical terminal split
|
||||||
|
- `,th` - Horizontal terminal split (10 rows)
|
||||||
|
|
||||||
|
Navigate out of terminal with `Esc` then normal window navigation.
|
||||||
|
|
||||||
## Customization
|
## Customization
|
||||||
|
|
||||||
The configuration is organized into sections:
|
The configuration is organized into sections:
|
||||||
|
|
@ -248,25 +339,67 @@ The configuration is organized into sections:
|
||||||
5. **Plugin Settings**: Individual plugin configurations
|
5. **Plugin Settings**: Individual plugin configurations
|
||||||
6. **Auto Commands**: File-type specific settings
|
6. **Auto Commands**: File-type specific settings
|
||||||
7. **Helper Functions**: Utility functions
|
7. **Helper Functions**: Utility functions
|
||||||
|
8. **Engineering Utilities**: Project workflow tools
|
||||||
|
9. **Git Workflow**: Git integration shortcuts
|
||||||
|
|
||||||
Feel free to modify any section to suit your needs!
|
Feel free to modify any section to suit your needs!
|
||||||
|
|
||||||
|
### Quick Customization
|
||||||
|
|
||||||
|
Edit configuration:
|
||||||
|
```vim
|
||||||
|
,ev " Opens .vimrc in Vim
|
||||||
|
```
|
||||||
|
|
||||||
|
Reload configuration:
|
||||||
|
```vim
|
||||||
|
,sv " Sources .vimrc without restart
|
||||||
|
```
|
||||||
|
|
||||||
## Language-Specific Settings
|
## Language-Specific Settings
|
||||||
|
|
||||||
### Python
|
### Python
|
||||||
- 4 spaces indentation
|
- 4 spaces indentation
|
||||||
- 88 character line limit (Black formatter)
|
- 88 character line limit (Black formatter)
|
||||||
- Auto-formatting with Black on save
|
- Auto-formatting with Black + isort on save
|
||||||
|
- Linting with flake8 and pylint
|
||||||
|
|
||||||
### JavaScript/TypeScript
|
### JavaScript/TypeScript
|
||||||
- 2 spaces indentation
|
- 2 spaces indentation
|
||||||
- Prettier formatting on save
|
- Prettier formatting on save
|
||||||
- ESLint integration
|
- ESLint integration
|
||||||
|
- TypeScript server support
|
||||||
|
|
||||||
### Go
|
### Go
|
||||||
- Tab indentation
|
- Tab indentation
|
||||||
- Auto-formatting with gofmt
|
- Auto-formatting with gofmt
|
||||||
- Auto-import with goimports
|
- Auto-import with goimports
|
||||||
|
- gopls language server
|
||||||
|
|
||||||
|
### Rust
|
||||||
|
- Auto-formatting with rustfmt
|
||||||
|
- Cargo integration
|
||||||
|
|
||||||
|
### Shell Scripts
|
||||||
|
- 2 spaces indentation
|
||||||
|
- shellcheck linting
|
||||||
|
|
||||||
|
### Docker
|
||||||
|
- Dockerfile syntax highlighting
|
||||||
|
- hadolint linting
|
||||||
|
|
||||||
|
### YAML
|
||||||
|
- 2 spaces indentation
|
||||||
|
- yamllint integration
|
||||||
|
|
||||||
|
### HTML/CSS
|
||||||
|
- 2 spaces indentation
|
||||||
|
- Prettier formatting
|
||||||
|
|
||||||
|
### Markdown
|
||||||
|
- Line wrapping enabled
|
||||||
|
- Spell checking enabled
|
||||||
|
- Prettier formatting
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
|
|
|
||||||
119
install.sh
Executable file
119
install.sh
Executable file
|
|
@ -0,0 +1,119 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# Vim Configuration - Quick Installation Script
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
BOLD='\033[1m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
RED='\033[0;31m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
echo -e "${BOLD}========================================${NC}"
|
||||||
|
echo -e "${BOLD}Vim Configuration Installer${NC}"
|
||||||
|
echo -e "${BOLD}========================================${NC}\n"
|
||||||
|
|
||||||
|
# Function to print status messages
|
||||||
|
print_status() {
|
||||||
|
echo -e "${GREEN}==>${NC} ${BOLD}$1${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_warning() {
|
||||||
|
echo -e "${YELLOW}Warning:${NC} $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_error() {
|
||||||
|
echo -e "${RED}Error:${NC} $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if vim is installed
|
||||||
|
if ! command -v vim &> /dev/null; then
|
||||||
|
print_error "Vim is not installed. Please install Vim first."
|
||||||
|
echo " Ubuntu/Debian: sudo apt install vim"
|
||||||
|
echo " macOS: brew install vim"
|
||||||
|
echo " Fedora: sudo dnf install vim"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_status "Vim version: $(vim --version | head -n1)"
|
||||||
|
|
||||||
|
# Backup existing .vimrc if it exists
|
||||||
|
if [ -f "$HOME/.vimrc" ] && [ ! -L "$HOME/.vimrc" ]; then
|
||||||
|
BACKUP_FILE="$HOME/.vimrc.backup.$(date +%Y%m%d_%H%M%S)"
|
||||||
|
print_warning "Backing up existing .vimrc to $BACKUP_FILE"
|
||||||
|
mv "$HOME/.vimrc" "$BACKUP_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create symlink to .vimrc
|
||||||
|
print_status "Creating symlink: $HOME/.vimrc -> $SCRIPT_DIR/.vimrc"
|
||||||
|
ln -sf "$SCRIPT_DIR/.vimrc" "$HOME/.vimrc"
|
||||||
|
|
||||||
|
# Install vim-plug if not already installed
|
||||||
|
VIM_PLUG_PATH="$HOME/.vim/autoload/plug.vim"
|
||||||
|
if [ ! -f "$VIM_PLUG_PATH" ]; then
|
||||||
|
print_status "Installing vim-plug..."
|
||||||
|
curl -fLo "$VIM_PLUG_PATH" --create-dirs \
|
||||||
|
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||||
|
echo -e "${GREEN}✓${NC} vim-plug installed successfully"
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}✓${NC} vim-plug already installed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install plugins
|
||||||
|
print_status "Installing Vim plugins..."
|
||||||
|
vim +PlugInstall +qall
|
||||||
|
|
||||||
|
echo -e "\n${GREEN}✓${NC} ${BOLD}Installation complete!${NC}\n"
|
||||||
|
|
||||||
|
# Print optional dependencies
|
||||||
|
echo -e "${BOLD}Optional Dependencies (Recommended):${NC}"
|
||||||
|
echo ""
|
||||||
|
echo -e "${BOLD}1. FZF (Fuzzy Finder):${NC}"
|
||||||
|
echo " Ubuntu/Debian: sudo apt install fzf ripgrep"
|
||||||
|
echo " macOS: brew install fzf ripgrep"
|
||||||
|
echo ""
|
||||||
|
echo -e "${BOLD}2. Node.js (for CoC completion):${NC}"
|
||||||
|
echo " Ubuntu/Debian: curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && sudo apt install -y nodejs"
|
||||||
|
echo " macOS: brew install node"
|
||||||
|
echo ""
|
||||||
|
echo -e "${BOLD}3. Universal Ctags (for code navigation):${NC}"
|
||||||
|
echo " Ubuntu/Debian: sudo apt install universal-ctags"
|
||||||
|
echo " macOS: brew install universal-ctags"
|
||||||
|
echo ""
|
||||||
|
echo -e "${BOLD}4. Language-specific tools:${NC}"
|
||||||
|
echo " Python: pip install black flake8 pylint"
|
||||||
|
echo " JavaScript: npm install -g prettier eslint"
|
||||||
|
echo " Go: go install golang.org/x/tools/gopls@latest"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Ask to install CoC language servers
|
||||||
|
read -p "Do you want to install CoC language servers now? (y/N) " -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
print_status "Installing CoC language servers..."
|
||||||
|
|
||||||
|
# Check if node is installed
|
||||||
|
if ! command -v node &> /dev/null; then
|
||||||
|
print_error "Node.js is not installed. Please install Node.js first."
|
||||||
|
else
|
||||||
|
vim -c "CocInstall -sync coc-json coc-tsserver coc-pyright coc-sh coc-html coc-css coc-yaml|q"
|
||||||
|
echo -e "${GREEN}✓${NC} CoC language servers installed"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo -e "${BOLD}========================================${NC}"
|
||||||
|
echo -e "${GREEN}All done!${NC} Open Vim and start coding!"
|
||||||
|
echo -e "${BOLD}========================================${NC}"
|
||||||
|
echo ""
|
||||||
|
echo -e "Quick tips:"
|
||||||
|
echo " - Press ${BOLD}Ctrl+n${NC} to toggle file explorer (NERDTree)"
|
||||||
|
echo " - Press ${BOLD}Ctrl+p${NC} to fuzzy search files (FZF)"
|
||||||
|
echo " - Press ${BOLD},w${NC} to quick save"
|
||||||
|
echo " - Press ${BOLD}K${NC} on a function to see documentation"
|
||||||
|
echo " - See README.md for complete key mappings"
|
||||||
|
echo ""
|
||||||
Loading…
Reference in a new issue