mirror of
https://github.com/m1ngsama/chopsticks.git
synced 2026-02-07 22:44:04 +00:00
This commit addresses multiple issues discovered during code review: 1. Fix variable definition order in .vimrc - Move g:is_tty and g:has_true_color definitions to top of file - Previously used at line 32 but defined at line 263 - Ensures variables are available before first use 2. Remove duplicate configuration settings in .vimrc - Remove duplicate set number, wildmenu, ruler - Remove duplicate search settings (ignorecase, smartcase, hlsearch, incsearch) - Remove duplicate backspace and wildignore settings - Reduces file size and eliminates confusion 3. Enhance install.sh reliability - Add directory validation to ensure script runs from ~/.vim - Add symlink validation after creation - Fix CoC installation command syntax (vim -c to vim +) - Move helper functions before usage - Prevents symlink-to-self errors 4. Improve installation documentation - Add warnings in README.md about running from correct directory - Add IMPORTANT notes in QUICKSTART.md - Update installation step descriptions - Prevents common user installation mistakes These fixes improve installation reliability and prevent configuration errors.
6.6 KiB
6.6 KiB
Quick Start Guide
Get up and running with this Vim configuration in 5 minutes!
Installation
One-Line Install
git clone https://github.com/m1ngsama/chopsticks.git ~/.vim && cd ~/.vim && ./install.sh
IMPORTANT: Always run the install script from the ~/.vim directory (where you cloned the repository). The script validates this to ensure correct symlink creation.
That's it! The script will:
- Verify it's being run from the correct directory
- Backup your existing .vimrc
- Create and validate symlink to the new configuration
- Install vim-plug
- Install all plugins automatically
Manual Install
# 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
# 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
- Open a file with
Ctrl+por through NERDTree - Use
gdto jump to definitions - Use
Kto view documentation - Use
Tabfor autocomplete while typing - 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
" 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:
pip install black flake8 pylint
vim -c "CocInstall coc-pyright" -c "q"
JavaScript/TypeScript
- Prettier formatting (on save)
- ESLint integration
- 2-space indentation
Setup:
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:
go install golang.org/x/tools/gopls@latest
vim -c "CocInstall coc-go" -c "q"
Troubleshooting
Plugins not working?
:PlugInstall
:PlugUpdate
Autocomplete not working?
Make sure Node.js is installed:
node --version # Should be >= 14.14
Then install CoC language servers:
:CocInstall coc-json coc-tsserver coc-pyright
FZF not finding files?
Install FZF and ripgrep:
# Ubuntu/Debian
sudo apt install fzf ripgrep
# macOS
brew install fzf ripgrep
Colors look weird?
Add to your ~/.bashrc or ~/.zshrc:
export TERM=xterm-256color
Customization
The .vimrc file is well-organized into sections:
- General Settings (lines 1-150) - Basic Vim behavior
- Plugin Management (lines 151-230) - Plugin list
- Key Mappings (lines 300-400) - Custom shortcuts
- Plugin Settings (lines 400-600) - Plugin configurations
To customize:
- Open
~/.vim/.vimrc - Find the section you want to modify
- Make your changes
- Reload with
:source ~/.vimrcor restart Vim
Common Customizations
Change colorscheme:
" In .vimrc, find the colorscheme line and change to:
colorscheme dracula
" or: solarized, onedark, gruvbox
Change leader key:
" Default is comma (,), change to space:
let mapleader = " "
Disable relative line numbers:
set norelativenumber
Next Steps
- Read the full README.md for complete documentation
- Check out
:helpin Vim for built-in documentation - Customize the configuration to your needs
- 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!