-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
461 lines (354 loc) · 9.79 KB
/
Copy pathvimrc
File metadata and controls
461 lines (354 loc) · 9.79 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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
" = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
"
" 1 - vim configurations
" 2 - plugins
" 3 - functions
" 4 - plugins config
" 5 - maps
" 6 - sources
" 7 - claude code integration
"
"
"
" by Steven Koch
"
" = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
"
" 1- vim configurations = = = = = = = = = = = = = = = = = = = = = = = =
"
let $tempFile = tempname()
let $ctagTempFile = $tempFile
" echo "Indexing ctags to " . $ctagTempFile
" let output = system("~/.powerVim/ctags/indexed.sh ".$ctagTempFile)
set tags=$ctagTempFile
set nocompatible
filetype off
set autoindent
set backspace=indent,eol,start
set complete-=i
set showmatch
set showmode
set smarttab
set nrformats-=octal
set shiftround
set ttimeout
set ttimeoutlen=50
set incsearch
set laststatus=2
set ruler
set showcmd
set wildmenu
set autoread
set encoding=utf-8
set tabstop=4 shiftwidth=4 expandtab
set listchars=tab:▒░,trail:▓
set list
set number
set hlsearch
set ignorecase
set smartcase
if has('mouse')
set mouse=a
endif
set hidden
set nobackup
set nowritebackup
set noswapfile
set fileformats=unix,dos,mac
set completeopt=menuone,longest,preview
let mapleader = '\'
"highlight ColorColumn ctermbg=DarkGrey
set colorcolumn=80
if has('syntax') && !exists('g:syntax_on')
syntax enable
endif
"set t_Co=256
let &path = getcwd() . '/**'
" files types like:
" au BufNewFile,BufRead *.tag set filetype=javascript " tags is javascript files
"
" vim configurations = = = = = = = = = = = = = = = = = = = = = = = =
"
"
" 2 - plugins = = = = = = = = = = = = = = = = = = = = = = = = = = = =
"
"vundle plugin manager
set rtp+=~/.powerVim/bundle/vundle/
call vundle#begin('~/.powerVim/bundle')
Plugin 'gmarik/vundle'
" -- navigation & files
Plugin 'preservim/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'mileszs/ack.vim'
Plugin 'jremmen/vim-ripgrep'
" -- git
Plugin 'tpope/vim-fugitive'
Plugin 'airblade/vim-gitgutter'
Plugin 'wfxr/minimap.vim'
" -- editing
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-repeat'
Plugin 'mg979/vim-visual-multi'
Plugin 'junegunn/vim-easy-align'
Plugin 'dhruvasagar/vim-table-mode'
" -- ui & statusline
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'Yggdroot/indentLine'
Plugin 'flazz/vim-colorschemes'
Plugin 'reewr/vim-monokai-phoenix'
Plugin 'angamaiton/vim-snazzy'
if executable('ctags')
Plugin 'preservim/tagbar'
endif
" -- linting & formatting
Plugin 'dense-analysis/ale'
Plugin 'prettier/vim-prettier'
" -- language support
Plugin 'fatih/vim-go'
Plugin 'mattn/emmet-vim'
Plugin 'JulesWang/css.vim'
Plugin 'elzr/vim-json'
Plugin 'pangloss/vim-javascript'
Plugin 'honza/vim-snippets'
call vundle#end()
"
" 3 - functions = = = = = = = = = = = = = = = = = = = = = = = = =
"
function! AutoHighlightToggle()
let @/ = ''
if exists('#auto_highlight')
au! auto_highlight
augroup! auto_highlight
setl updatetime=4000
echo 'Highlight current word: off'
return 0
else
augroup auto_highlight
au!
au CursorHold * let @/ = '\V\<'.escape(expand('<cword>'), '\').'\>'
augroup end
setl updatetime=500
echo 'Highlight current word: ON'
return 1
endif
endfunction
command FormatJson :%!python -m json.tool
command FormatPerl :%!perltidy -q<CR>
command ShowSpecialCharacteres :set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
function! s:swap_lines(n1, n2)
let line1 = getline(a:n1)
let line2 = getline(a:n2)
call setline(a:n1, line2)
call setline(a:n2, line1)
endfunction
function! s:swap_up()
let n = line('.')
if n == 1
return
endif
call s:swap_lines(n, n - 1)
exec n - 1
endfunction
function! s:swap_down()
let n = line('.')
if n == line('$')
return
endif
call s:swap_lines(n, n + 1)
exec n + 1
endfunction
"
" functions = = = = = = = = = = = = = = = = = = = = = = = = = = = =
"
"
" 4 - plugins config = = = = = = = = = = = = = = = = = = = = = = = = = = = =
"
" colorscheme monokai-phoenix
" colorscheme molokai_dark
" colorscheme snazzy
" colorscheme southernlights
colorscheme solarized
" colorscheme gotham
" colorscheme flattened_dark
" colorscheme mustang
let g:solarized_termcolors=256
set t_Co=256
set background=dark
highlight Normal ctermbg=NONE
highlight nonText ctermbg=NONE
let g:ale_linters = {'javascript': ['eslint']}
if has('autocmd')
filetype plugin indent on
autocmd VimEnter * NERDTree
autocmd VimEnter * if argc() | wincmd p | endif
endif
" CtrlP
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/node_modules/*
" g:ctrlp_root_markers
" let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_working_path_mode = 2
" vim-airline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#branch#enabled = 1
" let g:airline_theme = 'molokai'
let g:airline_theme = 'solarized'
" let g:airline#extensions#syntastic#enabled = 1
" NERDTree
map <Leader>n <plug>NERDTreeTabsToggle<CR>
let g:nerdtree_tabs_open_on_console_startup = 1
let NERDTreeWinSize = 20
" Tagbar
"let g:tagbar_ctags_bin='/usr/local/bin/ctags' " Proper Ctags locations
let g:tagbar_width=20 " Default is 40, seems too wide
" let g:tagbar_autoclose=1
noremap <silent> <Leader>y :TagbarToggle
"indentLine
let g:indentLine_enabled = 1
let g:indentLine_color_term = 239
set omnifunc=syntaxcomplete#Complete
set completeopt=menuone,menu,longest
" plugins config = = = = = = = = = = = = = = = = = = = = = = = = = = = =
"
"
" 5 - maps = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
"
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
endif
" Find
map <C-f> /
map <Space> :nohlsearch<CR>/
" indend / deindent after selecting the text with (⇧ v), (.) to repeat.
vnoremap > >gv
vnoremap < <gv
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" comment / decomment & normal comment behavior
vmap <C-m> gc
" Cut, Paste, Copy
vmap <C-x> d
vmap <C-v> p
vmap <C-c> y
" Undo, Redo (broken)
nnoremap <C-z> :undo<CR>
inoremap <C-z> <Esc>:undo<CR>
nnoremap <C-h> :tabprevious<CR>
inoremap <C-h> <Esc>:tabprevious<CR>i
nnoremap <C-l> :tabnext<CR>
inoremap <C-l> <Esc>:tabnext<CR>i
nnoremap <C-t> :tabnew<CR>
inoremap <C-t> <Esc>:tabnew<CR>i
nnoremap <C-k> :tabclose<CR>
inoremap <C-k> <Esc>:tabclose<CR>i
" lazy ':'
map , :
" Don't use Ex mode, use Q for formatting
map Q gq
" exit insert mode
inoremap <C-c> <Esc>
map ,, :set paste<CR><ESC>i
nnoremap <Leader>o :set nopaste<CR>
" highlight word under cursor
nnoremap <leader>z :if AutoHighlightToggle()<Bar>set hls<Bar>endif<CR>
" move lines
noremap <silent> <c-s-u> :call <SID>swap_up()<CR>
noremap <silent> <c-s-d> :call <SID>swap_down()<CR>
if has('conceal')
set conceallevel=2 concealcursor=i
endif
" autocomplete quotes (visual and select mode)
xnoremap ' s''<Esc>P<Right>
xnoremap " s""<Esc>P<Right>
xnoremap ` s``<Esc>P<Right>
" open terminal in split
map <C-x> :below terminal<CR>
" \fi enable folding by indent
map <leader>fi :set foldmethod=indent<CR>
" map <leader>p :ctrlp :pwd<CR>
let g:ctrlp_cmd='CtrlP :pwd'
" jump to tag under cursor
nnoremap <leader>w :tag <C-r><C-w><CR>
vnoremap <leader>w :tag <C-r><C-w><CR>
" open ctrl+p with word under cursor
nmap <leader>p :CtrlP<CR><C-\>w
" open buffer list
map <leader>b :CtrlPBuffer<CR>
" commentary
map <leader>c :Commentary<CR>
map <leader>. :CtrlPTag<CR>
" git changemap sidebar
nnoremap <leader>gm :ChangeMapToggle<CR>
" minimap
let g:minimap_width = 10
let g:minimap_auto_start = 1
let g:minimap_git_colors = 1
nnoremap <leader>mm :MinimapToggle<CR>
"
" maps = = = = = = = = = = = = = = = = = = = = = = = = = = = =
"
"
" 6 - sources = = = = = = = = = = = = = = = = = = = = = = = = = = = =
"
if filereadable(expand('~/.vimrc.local'))
source ~/.vimrc.local
endif
if filereadable('.vimrc.local')
source .vimrc.local
endif
" 7 -- ctags --- config
" if filereadable('.ctags/vimrc.ctag')
" source .ctags/vimrc.ctag
" endif
"
" sources = = = = = = = = = = = = = = = = = = = = = = = = = = = =
"
"
" 7 - claude code integration = = = = = = = = = = = = = = = = = = = = =
"
" open claude code in a terminal split
function! ClaudeOpen()
below terminal ++close claude
endfunction
" send visual selection to claude with a prompt
function! ClaudeAsk(prompt) range
let l:lines = getline(a:firstline, a:lastline)
let l:text = join(l:lines, "\n")
let l:tmpfile = tempname()
call writefile(split(l:text, "\n"), l:tmpfile)
let l:file = expand('%:t')
let l:ft = &filetype
execute 'below terminal ++close claude -p "' . a:prompt . ' (from ' . l:file . ', ' . l:ft . '):\n$(cat ' . l:tmpfile . ')"'
endfunction
" send current file to claude for review
function! ClaudeReview()
let l:file = expand('%:p')
execute 'below terminal ++close claude -p "Review this file for bugs, security issues, and improvements: ' . l:file . '"'
endfunction
" ask claude a question in a terminal split
function! ClaudeQuestion()
call inputsave()
let l:question = input('Ask Claude: ')
call inputrestore()
if l:question != ''
execute 'below terminal ++close claude -p "' . l:question . '"'
endif
endfunction
" \cc - open claude code interactive session
nnoremap <Leader>cc :call ClaudeOpen()<CR>
" \cr - review current file
nnoremap <Leader>cr :call ClaudeReview()<CR>
" \cq - ask claude a question
nnoremap <Leader>cq :call ClaudeQuestion()<CR>
" \ca - ask claude about selected code (visual mode)
vnoremap <Leader>ca :call ClaudeAsk("Explain this code")<CR>
" \cf - ask claude to fix selected code (visual mode)
vnoremap <Leader>cf :call ClaudeAsk("Find bugs and suggest fixes for this code")<CR>
" \ct - ask claude to write tests for selected code (visual mode)
vnoremap <Leader>ct :call ClaudeAsk("Write tests for this code")<CR>
"
" claude code = = = = = = = = = = = = = = = = = = = = = = = = = = = =
"