-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
327 lines (256 loc) · 8.57 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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'ap/vim-css-color'
Plugin 'Shougo/denite.nvim'
Plugin 'scrooloose/nerdtree'
Plugin 'xolox/vim-misc'
Plugin 'majutsushi/tagbar'
Plugin 'ervandew/supertab'
Plugin 'tpope/vim-commentary'
Plugin 'w0rp/ale'
Bundle 'lifepillar/vim-solarized8'
Plugin 'mhinz/vim-signify'
Plugin 'justinmk/vim-sneak'
Plugin 'Shougo/deoplete.nvim'
Plugin 'roxma/nvim-yarp'
Plugin 'roxma/vim-hug-neovim-rpc'
Plugin 'xolox/vim-easytags'
Plugin 'tpope/vim-fugitive'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" Put your non-Plugin stuff after this line
let g:deoplete#enable_at_startup = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Numbering
set nu
" Show trailing whitespace chars
match ErrorMsg '\s\+$'
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7
" A buffer becomes hidden when it is abandoned
set hid
" Don't redraw while executing macros (good performance config)
set lazyredraw
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Show last command (after tpope's vim-sensible)
set showcmd
" Set to auto read when a file is changed from the outside
au FileChangedShell * echo "file changed on disk"
" Remove tabline
set showtabline=1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Searching
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set wildmenu
set wildignore=*.o,*~,*.pyc
set ignorecase
set smartcase
" Perl compatible regex syntax while searching
nnoremap / /\v
vnoremap / /\v
set magic
" Always search globally
set gdefault
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text editing
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set wrap
set textwidth=0
set formatoptions=cq
set wrapmargin=0
" Save on losing focus
au FocusLost * :wa
" Line break setting
setlocal fo+=t
" Set utf8 as standard encoding and en_US as the standard language
" set encoding=utf8
" Use Unix as the standard file type
set ffs=unix,dos,mac
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
set mouse=a
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
" Termtrans=1 to avoid overlap with colors from gnome terminal
" set t_Co=256
let g:solarized_termtrans=1
set background=light
colorscheme solarized8
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set noswapfile
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp " store swap files here
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related (PEP8)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Many settings are from: http://svn.python.org/projects/python/trunk/Misc/Vim/vimrc
" Use PEP8 conform Python style (only spaces)
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
" Also PEP8, but only for Python files; as well as folding
" au BufRead,BufNewFile *.py,*.pyw set textwidth=79 | set foldmethod=indent | set foldlevel=99
" Use the below highlight group when displaying bad whitespace is desired.
highlight BadWhitespace ctermbg=red guibg=red
" Display tabs at the beginning of a line in Python mode as bad.
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
" Make trailing whitespace be flagged as bad.
au BufRead,BufNewFile *.py,*.pyw,*.html,*.php,*.js match BadWhitespace /\s\+$/
" Intendation for web development
autocmd Filetype html setlocal ts=2 sw=2 foldmethod=indent
autocmd Filetype scss,css,sass setlocal ts=2 sw=2
autocmd Filetype javascript setlocal ts=2 sw=2
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs, windows and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Treat long lines as break lines (useful when moving around in them)
map j gj
map k gk
" Open splits below or to the right
set splitbelow
set splitright
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab,newtab
set stal=2
catch
endtry
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Remember info about open buffers on close
set viminfo^=%
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Nerdtree
let NERDTreeChDirMode=2
map <F2> :NERDTreeToggle<CR>
let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim-Sneak
" nmap s <Plug>Sneak_s
let g:sneak#s_next = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Airline setup
let g:airline_powerline_fonts=1
let g:airline_theme='solarized' "or use 'raven'
let g:airline_exclude_preview = 0 "no additional airline in preview windows
" let g:airline#extensions#branch#enabled = 0
" call airline#parts#define_accent('branch', 'red')
" let g:airline#extensions#branch#format = 2
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#excludes = ['term:']
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline_inactive_collapse=0
let g:airline#extensions#tabline#buffer_min_count = 2
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Easytags setup
let g:easytags_auto_highlight = 0
let g:easytags_async = 1
set tags=vimtags;/
let g:easytags_dynamic_files = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Denite setup
" nnoremap <space>s :Unite -quick-match buffer<cr>
nnoremap <space>d :Denite buffer<cr>
nnoremap <space>f :Denite file/rec<cr>
nnoremap <space>a :Denite grep<cr>
nnoremap <leader>f :<C-u>DeniteCursorWord grep:.<CR>
vnoremap <leader>f y:Denite -input=<C-r>" grep<CR>
call denite#custom#map(
\ 'insert',
\ '<Down>',
\ '<denite:move_to_next_line>',
\ 'noremap'
\)
call denite#custom#map(
\ 'insert',
\ '<Up>',
\ '<denite:move_to_previous_line>',
\ 'noremap'
\)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Tagbar setup
nmap <F8> :TagbarToggle<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ale setup
let g:ale_fixers = {
\ 'javascript': ['prettier', 'eslint'],
\ 'python': ['flake8', 'pylint'],
\}
" let g:ale_lint_on_text_changed = 'never'
noremap <C-a> :ALENext<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Mappings for easy buffer switching
noremap gn :bn<cr>
noremap gp :bp<cr>
noremap gd :bd<cr>
noremap gr :b#<cr>
" Turn off highlighting of search hits
map <F3> :nohl <CR>
" Fix syntax highlighting
noremap <F12> <Esc>:syntax sync fromstart<CR>
" Avoid colon to spare your pinky ;-)
nnoremap <Space><Space> :
" Avoid ESC
inoremap jj <ESC>
" Change leader key from odd '\' to ','
let mapleader = ","
" Then make good use of the new leader for an easy saving
" and closing of buffers ;-)
map <leader>w :w<cr>
map <leader>q :q<cr>
" Reselect text pasted just before
map <leader>v V`]
" Copy visual selection into clipboard
noremap <Leader>y "*y
" Kill white space
nnoremap <Leader>dw :%s/\s\+$//e<CR>
" Folding
nnoremap <space> za
" Last edit location
nnoremap ;; g;
" paste toggle
nnoremap <F4> :set invpaste paste?<CR>
set pastetoggle=<F4>
set showmode
" Remap VIM 0 to first non-blank character
map 0 ^
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %