-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc.symlink
394 lines (316 loc) · 9.32 KB
/
vimrc.symlink
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
set nocompatible
filetype off
call plug#begin('~/.local/share/nvim/plugged/')
Plug 'editorconfig/editorconfig-vim'
Plug 'jparise/vim-graphql'
Plug 'pearofducks/ansible-vim'
Plug 'cespare/vim-toml'
Plug 'NLKNguyen/papercolor-theme'
Plug 'elixir-editors/vim-elixir'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'pappasam/coc-jedi', { 'do': 'yarn install --frozen-lockfile && yarn build' }
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Search
" Plug 'rking/ag.vim'
Plug 'mhinz/vim-grepper'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'majutsushi/tagbar'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-jdaddy'
Plug 'tpope/vim-commentary'
Plug 'altercation/vim-colors-solarized'
Plug 'scrooloose/nerdtree'
Plug 'bling/vim-airline'
Plug 'fatih/vim-go'
Plug 'airblade/vim-gitgutter'
Plug 'jwalton512/vim-blade'
Plug 'godlygeek/tabular'
Plug 'mattn/emmet-vim'
Plug 'mattn/webapi-vim'
Plug 'mattn/gist-vim'
Plug 'tobyS/Vmustache'
Plug 'tobyS/pdv'
Plug 'vim-scripts/Mark--Karkat'
Plug 'pangloss/vim-javascript'
Plug 'bumaociyuan/vim-swift'
Plug 'ervandew/supertab'
Plug 'spf13/vim-autoclose'
Plug 'martinda/Jenkinsfile-vim-syntax'
Plug 'Glench/Vim-Jinja2-Syntax'
Plug 'hashivim/vim-terraform'
Plug 'posva/vim-vue'
Plug 'tpope/vim-obsession'
Plug 'plasticboy/vim-markdown'
Plug 'flazz/vim-colorschemes'
call plug#end()
" {{{
map <C-p> :FZF<enter>
let g:fzf_tags_command = 'ctags -R'
" open fzf filtering ctags on the current directory
" nnoremap <leader>g :call fzf#vim#tags(expand('<cword>'), {'options': '--exact --select-1 --exit-0'})<CR>
" }}}
" Grepper
nnoremap <leader>g :Grepper -tool rg<cr>
nnoremap <leader>G :Grepper -tool rg -buffers<cr>
let g:grepper = {}
let g:grepper.tools = ['rg', 'ag', 'git']
let g:grepper.highlight = 1
let g:grepper.simple_prompt = 1
let g:grepper.prompt_mapping_tool = '<leader>g'
command! Todo :Grepper -tool git -query '\(TODO\|FIXME\)'
" zfz
nnoremap <leader>b :Buffers<CR>
" tagbar
map <leader>o :TagbarToggle<cr>
let g:tagbar_compact = 1
let g:tagbar_indent = 1
" {{{
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_new_list_item_indent = 0
let g:vim_markdown_auto_insert_bullets = 1
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_no_extensions_in_markdown = 1
let g:vim_markdown_follow_anchor = 1
let g:vim_markdown_strikethrough = 1
let g:vim_markdown_autowrite = 1
" }}}
" color schemes
let g:airline_powerline_fonts = 0
let g:airline#extensions#tabline#enabled = 1
" This fixes small delay on terminal when using capital O
" ====================================
" general editor options
" ====================================
syntax on
set nu
let mapleader=','
set ttimeoutlen=50
set modeline
set noswapfile
set laststatus=2
set relativenumber
set pastetoggle=<F3>
if has('clipboard')
if has('unnamedplus') " When possible use + register for copy-paste
set clipboard=unnamed,unnamedplus
else " On mac and Windows, use * register for copy-paste
set clipboard=unnamed
endif
endif
set hidden
set foldmethod=marker
set foldlevel=99
set encoding=utf-8
set diffopt+=vertical
" search
set ignorecase
set smartcase
set incsearch
set hls
set gdefault "default to globl search & replace
set wildmode=longest,list
set showmatch
set showcmd
set shortmess=at
set synmaxcol=800 " don't try to highlight lines longer than 800 characters
set scrolloff=3
set wildignore=*.o,*.obj,*.swp,*.bak,*.pyc,*~,build,cache,*/sites/default/files,tmp,*.class,*.egg-info,__pycache__,
set wildignore+=*/vendor/**
set wildignore+=*/node_modules/**
" Use Perl's regex on searches
nnoremap / /\v
vnoremap / /\v
set nowrap "do not wrap by default
" move to the next editor line for wrapped lines
nnoremap j gj
nnoremap k gk
filetype plugin indent on
" fix for vim setting ft=modula2 on *.md files
au BufNewFile,BufReadPost *.md setl ft=markdown tw=80
"}}}
" look and feel {{{
let g:solarized_termcolors=256
set t_Co=256
colorscheme PaperColor
set background=light
" Allow to trigger background
function! ToggleBG()
let s:tbg = &background
" Inversion
if s:tbg == "dark"
set background=light
else
set background=dark
endif
endfunction
" noremap <leader>bg :call ToggleBG()<CR>
set cursorline
""set listchars=tab:▸\ ,eol:¬,trail:·
set list
set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
"
"set nonu
"map <leader>b :set nu!<CR>
set title " show filename in titlebar / terminal
" }}}
" general editing tweaks {{{
set backspace=indent,eol,start " allow backspacing over autoindent, linke breaks and start of insert
set nowrap
set autoindent
" default indentation is two spaces
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
" }
" auto-completion {{{
set completeopt=menuone,preview
" }}}
" helpful leader shortcuts {{{
map <leader>q :q<cr>
map <leader>d :bd<cr>
" map <leader>ca :1,300bd<cr> " conflicts with find conflict mapping
"" NERDTree mappings {{{
map <leader>f :NERDTree<cr>
map <leader>x :NERDTreeFind<cr>
let NERDTreeIgnore = ['\.pyc$', 'venv', '__pycache__']
let NERDTreeQuitOnOpen=0
"" }} NERDTree mappings
map <leader><space> :noh<cr>
map <leader>l :set list!<cr>
map <leader>s :%:<C-R><C-W>:
vmap <leader>s :%s:<C-R><C-W>:
" from vimcasts.org/e/14
" edit file taking the path to the current active buffer into account.
map <leader>ew :e <C-R>=expand("%:p:h") . "/" <CR>
map <leader>es :sp <C-R>=expand("%:p:h") . "/" <CR>
map <leader>ev :vsp <C-R>=expand("%:p:h") . "/" <CR>
map <leader>et :tabe <C-R>=expand("%:p:h") . "/" <CR>
" }}}
" other mappings {{{
" use Q to format paragraph
vmap Q gq
nmap Q gqap
" }}}
nnoremap Y y$
" Adjust viewports to the same size
map <Leader>= <C-w>=
" Find merge conflict markers
map <leader>c /\v^[<\|=>]{7}( .*\|$)<CR>
"autocmd vimenter * if !argc() | NERDTree | endif
autocmd BufNewFile,BufRead,BufEnter TODO.md setf todo
" Resize splits when the window is resized
au VimResized * :wincmd =
" Cursorline {{{
" Only show cursorline in the current window and in normal mode.
augroup cline
au!
au WinLeave,InsertEnter * set nocursorline
au WinEnter,InsertLeave * set cursorline
augroup END
" }}}
" Trailing whitespace {{{
" Only shown when not in insert mode so I don't go insane.
augroup trailing
au!
au InsertEnter * :set listchars-=trail:⌴
augroup END
" }}}
" Fuck you, help key.
noremap <F1> <nop>
inoremap <F1> <nop>
" Clean trailing whitespace
nnoremap <leader>w mz:%s/\s\+$//<cr>:let @/=''<cr>`z
" Marks and Quotes
noremap ' `
" Select (charwise) the contents of the current line, excluding indentation.
" Great for pasting Python lines into REPLs.
nnoremap vv ^vg_
" Sudo to write
cnoremap w!! w !sudo tee % >/dev/null
" Don't move on *
"nnoremap * *<c-o>
" Easy buffer navigation
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
noremap <leader>v <C-w>v
noremap <leader>t :tabnew<CR>
" Keep search matches in the middle of the window.
nnoremap n nzzzv
nnoremap N Nzzzv
" Same when jumping around
nnoremap g; g;zz
nnoremap g, g,zz
nnoremap <c-o> <c-o>zz
" Re-select last pasted text
nnoremap gp `[v`]
set tags=./tags;/,~/.vimtags
set lazyredraw
set ttyfast
" More natural split behavior
"set splitbelow
set splitright
if exists('$TMUX')
function! TmuxOrSplitSwitch(wincmd, tmuxdir)
let previous_winnr = winnr()
silent! execute "wincmd " . a:wincmd
if previous_winnr == winnr()
call system("tmux select-pane -" . a:tmuxdir)
redraw!
endif
endfunction
let previous_title = substitute(system("tmux display-message -p '#{pane_title}'"), '\n', '', '')
let &t_ti = "\<Esc>]2;vim\<Esc>\\" . &t_ti
let &t_te = "\<Esc>]2;". previous_title . "\<Esc>\\" . &t_te
nnoremap <silent> <C-h> :call TmuxOrSplitSwitch('h', 'L')<cr>
nnoremap <silent> <C-j> :call TmuxOrSplitSwitch('j', 'D')<cr>
nnoremap <silent> <C-k> :call TmuxOrSplitSwitch('k', 'U')<cr>
nnoremap <silent> <C-l> :call TmuxOrSplitSwitch('l', 'R')<cr>
else
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
endif
map <S-H> gT
map <S-L> gt
" Tabular.vim leader mappings
nmap <leader>a= :Tabularize /=<CR>
vmap <leader>a= :Tabularize /=<CR>
nmap <leader>a: :Tabularize /:\zs<CR>
vmap <leader>a: :Tabularize /:\zs<CR>
let g:UltiSnipsEditSplit = 'vertical'
nmap <F4> :Gst<CR>
imap jj <Esc>
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_python_flake8_args = "--ignore=E501"
" make YCM compatible with UltiSnips (using supertab)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'
" " better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
" URL encode/decode selection
vnoremap <leader>en :!python -c 'import sys,urllib;print urllib.quote(sys.stdin.read().strip())'<cr>
vnoremap <leader>de :!python -c 'import sys,urllib;print urllib.unquote(sys.stdin.read().strip())'<cr>
" prettify JSON on current buffer
nmap <leader>jt <Esc>:%!python -m json.tool<CR><Esc>:set filetype=json<CR>
augroup autosourcing
autocmd!
autocmd BufWritePost .vimrc source %
augroup END
" vim:fdm=marker: