-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
281 lines (234 loc) · 7.52 KB
/
.vimrc
File metadata and controls
281 lines (234 loc) · 7.52 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
" Add path to powerline
set rtp+=/usr/local/lib/python2.7/site-packages/powerline/bindings/vim/
" Disable bundles by adding full path to bundle
let g:pathogen_blacklist=[]
filetype off
execute pathogen#infect()
call pathogen#helptags()
" Vertical Split: Ctrl+w + v
" Horizontal Split: Ctrl+w + s
" Close current windows: Ctrl+w + q
" Change cursor by mode for iterm2
highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
"let &t_SR = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
"let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
augroup cursor
autocmd!
:autocmd InsertEnter * set cul
:autocmd InsertLeave * set nocul
augroup END
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
" Tab mappings
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
set backspace=2
set clipboard=unnamed
map <leader>td <Plug>TaskList
map <leader>g :GundoToggle<CR>
map <C-n> :NERDTreeToggle<CR>
map <leader>w :%s/[ \t]\+$//g<CR>g;
map <F8> :TagbarToggle<CR>
nmap <leader>A <Esc>:Ack!
nmap <leader>d :Gvdiff<CR>
nmap <leader>b :Gblame<CR>
nmap <leader>ci :!git add % && git ci<CR>
nmap <leader>s :Gstatus<CR>
nmap <leader>p :Prettier<CR>:w<CR>
nmap <leader>h :vsp \| :Glog -- % <CR><CR> \| :copen<CR>
" Function Keys
" Highlight all search matches
:set hlsearch!
:nnoremap <F5> :set hlsearch!<CR>
" load the background script
call togglebg#map("<F6>")
" In normal mode insert the current datestamp
:nnoremap <F7> "=strftime("%Y-%m-%d %H:%M:%S")<CR>P
" If buffer modified, update any 'LAST modified:' in the first 20 lines.
" 'LAST Modified: 2017-09-02 20:21:58
" " Restores cursor and window position using save_cursor variable.
function! LastModified()
if &modified
let save_cursor = getpos(".")
let n = min([20, line("$")])
keepjumps exe '1,' . n . 's#^\(.\{,10}LAST Modified:\).*#\1' .
\ strftime(' %Y-%m-%d %H:%M:%S') . '#e'
call histdel('search', -1)
call setpos('.', save_cursor)
endif
endfun
augroup lastModified
autocmd!
autocmd BufWritePre * call LastModified()
augroup END
" Highlight duplicate lines in file
function! HighlightRepeats() range
let lineCounts = {}
let lineNum = a:firstline
while lineNum <= a:lastline
let lineText = getline(lineNum)
if lineText != ""
let lineCounts[lineText] = (has_key(lineCounts, lineText) ? lineCounts[lineText] : 0) + 1
endif
let lineNum = lineNum + 1
endwhile
exe 'syn clear Repeat'
for lineText in keys(lineCounts)
if lineCounts[lineText] >= 2
exe 'syn match Repeat "^' . escape(lineText, '".\^$*[]') . '$"'
endif
endfor
endfunction
command! -range=% HighlightRepeats <line1>,<line2>call HighlightRepeats()
command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
function! s:RunShellCommand(cmdline)
let isfirst = 1
let words = []
for word in split(a:cmdline)
if isfirst
let isfirst = 0 " don't change first word (shell command)
else
if word[0] =~ '\v[%#<]'
let word = expand(word)
endif
let word = shellescape(word, 1)
endif
call add(words, word)
endfor
let expanded_cmdline = join(words)
botright new
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
call setline(1, 'You entered: ' . a:cmdline)
call setline(2, 'Expanded to: ' . expanded_cmdline)
call append(line('$'), substitute(getline(2), '.', '=', 'g'))
silent execute '$read !'. expanded_cmdline
1
endfunction
command! -nargs=1 Find :vim /<args>/gj % | :copen
" Map HighlightRepeats function
vn <leader>R :call HighlightRepeats()<CR>
filetype on " try to detect filetypes
filetype plugin indent on " enable loading indent file for filetype
set omnifunc=syntaxcomplete#Complete
" Tern settings
let g:tern_map_keys=1
let g:tern_show_argument_hints="on_hold"
"autocmd Filetype javascript setlocal omnifunc=tern#Complete
" Set FileType
augroup filetypedetect
au! BufRead,BufNewFile *.m,*.oct set filetype=octave
au! BufRead,BufNewFile *.sas set filetype=sas
au! BufRead,BufNewFile *.log set filetype=log
au! BufRead,BufNewFile *.r,*.R set filetype=r
au! BufRead,BufNewFile *.xml,*.xsd set filetype=xml
au! BufRead,BufNewFile *.sql set filetype=sql
au! BufRead,BufNewFile *.py set filetype=python
au! BufRead,BufNewFile *.pl set filetype=perl
au! BufRead,BufNewFile *.js set filetype=javascript
au! BufRead,BufNewFile *.json set filetype=json
au! BufRead,BufNewFile *.tex set filetype=tex
augroup END
syntax on " syntax highlighing
set background=dark
let g:solarized_termcolors=256
colorscheme solarized
:set number
set splitright
" Show current column and row in statusbar
:set ruler
" Set the maximum column width and wrap long lines
:set tw=79
:set wrap
" Highlight background when text goes over 79 chars
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%80v.\+/
" Highlight trailing whitespace
highlight ExtraWhitespace ctermbg=darkgreen guibg=lightgreen
2match ExtraWhitespace /[ \t]\+$/
" Global text settings
set tabstop=4
set shiftwidth=4
set softtabstop=4
set smarttab expandtab autoindent
set foldmethod=indent
set foldlevel=20
" Add Fugitive statusline
set statusline+=%{fugitive#statusline()}
" Set snipMate author
let g:snips_author='Peter Herbert'
let g:SuperTabDefaultCompletionType = "context"
" Remap SuperTab
let g:SuperTabMappingForward = "<M-space>"
let g:SuperTabMappingBackward = "<c-M-space>"
set completeopt=menuone,longest
" Set the maximum number of files for Command-T
let g:CommandTMaxFiles=20000
augroup NERDTree
" Open a NERDTree automatically when vim starts up if no files were specified
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" Close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
augroup END
" Syntastic Settings
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" Enable autoread to reload any files from files when checktime is called and
" the file is changed
set autoread
" Autofix with eslint
function! SyntasticCheckHook(errors)
if !empty(a:errors)
checktime
endif
endfunction
let g:prettier#quickfix_enabled = 0
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
let g:syntastic_loc_list_height = 5
let g:syntastic_echo_current_error = 0
let g:syntastic_cursor_column = 0
" Powerline settings
let g:Powerline_symbols = 'fancy'
set laststatus=2
set showtabline=2
set noshowmode
" YCM settings
let g:ycm_collect_identifiers_from_tags_files = 0
let g:ycm_register_as_syntastic_checker = 0
let g:ycm_show_diagnostics_ui = 0
let g:ycm_use_ultisnips_completer = 0
" disable YCM in some file
let g:ycm_filetype_blacklist = {
\ 'tagbar' : 1,
\ 'nerdtree' : 1,
\}
set tags=./tags,tags,~/.vimtags
let g:easytags_events = ['BufReadPost', 'BufWritePost']
let g:easytags_async = 1
let g:easytags_dynamic_file = 1
let g:easytags_languages = {
\ 'javascript': {
\ 'args': ['-f'],
\ 'cmd': 'jsctags',
\ 'recurse_flag': ''
\ }
\}
" Command mode autocomplete
set wildmenu
set wildmode=longest,list,full
" Ignore
set wildignore+=*/node_modules,*/.git,*/.meteor