-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.vimrc
More file actions
405 lines (333 loc) · 19.2 KB
/
.vimrc
File metadata and controls
405 lines (333 loc) · 19.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
" =============================================================================
" IDV's Vim Configuration
" =============================================================================
" A comprehensive Vim configuration focused on Python development and
" general productivity with modern plugins and sensible defaults.
"
" Author: Igor Dvoretskyi
" Repository: https://github.com/idvoretskyi/vim_idv
" =============================================================================
" =============================================================================
" Vim-Plug Plugin Manager Setup
" =============================================================================
" Auto-install vim-plug if not present
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Initialize plugin system
call plug#begin('~/.vim/plugged')
" =============================================================================
" Core Plugins - Essential functionality and sensible defaults
" =============================================================================
Plug 'tpope/vim-sensible' " Sensible defaults for Vim
Plug 'tpope/vim-fugitive' " Git integration
Plug 'tpope/vim-markdown' " Enhanced markdown support
" =============================================================================
" Code Quality & Linting
" =============================================================================
Plug 'scrooloose/syntastic' " Syntax checking framework
Plug 'nvie/vim-flake8' " Python PEP8 checker
" =============================================================================
" Interface & Navigation Plugins
" =============================================================================
Plug 'vim-airline/vim-airline' " Enhanced status line
Plug 'vim-airline/vim-airline-themes' " Themes for airline
Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeToggle', 'NERDTreeTabsToggle', 'NERDTree'] } " File explorer (lazy)
Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': ['NERDTreeToggle', 'NERDTreeTabsToggle'] } " Git status in NERDTree (lazy)
Plug 'jistr/vim-nerdtree-tabs', { 'on': 'NERDTreeTabsToggle' } " NERDTree with tabs (lazy)
Plug 'majutsushi/tagbar', { 'on': 'TagbarToggle' } " Code structure browser (lazy)
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " Fuzzy finder
Plug 'junegunn/fzf.vim' " FZF integration
" =============================================================================
" Code Development & Editing
" =============================================================================
Plug 'scrooloose/nerdcommenter' " Easy commenting
Plug 'jiangmiao/auto-pairs' " Auto-close brackets and quotes
Plug 'sheerun/vim-polyglot' " Language pack collection
Plug 'github/copilot.vim', { 'on': [] } " AI-powered code assistance (manual load)
" =============================================================================
" Python Development
" =============================================================================
Plug 'davidhalter/jedi-vim', { 'for': 'python' } " Python autocompletion (lazy)
Plug 'python-mode/python-mode', { 'for': 'python' } " Python IDE features (lazy)
" =============================================================================
" Go Development
" =============================================================================
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries', 'for': 'go' } " Go development tools
" =============================================================================
" Git Integration
" =============================================================================
Plug 'airblade/vim-gitgutter' " Git diff indicators in gutter
" =============================================================================
" Markdown & Documentation
" =============================================================================
Plug 'moorereason/vim-markdownfmt', { 'for': 'markdown' } " Markdown formatting (lazy)
" =============================================================================
" Color Schemes
" =============================================================================
Plug 'junegunn/seoul256.vim' " Seoul256 color scheme
Plug 'altercation/vim-colors-solarized' " Solarized color scheme
" Finalize plugin installation
call plug#end()
" =============================================================================
" General Settings - Core Vim behavior and appearance
" =============================================================================
" Display and Interface
set number " Show line numbers
set ruler " Show cursor position in status line
set showcmd " Show command in bottom bar
set wildmenu " Visual autocomplete for command menu
set showmatch " Highlight matching brackets
set laststatus=2 " Always show status line
set cursorline " Highlight current line
set scrolloff=5 " Keep 5 lines below and above cursor
" Text Editing Behavior
set backspace=indent,eol,start " Make backspace behave normally
set hidden " Allow buffer switching without saving
set encoding=utf-8 " Use UTF-8 encoding
" File Management
set nobackup " Disable backup files (we use git)
set noswapfile " Disable swap files (causes more issues than helps)
set undofile " Enable persistent undo history
set undodir=~/.vim/undo " Directory for undo files
" Search Behavior
set ignorecase " Case insensitive search
set smartcase " Override ignorecase if uppercase is used
set incsearch " Incremental search as you type
set hlsearch " Highlight search results
" =============================================================================
" Color Scheme and Visual Appearance
" =============================================================================
" Enable syntax highlighting
syntax enable
" Color scheme configuration
set background=dark " Use dark background
set t_Co=256 " Enable 256 colors
" Solarized color scheme settings
let g:solarized_termcolors=256 " Use 256 color version
let g:rehash256 = 1 " Better color accuracy
" Apply color scheme
colorscheme solarized
" Custom highlighting
highlight Comment cterm=bold " Make comments bold for better readability
" =============================================================================
" Python Development Configuration
" =============================================================================
" Python-mode settings
let g:pymode_python = 'python3' " Use Python 3
let g:pymode_lint_cwindow = 0 " Don't auto-open quickfix window
" PEP 8 compliance settings
augroup python_settings
autocmd!
autocmd FileType python setlocal textwidth=79 " Line length limit
autocmd FileType python setlocal shiftwidth=4 " Indentation width
autocmd FileType python setlocal tabstop=4 " Tab display width
autocmd FileType python setlocal expandtab " Use spaces instead of tabs
autocmd FileType python setlocal softtabstop=4 " Soft tab width
autocmd FileType python setlocal shiftround " Round indents to shiftwidth
autocmd FileType python setlocal autoindent " Auto-indent new lines
autocmd FileType python setlocal smartindent " Smart indentation
" Auto-run flake8 on save - disabled for performance, use <leader>8 manually
" autocmd BufWritePost *.py call Flake8()
augroup END
" Flake8 configuration
let g:flake8_show_in_gutter = 1 " Show errors in gutter
let g:flake8_show_in_file = 1 " Show errors in file
" Python-mode lint settings (alternative to flake8)
let g:PyFlakeOnWrite = 0 " Disable on-write checking
let g:PyFlakeCheckers = 'pep8,mccabe,frosted' " Enabled checkers
let g:PyFlakeDefaultComplexity = 10 " Maximum complexity
let g:PyFlakeAggressive = 3 " Aggressiveness level
let g:PyFlakeRangeCommand = 'Q' " Range checking command
" =============================================================================
" Go Development Configuration
" =============================================================================
" vim-go settings
let g:go_fmt_command = "goimports" " Use goimports for formatting (includes gofmt)
let g:go_fmt_autosave = 1 " Auto-format on save
let g:go_def_mode = 'gopls' " Use gopls for definitions
let g:go_info_mode = 'gopls' " Use gopls for info
let g:go_metalinter_autosave = 0 " Disable metalinter on save (performance)
let g:go_list_type = "quickfix" " Use quickfix for errors
" Syntax highlighting
let g:go_highlight_functions = 1 " Highlight functions
let g:go_highlight_methods = 1 " Highlight methods
let g:go_highlight_structs = 1 " Highlight structs
let g:go_highlight_operators = 1 " Highlight operators
let g:go_highlight_build_constraints = 1 " Highlight build constraints
let g:go_highlight_extra_types = 1 " Highlight extra types
let g:go_highlight_fields = 1 " Highlight struct fields
let g:go_highlight_types = 1 " Highlight types
let g:go_highlight_variable_declarations = 1 " Highlight variable declarations
let g:go_highlight_variable_assignments = 1 " Highlight variable assignments
" Go-specific indentation and formatting
augroup go_settings
autocmd!
autocmd FileType go setlocal tabstop=4 " Tab display width
autocmd FileType go setlocal shiftwidth=4 " Indentation width
autocmd FileType go setlocal noexpandtab " Use tabs (Go convention)
autocmd FileType go setlocal autoindent " Auto-indent new lines
augroup END
" =============================================================================
" NERDTree File Explorer Configuration
" =============================================================================
" NERDTree autocommands - minimal for performance
augroup nerdtree_settings
autocmd!
" Auto-open disabled for faster startup - use <C-f> to open manually
" Close vim if NERDTree is the only window left
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
augroup END
" NERDTree appearance
let g:NERDTreeDirArrowExpandable = "+" " Expandable directory symbol
let g:NERDTreeDirArrowCollapsible = "~" " Collapsible directory symbol
let g:NERDTreeShowHidden = 1 " Show hidden files
let g:NERDTreeMinimalUI = 1 " Minimal UI
let g:NERDTreeShowLineNumbers = 0 " Hide line numbers
let g:NERDTreeWinSize = 30 " Window width
" NERDTree file filters
let g:NERDTreeIgnore = ['\.pyc$', '\.pyo$', '__pycache__', '.git', '.DS_Store', '\.o$', '\.a$', '\.so$', '\.exe$']
" =============================================================================
" Plugin Configuration - Settings for installed plugins
" =============================================================================
" Airline Status Line Configuration
let g:airline#extensions#tabline#enabled = 1 " Enable tabline
let g:airline#extensions#tabline#left_sep = ' ' " Tab separator
let g:airline#extensions#tabline#left_alt_sep = '|' " Alternative separator
let g:airline_powerline_fonts = 1 " Use powerline fonts
let g:airline#extensions#branch#enabled = 1 " Show git branch
let g:airline#extensions#hunks#enabled = 1 " Show git changes
" FZF Fuzzy Finder Configuration
let g:fzf_layout = { 'down': '~40%' } " FZF window layout
let g:fzf_preview_window = ['right:50%', 'ctrl-/'] " Preview window
let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
" Git Gutter Configuration
let g:gitgutter_enabled = 1 " Enable git gutter
let g:gitgutter_map_keys = 0 " Disable default mappings
let g:gitgutter_highlight_linenrs = 1 " Highlight line numbers
" Syntastic Configuration - optimized for performance
let g:syntastic_always_populate_loc_list = 1 " Populate location list
let g:syntastic_auto_loc_list = 0 " Don't auto open location list
let g:syntastic_check_on_open = 0 " Don't check on file open (performance)
let g:syntastic_check_on_wq = 0 " Don't check on :wq
" Auto-pairs Configuration
let g:AutoPairsMapCR = 1 " Map <CR> for auto-pairs
" =============================================================================
" Key Mappings and Shortcuts
" =============================================================================
" Set leader key for custom shortcuts
let mapleader = ","
" =============================================================================
" File and Buffer Navigation
" =============================================================================
" File explorer and project navigation
nnoremap <C-f> :NERDTreeTabsToggle<CR> " Toggle file explorer
nnoremap <C-t> :TagbarToggle<CR> " Toggle code structure
nnoremap <leader>f :Files<CR> " FZF file search
nnoremap <leader>b :Buffers<CR> " FZF buffer search
nnoremap <leader>g :Rg<CR> " FZF grep search
nnoremap <leader>h :History<CR> " FZF file history
" Tab navigation
nnoremap <C-l> :tabn<CR> " Next tab
nnoremap <C-h> :tabp<CR> " Previous tab
nnoremap <C-n> :tabnew<CR> " New tab
" Window/split navigation (improved)
nnoremap <C-J> <C-W><C-J> " Move to split below
nnoremap <C-K> <C-W><C-K> " Move to split above
nnoremap <C-L> <C-W><C-L> " Move to split right
nnoremap <C-H> <C-W><C-H> " Move to split left
" =============================================================================
" File Operations
" =============================================================================
" Save and quit shortcuts
nnoremap <leader>w :w!<CR> " Force write
nnoremap <leader>q :q<CR> " Quit
nnoremap <leader>wq :wq<CR> " Write and quit
nnoremap <leader>x :x<CR> " Save and exit
" =============================================================================
" Development and Language-Specific Mappings
" =============================================================================
" Python development shortcuts
augroup python_mappings
autocmd!
autocmd FileType python nnoremap <buffer> <leader>r :!python3 %<CR> " Run Python file
autocmd FileType python nnoremap <buffer> <leader>8 :PymodeLint<CR> " Lint Python file
autocmd FileType python nnoremap <buffer> <leader>d :PymodeDoc<CR> " Show documentation
augroup END
" Go development shortcuts
augroup go_mappings
autocmd!
autocmd FileType go nnoremap <buffer> <leader>r :GoRun<CR> " Run Go file
autocmd FileType go nnoremap <buffer> <leader>b :GoBuild<CR> " Build Go project
autocmd FileType go nnoremap <buffer> <leader>t :GoTest<CR> " Run tests
autocmd FileType go nnoremap <buffer> <leader>c :GoCoverageToggle<CR> " Toggle coverage
autocmd FileType go nnoremap <buffer> <leader>d :GoDoc<CR> " Show documentation
autocmd FileType go nnoremap <buffer> <leader>i :GoInfo<CR> " Show type info
autocmd FileType go nnoremap <buffer> <leader>l :GoMetaLinter<CR> " Run linter
autocmd FileType go nnoremap <buffer> gd :GoDef<CR> " Go to definition
autocmd FileType go nnoremap <buffer> gr :GoReferrers<CR> " Show references
augroup END
" Syntax highlighting shortcuts
nnoremap <leader>th :set ft=htmljinja<CR> " HTML Jinja syntax
nnoremap <leader>tp :set ft=python<CR> " Python syntax
nnoremap <leader>tj :set ft=javascript<CR> " JavaScript syntax
nnoremap <leader>tc :set ft=css<CR> " CSS syntax
nnoremap <leader>td :set ft=django<CR> " Django syntax
nnoremap <leader>tg :set ft=go<CR> " Go syntax
" =============================================================================
" Git and Version Control
" =============================================================================
" Git shortcuts
nnoremap <leader>gs :Git status<CR> " Git status
nnoremap <leader>gc :Git commit<CR> " Git commit
nnoremap <leader>gp :Git push<CR> " Git push
nnoremap <leader>gl :Git log --oneline<CR> " Git log
" Git gutter navigation
nnoremap ]h :GitGutterNextHunk<CR> " Next git hunk
nnoremap [h :GitGutterPrevHunk<CR> " Previous git hunk
" =============================================================================
" Editing and Text Manipulation
" =============================================================================
" Auto-completion
inoremap <C-Space> <C-x><C-o> " Trigger omni-completion
" Clear search highlighting
nnoremap <leader><Space> :nohlsearch<CR> " Clear search highlight
" Toggle paste mode
nnoremap <leader>p :set paste!<CR> " Toggle paste mode
" =============================================================================
" Custom Functions and Advanced Mappings
" =============================================================================
" Quick edit vimrc
nnoremap <leader>ev :edit $MYVIMRC<CR> " Edit vimrc
nnoremap <leader>sv :source $MYVIMRC<CR> " Source vimrc
" =============================================================================
" Performance Optimizations
" =============================================================================
" Faster redrawing
set ttyfast " Fast terminal
set lazyredraw " Don't redraw during macros
" Optimize for large files
set synmaxcol=200 " Limit syntax highlighting
set regexpengine=1 " Use old regexp engine
" Reduce updatetime for better experience
set updatetime=250 " Faster completion
" =============================================================================
" Final Configurations and Cleanup
" =============================================================================
" Auto-create required directories on startup
augroup auto_mkdir
autocmd!
autocmd BufNewFile * call mkdir(fnamemodify(expand('<afile>'), ':h'), 'p')
augroup END
" Remember cursor position
augroup remember_cursor
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
" =============================================================================
" End of Configuration
" =============================================================================
" IDV's Vim Configuration - Loaded Successfully!
" For support: https://github.com/idvoretskyi/vim_idv