-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
424 lines (331 loc) · 14.9 KB
/
.vimrc
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
set t_Co=256
"colorscheme delek
colorscheme delek
"set spell
syntax enable
set encoding=utf-8
"set laststatus=2
set mouse=a
set mousefocus
set ttymouse=sgr
set sps=best
set nohidden
set backspace=1 " make backspace work like most other apps
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set expandtab " expand tabs to spaces
set cursorline " show a visual line under the cursor's current line
set nocompatible " (cp) use Vim defaults (much better)
set ruler " (ru) show the cursor position at all times
set showcmd " (sc) display an incomplete command in the lower right
set history=500 " (hi) keep x num lines of command history
set number " (nu) show line numbers
set showmatch " (sm) briefly jump to matching bracket when inserting one
set autoindent " (ai) turn on auto-indenting
set copyindent " (ci) when auto-indenting, use the indenting format of the previous line
set tabstop=2 " (ts) width (in spaces) that a <tab> is displayed as
set shiftwidth=2 " (sw) width (in spaces) used in each step of autoindent (aswell as << and >>)
set smarttab " (sta) 'shiftwidth' used in front of a line, but 'tabstop' used otherwise
set textwidth=80 " (tw) number of columns before an automatic line break is inserted (see formatoptions)
set formatoptions=croq " (fo) influences how vim automatically formats text
set backspace=indent,eol,start " (bs) allows backspacing beyond starting point of insert mode, indents and line breaks
set nrformats+=alpha " (nf) adds alpha chars to list that gets incremented/decremented with ^A/^X
set listchars+=tab:>- " (lcs) strings used in 'list' mode to show hidden characters (default=eol:$)
set listchars+=trail:-
set winminheight=0 " (wmh) the minimal height of the window when it's not the current window
set nowrap " allows text to continue off the window (need horizontal scrolling)
set linebreak " (lbr) wrap long lines at a space instead of in the middle of a word
set sidescroll=3 " (ss) the minimal number of columns to scroll horizontally
set listchars+=precedes:< " (lcs) when 'nowrap', character to indicate that line continues off the page
set listchars+=extends:>
set wrapscan " (ws) allows search to wrap to top of document when the bottom has been hit
set incsearch " (is) highlights what you are searching for as you type
set hlsearch " (hls) highlights all instances of the last searched string
set ignorecase " (ic) ignores case in search patterns
set smartcase " (scs) don't ignore case when the search pattern has uppercase
set infercase " (inf) during keyword completion, fix case of new word (when ignore case is on)
"set foldcolumn=3 " (fdc) width of fold column (to see where folds are)
"set foldmethod=syntax " (fdm) creates a fold for every level of indentation
"set foldlevel=99 " (fdl) when file is opened, don't close any folds
"set foldenable " (fen) enables or disables folding
set clipboard=unnamed
let html_use_css = 1 " the ':%TOhtml' command generates html without <font> tags
let g:javascript_plugin_flow = 1
" File Specific Settings
" ------------------------------------------------------------
" augroup ts_ft
" au!
" autocmd BufNewFile,BufRead *.ts,*.tsx set syntax=typescript
" augroup END
au FileType py setlocal expandtab
au FileType ts,tsx setfiletype=typescript
au FileType ts,tsx syntax=typescript
au FileType xhtml,html,htm,php,xml,yaml,yml,js,ts,tsx setlocal tabstop=2
au FileType xhtml,html,htm,php,xml,yaml,yml,js,ts,tsx setlocal shiftwidth=2
au FileType xhtml,html,htm,php,xml,yaml,yml,js,ts,tsx setlocal expandtab " (et) expand tabs to spaces (use :retab to redo entire file)
au FileType xhtml,html,htm,php,xml.yaml,yml,js,ts,tsx setlocal softtabstop=2 " (sts) makes spaces feel like tabs (like deleting)
au FileType c,h,java,js,jsx,ts,tsx setlocal mps+==:; " allow the match pairs operation (%) to work with '=' and ';'
au FileType c,h setlocal cindent " enable the intelligent cindent (cin) feature for the following files
au FileType python,py,java,js,jsx,ts,tsx,yaml,yml setlocal smartindent " enable the smartindenting (si) feature for the following files
au FileType txt setlocal fo+=tn
" before writing to any file, this function call will remove any extra white space at the end of a line
" au! BufWrite,FileWritePre * call RemoveWhiteSpace()
" Abbreviations
" ------------------------------------------------------------
"abbreviate #i #include
"abbreviate #d #define
"abbreviate <a <a href=""></a><left><left><left><left><left>
"abbreviate <i <img src="" /><left><left><left>
"abbreviate l" “”<left><left><left><left><left><left>
"abbreviate r" ”
"abbreviate l' ‘
"abbreviate r' ’
"abbreviate "" ""<left><left><left><left><left>
"abbreviate <? <?php?><left><left>
" Miscellaneous Settings
" ------------------------------------------------------------
" (dict) dictionary used for keyword completion
" to use: while in insertion mode and in the middle of a word, type <ctrl-n> and <ctrl-p>
"set dictionary-=/usr/share/dict/words dictionary+=/usr/share/dict/words
" set complete-=k complete+=k
" set completeopt=longest" Don't select first Omni-completion option
" Old stuff
" ---------------------------------------------------------------
set wildmenu
" set wildmode=full:list:hh=SuperTab('n')
set wildmode=full
set undodir=~/.vim/undo " where to save undo histories
set undofile " Save undo's after file closes
set undolevels=1000 " How many undos
set undoreload=10000 " number of lines to save for undo
let python_highlight_all=1 " enable all Python syntax highlighting features
let g:jsx_ext_required=0 " Js to indent like jsx
let g:tsx_ext_required=0 " Js to indent like jsx
let typescript_highlight_all=1
let javascript_highlight_all=1
" Key Mappings
" ------------------------------------------------------------
" compile maps
nmap <F9> :SCCompile<cr>
nmap <F10> :SCCompileRun<cr>
" remapping movement keys swapping h and i
map i <Up>
map j <Left>
map k <Down>
noremap a i
"Remap esc to qq
imap hh <Esc>
" allows moving between split windows much faster and more intuitive
map <C-J> <C-W>j<C-W>_
map <C-K> <C-W>k<C-W>_
" <F2> applies a rot13 dmca-grade encryption scheme to your file
map <F2> mzggg?G`z<CR> "(seems to be faster than mzggVGg?`z)
" <F3> appends the current date and time after the cursor
map <F3> a<C-R>=strftime("%c")<CR><Esc>
imap <F3> <C-R>=strftime("%c")<CR>
" <F6> sorts a paragraph of numbers using the external 'sort' program
map <F6> {V}k:!sort<CR>
" <F7> toggles hidden characters
map <F7> :set list!<CR>
imap <F7> <ESC>:set list!<CR>a
" <F9> toggles word wrap
map <F9> :set wrap!<CR>
imap <F9> <ESC>:set wrap!<CR>a
" <F8> toggles whether the last searched string is highlighted
map <F8> :set hls!<CR>
imap <F8> <ESC>:set hls!<CR>a
" Functions
" ------------------------------------------------------------
" Renames param1 tags to be param2 tags
function! RenameTag(param1, param2)
:%s/<\(\/\?\)a:param1\(\_s*\)/<\1a:param2\2/gci
endfunction
" Strips the tag defined by the parameter (for html pages)
function! StripTag(TagName)
:%s/a:TagName/hello/gci
":% s/<[^>]\+>//gci
endfunction
" Reverses all the lines in the file (top to bottom)
function! ReverseLines()
:g/^/m0
endfunction
" Removes the ^M character from the end of every line
function! RemoveM()
:%s/^M$//g
endfunction
" Replaces the ^M character with a carraige return native to the system
function! ReplaceM()
:%s/^M/\r/g
endfunction
" Removes superfluous white space from the end of a line
function! RemoveWhiteSpace()
:%s/\s*$//g
:'^
"`.
endfunction
" Command Reference
" ------------------------------------------------------------
" * - searches for word under cursor
" gd - finds definition of variable/function under cursor
" ga - prints the ascii value of character under cursor
" gf - opens file under the cursor (in split view)
" gi - goes to insert mode in the same spot as you last inserted
" ~ - changes case of character
" :r !<cmd> - reads the output of the shell <cmd> into the file
" :% s/hello/A/gc - typical search and replace command
" :% !tidy - runs the code through the 'tidy' program
" :runtime! syntax/2html.vim
" :10,40TOhtml
" command reference -> " za : fold toggle toggles between a fold being opened and closed (zA does it recursively)
" " zc : fold close close 1 fold under the cursor (zC does it recursively)
" zo : fold open open 1 fold under the cursor (zO does it recursively)
" zm : fold more increases foldlevel by 1 (zM opens all folds)
" zr : fold reduce decreses foldlevel by 1 (zR closes all folds)
" :retab - when expandtab is set, replace all tabs in the file with the # of spaces defined in 'shiftwidth'
" :retab! - when expandtab is not set, replace the number of spaces in 'shiftwidth' with a tab
" if has("cscope")
" set csprg=/usr/bin/cscope
" set csto=0
" set cst
" set nocsverb
" " add any database in current directory
" if filereadable("cscope.out")
" cs add cscope.out
" " else add database pointed to by environment
" elseif $CSCOPE_DB !=
" cs add $CSCOPE_DB
" endif
" set csverb
"
" " 's' symbol: find all references to the token under cursor
" " 'g' global: find global definition(s) of the token under cursor
" " 'c' calls: find all calls to the function name under cursor
" " 't' text: find all instances of the text under cursor
" " 'e' egrep: egrep search for the word under cursor
" " 'f' file: open the filename under cursor
" " 'i' includes: find files that include the filename under cursor
" " 'd' called: find functions that function under cursor calls
" nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
" nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
" nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
" nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
" nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
" nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
" nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
" nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
" endif
" Plugin Settings
" ------------------------------------------------------------
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
let &runtimepath.=',~/.vim/bundle'
call vundle#begin()
call vundle#rc()
"let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'w0rp/ale'
Plugin 'mxw/vim-jsx'
Plugin 'majutsushi/tagbar'
Plugin 'scrooloose/nerdTree'
Plugin 'tpope/vim-fugitive'
Plugin 'sjl/gundo.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'rizzatti/dash.vim'
Plugin 'szw/vim-g.git'
Plugin 'pangloss/vim-javascript'
Plugin 'davidhalter/jedi-vim'
Plugin 'ervandew/supertab'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'Shougo/deoplete.nvim'
Plugin 'roxma/nvim-yarp'
" Plugin 'roxma/vim-hug-neovim-rpc'
Plugin 'leafgarland/typescript-vim'
Plugin 'Quramy/vim-js-pretty-template'
Plugin 'jason0x43/vim-js-indent'
Plugin 'Quramy/vim-dtsm'
Plugin 'mhartington/vim-typings'
Plugin 'HerringtonDarkholme/yats.vim'
Plugin 'Shougo/vimproc.vim'
let g:deoplete#enable_at_startup = 1
" ALE Linter
let g:ale_enabled=1
let g:ale_sign_column_always=1
let g:ale_javascript_eslint_use_global=1
let g:ale_typescript_tslint_use_global=1
let g:ale_linters={'javascript': ['eslint', 'prettier-eslint', 'standard'], 'python': ['pylint', 'flake8'], 'typescript': ['tslint']}
"let g:ale_fixers={'javascript': ['eslint', 'prettier-eslint', 'standard'], 'python': ['pylint', 'flake8'], 'typescript': ['tslint']}
"let g:ale_fixers={'javascript': ['DoSomething', 'eslint', {buffer, lines -> filter(lines, 'v:val !=~ ''^\s*//''')}]}
let g:ale_fixers={'ts': ['tslint', 'save_file']}
""" Moving Around/Editing
"autocmd VimEnter * Tagbar
" Start NerdTree
autocmd VimEnter * NERDTree
" Move to next window (right) from NerdTree
autocmd VimEnter * wincmd l
let g:NERDTreeMapOpenInTab='<2-LeftMouse>'
function! NERDTreeQuit()
redir => buffersoutput
silent buffers
redir END
" 1BufNo 2Mods. 3File 4LineNo
let pattern = '^\s*\(\d\+\)\(.....\) "\(.*\)"\s\+line \(\d\+\)$'
let windowfound = 0
for bline in split(buffersoutput, "\n")
let m = matchlist(bline, pattern)
if (len(m) > 0)
if (m[2] =~ '..a..')
let windowfound = 1
endif
endif
endfor
if (!windowfound)
quitall
endif
endfunction
autocmd WinEnter * call NERDTreeQuit()
" Pathogen load
call pathogen#infect()
call pathogen#helptags()
let g:airline_powerline_fonts = 1
" Airline plugin"
" Enable the list of buffers
"
let g:airline#extensions#tabline#enabled = 1
"let g:airline_detect_spell=1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'default'
let g:airline#extensions#tabline#fnamemod=':t'
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#branch#enabled = 1
let g:airline_detect_modified = 1
"let g:airline#extensions#branch#empty_message = 'NOT IN REPO'
let g:airline#extensions#branch#use_vcscommand = 1
let g:airline#extensions#tabline#keymap_ignored_filetypes = ['vimfiler', 'nerdtree']
"let g:airline_theme='kolor'
"let g:airline_theme='violet'
"let g:airline_theme='biogoo'
"let g:airline_theme='behelit'
let g:airline_theme_patch_func = 'AirlineThemePatch'
function! AirlineThemePatch(palette)
if g:airline_theme == 'behelit'
for colors in values(a:palette.inactive)
let colors[3] = 245
endfor
endif
endfunction
let g:airline_symbols_ascii = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_buffers = 1
"let g:airline_theme = 'solarized'
" YouCompleteMe
let g:ycm_autoclose_preview_window_after_completion=1
let g:ycm_global_ycm_extra_conf = "~/.vim/.ycm_extra_conf.py"
let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/.ycm_extra_conf.py"
noremap <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
"let g:yats_host_keyword = 1
call vundle#end()