-
Notifications
You must be signed in to change notification settings - Fork 14
/
vimrc
306 lines (252 loc) · 8.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
filetype off " required
set nocompatible " be iMproved, required
" Plugin manager: Vim-Plug
" https://github.com/junegunn/vim-plug
call plug#begin('~/.vim/plugged')
" For Grata
" Plug 'prettier/vim-prettier' " Didn't work, I'm using PyLint on ALE now
Plug 'psf/black', { 'branch': 'stable' }
" Navigation
Plug 'scrooloose/nerdtree'
" Plug 'ctrlpvim/ctrlp.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Syntax
" Plug 'scrooloose/syntastic' " Too slow, unbearable
Plug 'dense-analysis/ale' " Linting async
Plug 'nvie/vim-flake8' " python spelling and style checker
Plug 'frazrepo/vim-rainbow'
Plug 'chriskempson/base16-vim'
" Plug 'nathanaelkane/vim-indent-guides'
" Plug 'Vimjas/vim-python-pep8-indent'
Plug 'vim-scripts/indentpython.vim' " Some Py specific fixes of autoindent
Plug 'schickling/vim-bufonly'
Plug 'flazz/vim-colorschemes'
Plug 'Shougo/neocomplete'
Plug 'tmhedberg/matchit' " I think other Plugs use this
" Code helpers
Plug 'Raimondi/delimitMate' " Autocompletion for quotes, brakets, parens
Plug 'tpope/vim-unimpaired'
Plug 'mattn/emmet-vim' " Expand HTML from CSS style expressions with <C-y>,
Plug 'AndrewRadev/tagalong.vim' " Auto-changes matching tags
" Vim enhancement
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim' " Fuzzy finder
Plug 'tmhedberg/SimpylFold'
" Plug 'ycm-core/YouCompleteMe' " Failed install needs go
Plug 'tpope/vim-surround'
Plug 'henrik/vim-indexed-search' " Ads N of M results to searches
Plug 'scrooloose/nerdcommenter'
" Plug 'ervandew/supertab' " Tab for autocompletion
Plug 'vim-scripts/LargeFile' " Disables some feats when editing large files
Plug 'kshenoy/vim-signature' " Marks enhanced
" Git
Plug 'airblade/vim-gitgutter' " Shows git diff +/-/~ besides the line number
Plug 'tpope/vim-fugitive'
call plug#end() " required
" ### General configuration ### "
" let mapleader="," " change the leader from \\ to ,
set clipboard=unnamed
set nojoinspaces " Use only 1 space after . when joining lines instead of 2
set modifiable
set hidden
set wrap linebreak nolist
" Improve vim's scrolling speed
set ttyfast
set ttyscroll=3
set lazyredraw
set splitright " open vertical splits on the right
set splitbelow " open the horizontal split below
" ### Folding ###
"
" Lines with equal indent form a fold.
set foldmethod=indent
set foldlevel=99
set foldnestmax=10
set nofoldenable " Open all folds by default
set foldlevelstart=0
" Enable folding with the spacebar
" nnoremap <space> za
let g:SimpylFold_docstring_preview=1 " docstrings for foldd code
" Auto save and load folding status of files:
augroup remember_folds
autocmd!
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent! loadview
augroup END
set undofile " Save undo's after file closes
set undodir=~/.vim/undo " where to save undo histories
set undolevels=1000 " How many undos
set undoreload=10000 " number of lines to save for undo
set shortmess=at " Avoid the 'Press ENTER or type command to continue' prompt
set t_Co=256 " enable 256-color mode.
syntax enable " enable syntax highlighting (previously syntax on).
set cul " highlight current line
set number " show line numbers
set laststatus=2 " last window always has a statusline
set hlsearch
set incsearch " Do highlight as you type your search.
set ignorecase " Make searches case-insensitive.
set ruler " Always show info along bottom.
set showmatch
set expandtab " Insert spaces whenever TAB is pressed
" set shiftround " always indent/outdent to the nearest tabstop
set mouse=a
set showcmd
set scrolloff=5
set colorcolumn=88
set encoding=utf-8
set textwidth=88
" associate *.jinja templates with HTML for SparkUp Plug
" au BufRead,BufNewFile *.jinja set filetype=html.jinja
"au BufNewFile,BufRead *.jinja set ft=jinja.html
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set autoindent
au BufNewFile,BufRead *.py
\ set tabstop=4 |
\ set shiftwidth=4 |
\ set expandtab |
\ set softtabstop=4 |
\ set autoindent |
\ set fileformat=unix
au BufNewFile,BufRead *.rb,*.coffee,*.js,*.sh
\ set tabstop=2 |
\ set shiftwidth=2 |
\ set softtabstop=2
au BufNewFile,BufRead *.html,*.jinja,*.css,*.scss,*.erb,*.yml
\ set tabstop=2 |
\ set shiftwidth=2 |
\ set softtabstop=2
if exists('$BASE16_THEME')
\ && (!exists('g:colors_name') || g:colors_name != 'base16-$BASE16_THEME')
let base16colorspace=256
colorscheme base16-$BASE16_THEME
endif
" No swap files
set nobackup
set noswapfile
set nowritebackup
" Open new split panes to right and bottom
set splitbelow
set splitright
" Avoid hitting F1 by mistake
:imap <F1> <Esc>
:map <F1> <Esc>
:nmap <F1> <nop>
:inoremap <F1> <C-c>
" Move between windows, so instead of ctrl-w then j, it’s just ctrl-j:
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>
" Move between tabs
nnoremap <C-T> :tabNext<CR>
" Shortcuts for Find files (FZF) and Find IN files (Rg)
" nnoremap <C-G> :Files<CR> " I'm using Ctr+P now
" nnoremap <C-P> :Files<CR> " The one below prevents file from being opened in the
" NERDTree small window
nnoremap <silent> <expr> <C-P> (expand('%') =~ 'NERD_tree' ? "\<c-w>\<c-w>" : '').":Files\<CR>"
nnoremap <C-F> :Rg<CR>
map <Tab> :bn<CR>
map <S-Tab> :bp<CR>
" don't close windows when closing buffers
map :bd :bp<bar>sp<bar>bn<bar>bd
map <Home> ^
imap <Home> <Esc>^i
nnoremap Q <nop> " Avoid accidental EX mode
" C-c send enter in insert mode.
inoremap <C-c> <Esc>
" " Make zO recursively open whatever top level fold we're in
" nnoremap zO zCzO
" # Auto commands # "
autocmd FileType css,scss,less set iskeyword=@,48-57,_,-,?,!,192-255
autocmd FileType ruby setlocal sw=2 ts=2 sts=2
autocmd FileType eruby set iskeyword=@,48-57,_,192-255,$,-
autocmd FileType python setlocal sw=4 ts=4 sts=4
" Make those debugger statements painfully obvious
au BufEnter *.rb syn match error contained "\<binding.pry\>"
au BufEnter *.rb syn match error contained "\<debugger\>"
au BufEnter *.py syn match error contained "\<set_trace\>"
"Insert the line 'import ipdb; ipdb.set_trace'
" noreabbrev __i import ipdb; ipdb.set_trace()
noreabbrev __i import pdb; pdb.set_trace()
" autocmd VimEnter * call StartUp()
" function! StartUp()
" if 0 == argc()
" NERDTree
" end
" endfunction
" Hide files in nerdtree
let NERDTreeIgnore=['\.pyc$', '\~$', 'pycache', 'egg.info']
" Hide files from CTRLP
" set wildignore+=public/system
" set wildignore+=software
" set wildignore+=*.pyc
" set wildignore+=*/tmp/*,*.zip,*/build/*,*/dist/*
" let g:ctrlp_custom_ignore = {
" \ 'dir': '\v[\/]\.(git|build|dist|tmp|anaconda|node_modules)$',
" \ 'file': '\v\.(pyc|ipynb)$',
" \ }
augroup reload_vimrc {
autocmd!
autocmd BufWritePost $MYVIMRC source $MYVIMRC
autocmd BUfWritePost $MYVIMRC :AirlineRefresh
augroup END }
" Remove trailing whitespace on save
autocmd BufWritePre *.rb %s/\s\+$//e
autocmd BufWritePre *.py %s/\s\+$//e
autocmd BufWritePre *.jinja %s/\s\+$//e
autocmd BufWritePre *.yml %s/\s\+$//e
" Run the current file
nnoremap <C-X> :!%:p<CR>
hi Normal guibg=NONE ctermbg=NONE
" # Plugs cutomization # "
" ALE
" let g:ale_linters = {
" \ 'python': ['pylint', 'prettier'],
" \}
" let g:ale_linters_explicit = 1
" let g:ale_fix_on_save = 1
" Navigate ALE errors
nmap <C-n> :ALENextWrap<CR>
nmap <C-m> :ALEPreviousWrap<CR>
let g:ale_python_flake8_options = '--max-line-length=119'
let g:ale_python_pylint_options = '--rcfile '.expand("~/.pylintrc")
" Airline
" ALE linter
let g:airline#extensions#ale#enabled = 1
let g:airline_powerline_fonts=1
" enable/disable fugitive/lawrencium integration >
let g:airline#extensions#branch#enabled = 0
" change the text for when no branch is detected >
let g:airline#extensions#branch#empty_message = ''
" Enable the list of buffers
let g:airline#extensions#tabline#enabled = 1
" Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
" Airline themes that look ok: bubblegum, tomorrow, wombat, molokai,
" powerlineish,
" let g:airline_theme = 'bubblegum'
let g:airline_theme = 'papercolor'
" tmux will only forward escape sequences to the terminal if surrounded by a DCS sequence
" http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\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_EI = "\<Esc>]50;CursorShape=0\x7"
endif
let g:rainbow_active = 1
" Syntastic recommended configuration
" https://github.com/vim-syntastic/syntastic
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
"let g:syntastic_always_populate_loc_list = 1
"let g:syntastic_auto_loc_list = 1
"let g:syntastic_check_on_open = 1
"let g:syntastic_check_on_wq = 0