mirror of
https://github.com/m1ngsama/chopsticks.git
synced 2026-02-07 22:44:04 +00:00
Merge pull request #2 from m1ngsama/claude/engineering-optimizations-siZCJ
This commit is contained in:
commit
5ef24a5679
4 changed files with 736 additions and 19 deletions
200
.vimrc
200
.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 <C-p> :Files<CR>
|
||||
|
|
@ -403,6 +419,19 @@ map <leader>b :Buffers<CR>
|
|||
map <leader>rg :Rg<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 ---
|
||||
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_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
|
||||
|
||||
" Navigate between errors
|
||||
nmap <silent> <leader>aj :ALENext<cr>
|
||||
nmap <silent> <leader>ak :ALEPrevious<cr>
|
||||
nmap <silent> <leader>ad :ALEDetail<cr>
|
||||
|
||||
" --- Tagbar ---
|
||||
nmap <F8> :TagbarToggle<CR>
|
||||
|
|
@ -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 <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
|
||||
" ============================================================================
|
||||
|
|
|
|||
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
|
||||
|
||||
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 |
|
||||
| `,<leader>` | 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
|
||||
|
||||
|
|
|
|||
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}[OK]${NC} vim-plug installed successfully"
|
||||
else
|
||||
echo -e "${GREEN}[OK]${NC} vim-plug already installed"
|
||||
fi
|
||||
|
||||
# Install plugins
|
||||
print_status "Installing Vim plugins..."
|
||||
vim +PlugInstall +qall
|
||||
|
||||
echo -e "\n${GREEN}[OK]${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}[OK]${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