-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_vimrc
339 lines (262 loc) · 9.63 KB
/
dot_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
source $HOME/.config/vim/settings/plugins.vim
source $HOME/.config/vim/settings/configs.vim
source $HOME/.config/vim/settings/functions.vim
source $HOME/.config/vim/settings/mappings.vim
set guifont=Berkeley\ Mono:h14
" All the plugins are managed via vim-plug, run :PlugInstall to install all
" the plugins from Github, :PlugUpdate to update. Leader key is the spacebar.
"
" What function keys do (also see: Custom commands, Leader shortcuts):
" F5: toggle Mundo window.
" => Pre-load ------------------------------------------------------------- {{{1
" Enable syntax highlighting.
syntax on
" Enable file type based options.
filetype plugin indent on
" Download and install vim-plug (cross platform).
if empty(glob(
\ '$HOME/' . (has('win32') ? 'vimfiles' : '.vim') . '/autoload/plug.vim'))
execute '!curl -fLo ' .
\ (has('win32') ? '\%USERPROFILE\%/vimfiles' : '$HOME/.vim') .
\ '/autoload/plug.vim --create-dirs ' .
\ 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" => Sane defaults (from Neovim) ------------------------------------------ {{{1
set autoindent
set autoread
set backspace=indent,eol,start
set belloff=all
set complete-=i
set display=lastline
set formatoptions=tcqj
set history=10000
set incsearch
set laststatus=2
set nocompatible
set ruler
set sessionoptions-=options
set showcmd
set sidescroll=1
set smarttab
set ttimeoutlen=50
set ttyfast
set viminfo+=!
set wildmenu
" => vim-plug plugins ----------------------------------------------------- {{{1
let g:plug_timeout = 300 " Increase vim-plug timeout
call plug#begin()
Plug 'junegunn/vim-plug' " Need it for helpers download
Plug 'tpope/vim-fugitive' " Git integration
Plug 'tpope/vim-vinegar' " - to open netrw
Plug 'vim-airline/vim-airline' " powerline
Plug 'Lokaltog/vim-easymotion' " better move commands
Plug 'christoomey/vim-tmux-navigator' " better tmux integration
Plug 'ervandew/supertab' " more powerful <tab>
Plug 'junegunn/goyo.vim', {'on': 'Goyo'} " distraction-free writing
Plug 'justinmk/vim-dirvish' " less buggy netrw alternative
Plug 'preservim/nerdtree', {'on': 'NERDTreeToggle'}
Plug 'leafgarland/typescript-vim' " typescript syntax
Plug 'mileszs/ack.vim', {'on': 'Ack'} " ack integration
Plug 'simnalamburt/vim-mundo' " visualize the undo tree
Plug 'tomtom/tcomment_vim' " commenting helpers
Plug 'tpope/vim-abolish' " change case on the fly
Plug 'tpope/vim-repeat' " repeat everything
Plug 'tpope/vim-surround' " better surround commands
Plug 'tpope/vim-unimpaired' " pairs of helpful commands
Plug 'vimwiki/vimwiki' " personal wiki
Plug 'dense-analysis/ale', {'for': ['python']} " async syntax checke
Plug 'ctrlpvim/ctrlp.vim' " Ctrl+p to fuzzy search
Plug 'junegunn/fzf', {'do': {->fzf#install()}}
Plug 'junegunn/fzf.vim'
Plug 'vim-scripts/ScrollColors' " colorscheme scroller
Plug 'Zabanaa/neuromancer.vim' " colorscheme
Plug 'NLKNguyen/papercolor-theme' " colorscheme
Plug 'vim-scripts/Spacegray.vim' " colorscheme
Plug 'altercation/vim-colors-solarized' " colorscheme
Plug 'squarefrog/tomorrow-night.vim' " colorscheme
call plug#end()
" => Editing -------------------------------------------------------------- {{{1
" Global indentation settings.
set expandtab
set shiftwidth=2
set softtabstop=2
set tabstop=2
autocmd filetype python set expandtab " Expand tabs to spaces. Essential in Python.
autocmd filetype python set tabstop=4 " Number of spaces tab is counted for.
autocmd filetype python set shiftwidth=4 " Number of spaces to use for autoindent.
" Disable backups and .swp files.
set nobackup
set noswapfile
set nowritebackup
" Semicolon is too long to type.
nnoremap ; :
vnoremap ; :
" Map leader key.
let mapleader = "\<Space>"
" Use system clipboard.
set clipboard=unnamed,unnamedplus
" Enable wild menu (tab command autocompletion).
set wildmode=list:longest,full
" Don't complain about unsaved files when switching buffers.
set hidden
" Enable persistent undo.
" set undofile
" set undodir=$HOME/.vim/undodir
" Automatically change the working directory for the current file.
" set autochdir
" => Looks ---------------------------------------------------------------- {{{1
set background=dark
colorscheme PaperColor
" hi StatusLineTerm ctermbg=24 ctermfg=254 guibg=#004f87 guifg=#e4e4e4
" hi StatusLineTermNC ctermbg=252 ctermfg=238 guibg=#d0d0d0 guifg=#444444
" Shorten press ENTER to continue messages.
set shortmess=atI
" Highlight cursor line.
set cursorline
set cursorcolumn
" Display line numbers if terminal is wide enough.
if &co > 80
set number
endif
" Soft word wrap.
set linebreak
" Make soft line breaks much better looking.
set breakindent
" Pretty soft break character.
let &showbreak = '> '
" => Custom commands ------------------------------------------------------ {{{1
" Command to close current buffer without closing the window.
command! Bd :bp | :sp | :bn | :bd
" => Leader shortcuts ----------------------------------------------------- {{{1
nnoremap <Leader>] <C-]>
nnoremap <Leader>i <C-i>
nnoremap <Leader>o <C-o>
nnoremap <Leader>r :redraw!<cr>
nnoremap <Leader>w :w<cr>
nnoremap <Leader>dd "_dd
nnoremap <Leader>x q:
nnoremap <Leader>h q/
nnoremap <Leader>a :Ack! <C-r><C-w><cr>
nnoremap <leader>p :CtrlP<cr>
nnoremap <leader>b :CtrlPBuffer<cr>
nnoremap <leader>m :CtrlPMRU<cr>
nnoremap <leader>t :CtrlPTag<cr>
nnoremap <leader>n :NERDTreeToggle<cr>
nnoremap <leader>ev :vsplit $MYVIMRC<CR> " Map <leader>ev to edit the .vimrc file
nnoremap <leader>sv :source $MYVIMRC<cr> " Map <leader>sr to source the .vimrc
" => Movement and search -------------------------------------------------- {{{1
" Ignore case when searching.
set ignorecase
set smartcase
" Searching highlights
set hlsearch
" Fast split navigation.
nnoremap <c-j> <c-w><c-j>
nnoremap <c-k> <c-w><c-k>
nnoremap <c-l> <c-w><c-l>
nnoremap <c-h> <c-w><c-h>
tnoremap <c-j> <c-w><c-j>
tnoremap <c-k> <c-w><c-k>
tnoremap <c-l> <c-w><c-l>
tnoremap <c-h> <c-w><c-h>
" Absolute movement for word-wrapped lines.
nnoremap j gj
nnoremap k gk
" Accidentally hitting capital K doesn't open manpages.
nnoremap <s-k> k
" Unable to use stantard cursore only hjkl enjoy
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
" Faster way return to NORMAL mode
inoremap jj <Esc>
inoremap jk <Esc>
inoremap <esc> <nop>
" make . to work with visually selected lines
vnoremap . :normal.<CR>
" Move visual selection
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" Map Ctrl+Q to ":q"
nnoremap <C-q> :q<CR>
" Buffers
nnoremap <S-Left> :bprevious<CR>
nnoremap <S-Right> :bnext<CR>
nnoremap <S-Down> :buffers<CR>
nnoremap <S-Up> :buffer
nnoremap <S-Delete> :bdelete<CR>
" Tabs
" nnoremap <C-t> :tabnew<CR>
nnoremap <C-w> :tabclose<CR>
" nnoremap <C-p> :tabprevious<CR>
" nnoremap <C-n> :tabnew<CR>
" => Misc ----------------------------------------------------------------- {{{1
" Hide terminal windows in active buffer lists (for ]b and [b navigation).
autocmd TerminalOpen * if bufwinnr('') > 0 | setlocal nobuflisted | endif
" Use Unix as the standart file type.
set ffs=unix,dos,mac
" Fold using {{{n, where n is fold level
set foldmethod=marker
" set foldlevel=3
autocmd filetype python set foldmethod=indent
" highlight trailing whitespace
match ErrorMsg '\s\+$'
" remove trailing whitespaces automatically
autocmd BufWritePre * :%s/\s\+$//e
" => Fixes and hacks ------------------------------------------------------ {{{1
" Increase lower status bar height in diff mode.
if &diff
set cmdheight=2
endif
" Fix easymotion target colors in a PaperColor theme.
if g:colors_name ==# 'PaperColor'
hi EasyMotionTarget2First ctermbg=none ctermfg=red
hi EasyMotionTarget2Second ctermbg=none ctermfg=red
endif
" Disable line numbers in terminal.
au CursorMoved * if &buftype == 'terminal' | set nonumber | endif
" Open all folds when entering Vim.
set nofoldenable
" Don't wrap lines (to fix the way shortened URLs are displayed).
autocmd FileType vimwiki set nowrap
autocmd FileType python setlocal nowrap
autocmd FileType html setlocal nowrap
" => Abbreviations ------------------------------------------------------ {{{1
function! InsertIPD()
return "import ipdb; ipdb.set_trace()"
endfunction
function! InsertIPT()
return "{% load djcore_tags %}{{ __placeholder__|ipdb }}"
endfunction
" Insert mapping
inoremap ipd <C-R>=InsertIPD()<CR>
inoremap ipt <C-R>=InsertIPT()<CR>
" => Plugins configuration ------------------------------------------------ {{{1
" Load all plugins.
packloadall
" Load help files for all plugins.
silent! helptags ALL
" nerdtree
let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
let NERDTreeShowBookmarks=1 " Display bookmarks on startup.
let NERDTreeHijackNetrw=0
let g:NERDTreeFileLines = 1
" CtrlP
let g:ctrlp_working_path_mode = 'ra' " Set CtrlP working directory to a repository root
" fzf
let $FZF_DEFAULT_COMMAND = 'list_all_files'
nnoremap <c-p> :FZF<cr>
set grepprg=rg\ --vimgrep\ --smart-case\ --follow
" vim-test
let test#strategy = "dispatch"
" ack -> ag
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endi
" :Far -> ag
let g:far#source = 'ag'
" Mundo
let g:gundo_preview_bottom = 1
nnoremap <F5> :MundoToggle<cr>