-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
385 lines (307 loc) · 13 KB
/
vimrc
File metadata and controls
385 lines (307 loc) · 13 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
" =================================================================================================
" CTRL-FREAKZ .vimrc file
" -------------------------------------------------------------------------------------------------
" Moar optimize
" =================================================================================================
set nocompatible " Disable legacy mode
filetype on " Must set to on before turning off
filetype off
" Vundle
set rtp+=~/.vim/bundle/Vundle.vim " set Vundle runtime path
call vundle#begin() " begin Vundle
if filereadable(expand("~/.vimrc.bundles")) " include Vundle plugin files
source ~/.vimrc.bundles
source ~/.vimrc.bundles.local
endif
call vundle#end() " end Vundle
" Settings
syntax on " turn on syntax highlighting
filetype plugin indent on " determine syntax via filetype and more
let mapleader="," " change to easier mapleader
" Spelling " does this belong here? or in .local
set spell spelllang=en_us
setlocal spell spelllang=en_us
" Toggle spelling with the F7 key (should this move?)
nn <F7> :setlocal spell! spelllang=en_us<CR>
" Formatting
set number " line numbers
set numberwidth=5 " width of line number column
set autoindent " tabs are fixed width
set nocursorcolumn " hides vertical highlight (cross-hair)
set cursorline " highlights cursor line
set encoding=utf-8 " file encoding
set title " Show the filename in the window title bar
set shortmess=atI " hide intro
set report=0 " show messages
" Tabs
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set tabstop=2 " length of tabs
set shiftwidth=2 " length of auto tabs (inside code block)
set softtabstop=2 " length of tabs in insert mode
set shiftround " round tabs to multiples of shiftwidth
set expandtab " currently being overridden
" inoremap <S-Tab> <C-V><Tab><CR> this isnt working, cant toggle hard and soft tabs
" Wrapping
set nowrap " should we make shortcut to toggle?
set linebreak " if wrap is on, only add a line break manually
set textwidth=200 " columns for text wrap
" Buffer options
set ruler " coordinates bottom right
set list " display whitespace
set listchars=tab:\ ·,trail:· " characters to represent spaces and tabs
set fillchars=vert:\ " empty is nicer on our term " define character to use for buffer separators
set showbreak=↪ " character to represent line break
set splitbelow " open new buffer below instead of above
set splitright " open new vert buffer on right
set laststatus=2 " always show status line
" Improve performance
set lazyredraw " only redraw when necessary
set showmatch " jump cursor to matching brace when you close a block
set matchtime=3 " defined match hop in tenths of a second
" Search
set hlsearch " highlight search term matches
set incsearch " turn incremental searching on
set ignorecase " ignore case when searching
set smartcase " only watch case if including an uppercase letter
" Autocomplete
set completeopt=longest,menuone " display autocomplete as an optionlist like IDEs
set omnifunc=syntaxcomplete#Complete " turn on omnicompletion
set clipboard+=unnamed " share your clipboard with system
set mouse=a " allow mouse use
set modeline " allow to change expandtab within a file
set modelines=10 " set range for beginning or end of file for modeline
set shell=/bin/zsh " set shell
" Tabs
set wildmode=list:longest,list:full " Tab completion
set wildignore+=*.o,*.out,*.obj,.git,*.rbc,*.class,.svn,*.gem
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz
set wildignore+=*/vendor/gems/*,*/vendor/cache/*,*/.bundle/*,*/.sass-cache/*,*/nimcache/*
set wildignore+=*.swp,*~,._*
" History / File handling
set history=999 " increase history (default = 20)
set undolevels=999 " moar undo (default=100)
set autoread " reload files if changed externally
" set autowrite " auto save on buffer switch (risky?)
set showcmd " show (partial) command in the status line"
set showmode " show what mode you are in (Normal/Insert/Visual)
set backupdir=~/.vim/tmp/backup/ " where to put backup files.
set directory=~/.vim/tmp/swap/ " where to put swap files.
set backupskip=/tmp/*,/private/tmp/* " allow Vim to edit crontab files
set nobackup " disable backups
set noswapfile " disable swap files
" Avoid formatting bullets
set fo+=tcqlnr
" set fo-=r
" set fo-=o
set flp=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+
if exists("&undodir") " persistent undo
set undodir=~/.vim/undo/
set undofile
endif
set nostartofline " Don’t reset cursor to start of line when moving around.
set esckeys " Allow cursor keys in insert mode
set ttyfast " Optimize for fast terminal connections
set isk+=_,$,@,%,#,- " none word dividers
if exists("&cryptmethod")
set cryptmethod=blowfish " https://coderwall.com/p/hypjbg
endif
" Time out on key codes but not mappings.
" Basically this makes terminal Vim work sanely.
set notimeout
set ttimeout
set ttimeoutlen=10
" Write better
if exists("&cc")
set cc=100
endif
" In case we use molokay
let g:rehash256 = 1
" Set colors
set background=dark
colorscheme onedark
" Add a more detailed theme for airline
let g:airline_theme = 'tomorrow'
" Use Powerline fonts
let g:airline_powerline_fonts = 1
" Disable markdown floading
let g:vim_markdown_folding_disabled=1
" Verical bar in insert mode (for iTerm users only)
if has("nvim")
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
" Save when losing focus
au FocusLost * :silent! wall
" When we open a new session let's change the path
au VimEnter * cd %:p:h
" Resize splits when the window is resized
au VimResized * :wincmd =
" Set current chdir
au VimEnter * silent! cd %:p:h
" Smart indent
let delimitMate_expand_cr = 1
let delimitMate_expand_space = 1
" Set the snippets for golang
let g:go_snippet_engine = "ultisnips"
let g:go_fmt_command = "goimports"
" Play nice with YCM
" let g:UltiSnipsJumpForwardTrigger="<tab>"
" let g:UltiSnipsListSnippets="<c-e>"
"
let g:ycm_server_python_interpreter = '/usr/local/bin/python'
" Use AG
let g:ackprg = 'ag --nogroup --nocolor --column'
" au FileType * set expandtab " others not ///// LOOK AT THIS
" au FileType make set noexpandtab
" Thorfile, Rakefile, GuardFile, Vagrantfile and Gemfile are Ruby
au BufRead,BufNewFile {Gemfile,Rakefile,Guardfile,Vagrantfile,Thorfile,Do,dorc,Dofile,config.ru} set ft=ruby
" Auto source when we change vimrc
" au BufWritePost {vimrc,.vimrc,.gvimrc,.nvim,.nvimrc} source %
" Add json syntax highlighting
au BufNewFile,BufRead *.json set ft=javascript
" Special settings for common languages
au Filetype * set noexpandtab
au FileType python set softtabstop=4 tabstop=4 shiftwidth=4 textwidth=100 expandtab
au FileType {ruby,yaml} set softtabstop=2 tabstop=2 shiftwidth=2 textwidth=100 expandtab
" Iced coffee
autocmd BufNewFile,BufRead *.iced set filetype=coffee
syn match coffeeKeyword /\<\%(await\|defer\)\>/ display
" Git commits
au Filetype gitcommit setlocal spell textwidth=72
au BufRead,BufNewFile GHI_* set ft=gitcommit
" remember last location in file, but not for commit messages.
au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g`\"" | endif
au BufRead,BufNewFile *.wisp set ft=clojure
" Make sh a bit happier
let g:is_bash=1
" Vitality
let g:always_assume_iterm = 0
let g:ale_linters = {
\ 'javascript': ['standard'],
\}
let g:ale_sign_column_always = 1
let g:airline#extensions#ale#enabled = 1
" Enable syntastic syntax checking
"let g:syntastic_enable_signs = 1
" Turn off jslint errors by default
" let g:JSLintHighlightErrorLine = 0
" Stop netrw
let g:netrw_silent = 1
let g:netrw_quiet = 1
let g:loaded_netrw = 1
" NERDTree configuration
let NERDTreeQuitOnOpen = 0 " don't collapse NERDTree when a file is opened
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 0
let NERDTreeChDirMode = 0
let NERDTreeIgnore = ['\.pyc$', '\.rbc$', '\~$', '\.iml']
let NERDTreeHijackNetrw = 0
let g:nerdtree_tabs_startup_cd = 0
let g:nerdtree_tabs_open_on_gui_startup = 0
autocmd VimEnter * NERDTree
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
" Select with enter
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<S-tab>"
let g:UltiSnipsExpandTrigger="<nop>"
let g:ulti_expand_or_jump_res = 0
function! <SID>ExpandSnippetOrReturn()
let snippet = UltiSnips#ExpandSnippetOrJump()
if g:ulti_expand_or_jump_res > 0
return snippet
else
return "\<C-Y>"
endif
endfunction
imap <expr> <CR> pumvisible() ? "<C-R>=<SID>ExpandSnippetOrReturn()<CR>" : "<Plug>delimitMateCR"
" imap <expr> <CR> pumvisible() ? "\<c-y>" : "<Plug>delimitMateCR"
" Shortcuts
imap <C-w> <Esc><C-w> " move through windows in insert mode
imap <C-v> <Esc><C-v> " allow block selection in insert mode
" Keep visual mode during indenting
vmap > >gv
vmap < <gv
" Tab movements & creation
map <C-S-Left> gT
map <C-S-Right> gt
imap <C-S-Left> <Esc>gT
imap <C-S-Right> <Esc>gt
" Python
let g:pymode_rope_goto_definition_bind = '<Leader>gt'
let g:pymode_folding = 0
let g:pymode_options_max_line_length = 100
let g:pymode_lint_checkers = ['pyflakes', 'pep8']
let g:pymode_rope_show_doc_bind = '<Leader>gd'
let g:pymode_rope_autoimport_import_after_complete = 1
let g:pymode_rope_organize_imports_bind = '<Leader>is'
" Go
" au FileType go nmap <Leader>gt <Plug>(go-def)
" Terminal
if has('nvim')
let g:terminal_color_256=1
tnoremap <Leader>e <C-\><C-n>
tnoremap <C-S-Left> <C-\><C-n>gT
tnoremap <C-S-Right> <C-\><C-n>gt
tnoremap <C-w>h <C-\><C-n><C-w>h
tnoremap <C-w>j <C-\><C-n><C-w>j
tnoremap <C-w>k <C-\><C-n><C-w>k
tnoremap <C-w>l <C-\><C-n><C-w>l
endif
" nnoremap <C-S-Left> <C-w>h
" nnoremap <C-S-Down> <C-w>j
" nnoremap <C-S-Up> <C-w>k
" nnoremap <C-S-Right> <C-w>l
" Shortcuts
nmap <leader>z :ZoomWin<CR>
nmap <leader>gs :Gstatus<CR>
nmap <leader>gd :Gdiff<CR>
nmap <leader>gp :Git push<CR>
nmap <leader>gc :Git c<CR>
nmap <leader>rr :redraw! \| :NERDTree<CR>
nmap <leader>cc :nohlsearch<CR>
nmap <leader>d :NERDTreeTabsToggle<CR>
nmap <leader>ff :NERDTreeTabsFind<CR>
nmap <leader>tb :TagbarToggle<CR>
nmap <leader>ff ggVG= " format the entire file
nmap <leader>i :set list!<CR> " toggle [i]nvisible characters
nmap <Leader>o :CtrlP<CR>
nmap <Leader>w :w<CR>
nmap <Leader>q :q<CR>
nmap <Leader>wqa :wqa<CR>
nmap <Leader>pu :put<CR>
vmap p "_dP
" CtrlP
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_by_filename = 0
" if executable('fzf')
" let g:ctrlp_use_caching = 0
" let g:ctrlp_user_command = 'cd %s && find . -not \( -name .git -type d -prune \) -type f'
" let g:ctrlp_match_func = { 'match': 'ZFZMatch' }
" function! ZFZMatch(items, str, limit, mmode, ispath, crfile, regex)
" let cmd = 'fzf -f \"'.a:str.'\"'
" return split(system(cmd), "\n")
" endfunction
" endif
let g:jsx_pragma_required = 0
" Clang format
" let g:clang_format#auto_format = 1
" let g:clang_format#style_options = {
" \ 'BasedOnStyle': 'llvm',
" \ 'ColumnLimit': 100,
" \ 'BreakBeforeBraces' : 'Stroustrup',
" \ }
" \ 'AlwaysBreakAfterDefinitionReturnType': 'true',
" Additional mapping for buffer search
map <C-k> :CtrlPBuffer<CR>
imap <C-k> <ESC>:CtrlPBuffer<CR>
map <C-b> :CtrlPBufTag<CR>
imap <C-b> <ESC>:CtrlPBufTag<CR>
" Use :W! to write to a file using sudo if you forgot to 'sudo vim file'
ca W! %!sudo tee > /dev/null %