From 2941614b4584f6f048845411dd79a52bcea927b0 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 30 Dec 2025 00:17:46 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E5=B7=A5=E7=A8=8B=E5=8C=96=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=9A=E6=B7=BB=E5=8A=A0=E5=BF=AB=E9=80=9F=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E8=84=9A=E6=9C=AC=E5=92=8C=E4=BC=81=E4=B8=9A=E7=BA=A7?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增功能: ✨ 一键安装脚本 (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 (不在输入时) ⚡ 优化的语法高亮 ⚡ 更快的启动时间 --- .vimrc | 196 +++++++++++++++++++++++++++++++++++- QUICKSTART.md | 271 ++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 165 +++++++++++++++++++++++++++--- install.sh | 119 ++++++++++++++++++++++ 4 files changed, 734 insertions(+), 17 deletions(-) create mode 100644 QUICKSTART.md create mode 100755 install.sh diff --git a/.vimrc b/.vimrc index 1939ba4..9e56e59 100644 --- a/.vimrc +++ b/.vimrc @@ -242,6 +242,15 @@ if has('vim9') || has('nvim') Plug 'neoclide/coc.nvim', {'branch': 'release'} " LSP & Completion 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() " ============================================================================ @@ -395,7 +404,14 @@ autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isT let NERDTreeShowHidden=1 " 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 --- map :Files @@ -403,6 +419,19 @@ map b :Buffers map rg :Rg map t :Tags +" 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(), 1, + \ fzf#vim#with_preview(), 0) + +" Search in git files +command! -bang GFiles call fzf#vim#gitfiles('', fzf#vim#with_preview(), 0) + " --- CtrlP --- let g:ctrlp_working_path_mode = 'ra' let g:ctrlp_show_hidden = 1 @@ -430,23 +459,39 @@ let g:gitgutter_sign_modified_removed = '~' let g:ale_linters = { \ 'python': ['flake8', 'pylint'], \ 'javascript': ['eslint'], +\ 'typescript': ['eslint', 'tsserver'], \ 'go': ['gopls', 'golint'], +\ 'rust': ['cargo'], +\ 'sh': ['shellcheck'], +\ 'yaml': ['yamllint'], +\ 'dockerfile': ['hadolint'], \} let g:ale_fixers = { \ '*': ['remove_trailing_lines', 'trim_whitespace'], \ 'python': ['black', 'isort'], \ 'javascript': ['prettier', 'eslint'], +\ 'typescript': ['prettier', 'eslint'], \ '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_sign_error = '✗' 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 nmap aj :ALENext nmap ak :ALEPrevious +nmap ad :ALEDetail " --- Tagbar --- nmap :TagbarToggle @@ -588,6 +633,28 @@ autocmd FileType javascript,typescript setlocal expandtab shiftwidth=2 tabstop=2 " Go specific settings 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 " ============================================================================ @@ -642,6 +709,133 @@ else set signcolumn=yes 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 F gg=G`` + +" Toggle between source and header files (for C/C++) +nnoremap a :A + +" Quick save all buffers +nnoremap wa :wa + +" Easier window resizing +nnoremap = :exe "resize " . (winheight(0) * 3/2) +nnoremap - :exe "resize " . (winheight(0) * 2/3) +nnoremap + :exe "vertical resize " . (winwidth(0) * 3/2) +nnoremap _ :exe "vertical resize " . (winwidth(0) * 2/3) + +" Quick switch between last two files +nnoremap + +" Clear whitespace on empty lines +nnoremap W :%s/\s\+$//:let @/='' + +" Source current file +nnoremap so :source % + +" Edit vimrc quickly +nnoremap ev :edit $MYVIMRC + +" Reload vimrc +nnoremap sv :source $MYVIMRC + +" Search and replace word under cursor +nnoremap * :%s/\<\>//g + +" Copy file path to clipboard +nnoremap cp :let @+ = expand("%:p"):echo "Copied path: " . expand("%:p") +nnoremap cf :let @+ = expand("%:t"):echo "Copied filename: " . expand("%:t") + +" 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(''), +expand('')) +augroup END + +" ============================================================================ +" => Debugging Helpers +" ============================================================================ + +" Show syntax highlighting groups for word under cursor +nmap sp :call SynStack() +function! SynStack() + if !exists("*synstack") + return + endif + echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') +endfunc + +" ============================================================================ +" => Git Workflow Enhancements +" ============================================================================ + +" Git shortcuts +nnoremap gs :Git status +nnoremap gc :Git commit +nnoremap gp :Git push +nnoremap gl :Git pull +nnoremap gd :Gdiff +nnoremap gb :Git blame + +" ============================================================================ +" => Terminal Integration +" ============================================================================ + +" Better terminal navigation +if has('terminal') + " Open terminal in split + nnoremap tv :terminal + nnoremap th :terminal ++rows=10 + + " Terminal mode mappings + tnoremap + tnoremap h + tnoremap j + tnoremap k + tnoremap 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("")) | 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 " ============================================================================ diff --git a/QUICKSTART.md b/QUICKSTART.md new file mode 100644 index 0000000..fb98685 --- /dev/null +++ b/QUICKSTART.md @@ -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! 🚀 diff --git a/README.md b/README.md index a7c79f0..bb7a11f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,16 @@ # 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 @@ -31,34 +41,43 @@ A comprehensive, modern Vim configuration inspired by the best practices from th - **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 -### 1. Clone this repository +### Automatic Installation (Recommended) ```bash git clone https://github.com/m1ngsama/chopsticks.git ~/.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 +# 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 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: - -```bash -vim -``` - -Or manually install plugins: - -```vim -:PlugInstall +# 4. Open Vim and install plugins +vim +PlugInstall +qall ``` ### 4. (Optional) Install recommended dependencies @@ -178,6 +197,31 @@ For intelligent code completion, install language servers: |-----|--------| | `,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 | +| `,` | Switch to last file | ### Other Utilities @@ -221,6 +265,10 @@ For intelligent code completion, install language servers: - **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 @@ -237,6 +285,49 @@ To change: 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: @@ -248,25 +339,67 @@ The configuration is organized into sections: 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 on save +- 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 diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..3bdaac8 --- /dev/null +++ b/install.sh @@ -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 "" From 0ea76e6ae7e9bb04b187a4f86963edf78a7ed19e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 30 Dec 2025 00:29:35 +0000 Subject: [PATCH 2/2] Remove all icons and emojis - keep it simple (KISS principle) Changes: - Replaced checkmarks with plain text in README.md - Replaced emoji icons with [OK] in install.sh - Changed ALE error/warning signs from unicode to ASCII (X and !) - Removed rocket emoji from QUICKSTART.md - All output now uses simple ASCII characters Follows KISS (Keep It Simple, Stupid) principle for better: - Terminal compatibility - Accessibility - Readability in all environments - No font dependencies --- .vimrc | 4 ++-- QUICKSTART.md | 10 +++++----- README.md | 12 ++++++------ install.sh | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.vimrc b/.vimrc index 9e56e59..891a969 100644 --- a/.vimrc +++ b/.vimrc @@ -482,8 +482,8 @@ let g:ale_fixers = { \} let g:ale_fix_on_save = 1 -let g:ale_sign_error = '✗' -let g:ale_sign_warning = '⚠' +let g:ale_sign_error = 'X' +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 diff --git a/QUICKSTART.md b/QUICKSTART.md index fb98685..126c3c2 100644 --- a/QUICKSTART.md +++ b/QUICKSTART.md @@ -11,10 +11,10 @@ git clone https://github.com/m1ngsama/chopsticks.git ~/.vim && cd ~/.vim && ./in ``` That's it! The script will: -- ✓ Backup your existing .vimrc -- ✓ Create symlink to the new configuration -- ✓ Install vim-plug -- ✓ Install all plugins automatically +- Backup your existing .vimrc +- Create symlink to the new configuration +- Install vim-plug +- Install all plugins automatically ### Manual Install @@ -268,4 +268,4 @@ Print this for your desk: └─────────────────────────────────────────────┘ ``` -Happy Vimming! 🚀 +Happy Vimming! diff --git a/README.md b/README.md index bb7a11f..2d98748 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 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!** +**NEW: Quick installation script and enhanced engineering features!** ## Quick Start @@ -56,11 +56,11 @@ cd ~/.vim ``` The installation script will: -- ✓ Backup your existing configuration -- ✓ Create necessary symlinks -- ✓ Install vim-plug automatically -- ✓ Install all plugins -- ✓ Offer to install CoC language servers +- Backup your existing configuration +- Create necessary symlinks +- Install vim-plug automatically +- Install all plugins +- Offer to install CoC language servers ### Manual Installation diff --git a/install.sh b/install.sh index 3bdaac8..c71a04d 100755 --- a/install.sh +++ b/install.sh @@ -58,16 +58,16 @@ 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" + echo -e "${GREEN}[OK]${NC} vim-plug installed successfully" else - echo -e "${GREEN}✓${NC} vim-plug already installed" + echo -e "${GREEN}[OK]${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" +echo -e "\n${GREEN}[OK]${NC} ${BOLD}Installation complete!${NC}\n" # Print optional dependencies echo -e "${BOLD}Optional Dependencies (Recommended):${NC}" @@ -101,7 +101,7 @@ if [[ $REPLY =~ ^[Yy]$ ]]; 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" + echo -e "${GREEN}[OK]${NC} CoC language servers installed" fi fi