chopsticks/README.md
Claude 2941614b45
工程化优化:添加快速安装脚本和企业级开发功能
新增功能:
 一键安装脚本 (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 (不在输入时)
 优化的语法高亮
 更快的启动时间
2025-12-30 00:17:46 +00:00

444 lines
10 KiB
Markdown

# The Ultimate Vim Configuration
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
### Core Enhancements
- **Smart Line Numbers**: Hybrid line numbers (absolute + relative) for efficient navigation
- **Modern UI**: Gruvbox color scheme with airline status bar
- **Plugin Management**: vim-plug for easy plugin installation and updates
- **Auto-completion**: CoC (Conquer of Completion) for intelligent code completion
- **Syntax Checking**: ALE (Asynchronous Lint Engine) for real-time linting
### File Navigation
- **NERDTree**: Visual file explorer (`Ctrl+n`)
- **FZF**: Blazing fast fuzzy finder (`Ctrl+p`)
- **CtrlP**: Alternative fuzzy file finder
- **Easy Motion**: Jump to any location with minimal keystrokes
### Git Integration
- **Fugitive**: Complete Git wrapper for Vim
- **GitGutter**: Show git diff in the sign column
### Code Editing
- **Auto-pairs**: Automatic bracket/quote pairing
- **Surround**: Easily change surrounding quotes, brackets, tags
- **Commentary**: Quick code commenting (`gc`)
- **Multi-language Support**: vim-polyglot for 100+ languages
### Productivity Tools
- **UndoTree**: Visualize and navigate undo history (`F5`)
- **Tagbar**: Code structure browser (`F8`)
- **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
### Automatic Installation (Recommended)
```bash
git clone https://github.com/m1ngsama/chopsticks.git ~/.vim
cd ~/.vim
./install.sh
```
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
# 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
# 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
```
### 4. (Optional) Install recommended dependencies
For the best experience, install these optional dependencies:
```bash
# FZF (fuzzy finder)
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
# ripgrep (better grep)
# On Ubuntu/Debian
sudo apt install ripgrep
# On macOS
brew install ripgrep
# Node.js (for CoC)
# Required for code completion
curl -sL install-node.now.sh/lts | bash
# Universal Ctags (for Tagbar)
# On Ubuntu/Debian
sudo apt install universal-ctags
# On macOS
brew install universal-ctags
```
### 5. Install CoC language servers
For intelligent code completion, install language servers:
```vim
" Python
:CocInstall coc-pyright
" JavaScript/TypeScript
:CocInstall coc-tsserver
" Go
:CocInstall coc-go
" JSON
:CocInstall coc-json
" HTML/CSS
:CocInstall coc-html coc-css
" See more: https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions
```
## Key Mappings
### General
| Key | Action |
|-----|--------|
| `,w` | Quick save |
| `,q` | Quick quit |
| `,x` | Save and quit |
| `,,` + Enter | Clear search highlight |
### Window Navigation
| Key | Action |
|-----|--------|
| `Ctrl+h` | Move to left window |
| `Ctrl+j` | Move to bottom window |
| `Ctrl+k` | Move to top window |
| `Ctrl+l` | Move to right window |
### Buffer Management
| Key | Action |
|-----|--------|
| `,l` | Next buffer |
| `,h` | Previous buffer |
| `,bd` | Close current buffer |
| `,ba` | Close all buffers |
### Tab Management
| Key | Action |
|-----|--------|
| `,tn` | New tab |
| `,tc` | Close tab |
| `,tl` | Toggle to last tab |
### File Navigation
| Key | Action |
|-----|--------|
| `Ctrl+n` | Toggle NERDTree |
| `,n` | Find current file in NERDTree |
| `Ctrl+p` | FZF file search |
| `,b` | FZF buffer search |
| `,rg` | Ripgrep search |
### Code Navigation (CoC)
| Key | Action |
|-----|--------|
| `gd` | Go to definition |
| `gy` | Go to type definition |
| `gi` | Go to implementation |
| `gr` | Go to references |
| `K` | Show documentation |
| `[g` | Previous diagnostic |
| `]g` | Next diagnostic |
| `,rn` | Rename symbol |
### Linting (ALE)
| Key | Action |
|-----|--------|
| `,aj` | Next 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
| Key | Action |
|-----|--------|
| `F2` | Toggle paste mode |
| `F3` | Toggle line numbers |
| `F4` | Toggle relative numbers |
| `F5` | Toggle UndoTree |
| `F8` | Toggle Tagbar |
| `Space` | Toggle fold |
| `s` + 2 chars | EasyMotion jump |
## Plugin List
### File Navigation & Search
- **NERDTree**: File system explorer
- **FZF**: Fuzzy file finder
- **CtrlP**: Alternative fuzzy finder
### Git
- **vim-fugitive**: Git integration
- **vim-gitgutter**: Git diff in sign column
### UI
- **vim-airline**: Enhanced status line
- **gruvbox**: Color scheme
### Code Editing
- **vim-surround**: Manage surroundings
- **vim-commentary**: Code commenting
- **auto-pairs**: Auto close brackets
- **ALE**: Asynchronous linting
### Language Support
- **vim-polyglot**: Language pack for 100+ languages
- **vim-go**: Go development
### Productivity
- **UndoTree**: Undo history visualizer
- **Tagbar**: Code structure browser
- **EasyMotion**: Fast cursor movement
- **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
Available color schemes (change in .vimrc):
- **gruvbox** (default) - Warm, retro groove colors
- **dracula** - Dark theme with vivid colors
- **solarized** - Precision colors for machines and people
- **onedark** - Atom's iconic One Dark theme
To change:
```vim
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
The configuration is organized into sections:
1. **General Settings**: Basic Vim behavior
2. **Plugin Management**: vim-plug configuration
3. **Colors & Fonts**: Visual appearance
4. **Key Mappings**: Custom keybindings
5. **Plugin Settings**: Individual plugin configurations
6. **Auto Commands**: File-type specific settings
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!
### Quick Customization
Edit configuration:
```vim
,ev " Opens .vimrc in Vim
```
Reload configuration:
```vim
,sv " Sources .vimrc without restart
```
## Language-Specific Settings
### Python
- 4 spaces indentation
- 88 character line limit (Black formatter)
- Auto-formatting with Black + isort on save
- Linting with flake8 and pylint
### JavaScript/TypeScript
- 2 spaces indentation
- Prettier formatting on save
- ESLint integration
- TypeScript server support
### Go
- Tab indentation
- Auto-formatting with gofmt
- 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
### Plugins not working
```vim
:PlugInstall
:PlugUpdate
```
### CoC not working
Make sure Node.js is installed:
```bash
node --version # Should be >= 14.14
```
### Colors look wrong
Enable true colors in your terminal emulator and add to your shell rc:
```bash
export TERM=xterm-256color
```
## References
This configuration is inspired by:
- [amix/vimrc](https://github.com/amix/vimrc) - The ultimate vimrc
- [vim-plug](https://github.com/junegunn/vim-plug) - Minimalist plugin manager
- [Top 50 Vim Configuration Options](https://www.shortcutfoo.com/blog/top-50-vim-configuration-options)
- [Modern Vim Development Setup 2025](https://swedishembedded.com/developers/vim-in-minutes)
## License
MIT License - Feel free to use and modify!
## Contributing
Suggestions and improvements are welcome! Feel free to open an issue or submit a pull request.