-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
313 lines (265 loc) · 8.65 KB
/
init.vim
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
" Maintainer: Idigo Luwum
" Version: #ver
" License: This file is distributed under the terms of Gnu Public License Version 2
"""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
" General
"""""""""""""""""""""""""""""""""""""""
" utf8 ftw!
set encoding=utf-8
" up to 500 lines of vim command history
set history=500
" enable mouse for all modes.
set mouse=a
" load filetype specific highlighting and indentation
filetype plugin on
filetype indent on
set relativenumber
set ruler
set hlsearch
set incsearch
set noswapfile
set nobackup
set nowritebackup
set autoread
""""""""""""""""""""""""""""""""""""""""
" Tabs, Spaces, Folds
""""""""""""""""""""""""""""""""""""""""
set tabstop=8
set softtabstop=4
set shiftwidth=4
set expandtab
set smarttab
set foldcolumn=1
""""""""""""""""""""""""""""""""""""""""
" Ctags
""""""""""""""""""""""""""""""""""""""""
" Don't forget
" 1. Install univeral ctags at https://github.com/universal-ctags/ctags
" 2. Generate tags file with ctags -R -f ~/.local/share/ctags/systags /usr/include
" /usr/local/include
if empty(exepath('ctags'))
echom ' Could not find ctags on the system.\n'
\ ' Install univeral ctags at https://github.com/universal-ctags/ctags\n'
\ ' Generate tags file with ctags -R -f <path_to_store_ctags> <include_path>...'
endif
set tags+=expand('~/.local/share/ctags/systags')
"""""""""""""""""""""""""""""""""""""""
" Plugins (via vim-plug)
"""""""""""""""""""""""""""""""""""""""
if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
augroup plug_install
autocmd!
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
augroup END
endif
call plug#begin(expand('~/.local/share/nvim/plugged'))
Plug 'tpope/vim-obsession'
Plug 'dhruvasagar/vim-prosession'
Plug 'tpope/vim-sensible'
Plug 'w0rp/ale'
Plug 'itchyny/lightline.vim'
Plug 'SirVer/ultisnips'
Plug 'maximbaz/lightline-ale'
Plug 'tpope/vim-vinegar'
Plug 'w0rp/ale'
Plug 'supercollider/scvim'
Plug 'daviesjamie/vim-base16-lightline'
Plug 'scrooloose/nerdtree'
Plug 'tpope/vim-fugitive'
Plug 'majutsushi/tagbar'
Plug 'benmills/vimux'
Plug 'nightsense/vimspectr'
Plug 'Shougo/denite.nvim'
Plug 'ervandew/supertab'
Plug 'tpope/vim-surround'
Plug 'hashivim/vim-vagrant'
Plug 'lambdalisue/suda.vim'
Plug 'mattn/emmet-vim'
Plug 'othree/javascript-libraries-syntax.vim'
Plug 'rust-lang/rust.vim'
Plug 'honza/vim-snippets'
Plug 'Valloric/YouCompleteMe'
Plug 'wokalski/autocomplete-flow'
Plug 'airblade/vim-gitgutter'
Plug 'sebastianmarkow/deoplete-rust'
Plug 'Shougo/neosnippet-snippets'
Plug 'sheerun/vim-polyglot'
Plug 'chriskempson/base16-vim'
Plug 'ryanoasis/vim-devicons'
call plug#end()
""""""""""""""""""""""""""""""""""""""""
" UI
""""""""""""""""""""""""""""""""""""""""
set noshowmode
if filereadable(expand('~/.vimrc_background'))
let base16colorspace=256
source ~/.vimrc_background
endif
let g:lightline = {
\ 'colorscheme': 'base16',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch' ],
\ [ 'filename', 'modified', 'readonly' ] ],
\ 'right': [ [ 'lineinfo', 'linter_checking', 'linter_warnings', 'linter_errors', 'linter_ok' ],
\ [ 'percent' ],
\ [ 'fileencoding', 'filetype' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head'
\ },
\ 'component_expand' : {
\ 'linter_checking': 'lightline#ale#checking',
\ 'linter_warnings': 'lightline#ale#warnings',
\ 'linter_errors': 'lightline#ale#errors',
\ 'linter_ok': 'lightline#ale#ok'
\ },
\ 'component_type' : {
\ 'linter_checking': 'left',
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error',
\ 'linter_ok': 'left',
\ }
\ }
let g:lightline#ale#indicator_checking = "\uf110"
let g:lightline#ale#indicator_warnings = "\uf071"
let g:lightline#ale#indicator_errors = "\uf05e"
let g:lightline#ale#indicator_ok = "\uf00c"
"""""""""""""""""""""""""""""""""""""""
" Mappings
"""""""""""""""""""""""""""""""""""""""
let g:mapleader = ','
" Simple Window Movement
nmap <c-j> <c-w>j
nmap <c-h> <c-w>h
nmap <c-k> <c-w>k
nmap <c-l> <c-w>l
"""""""""""""""""""""""""""""""""""""""
" Normal Mode
"""""""""""""""""""""""""""""""""""""""
nmap <leader>gr :Gread<cr>
nmap <leader>gw :Gwrite<cr>
nmap <leader>gc :Gcommit<cr>
nmap <leader>gd :Gdiff<cr>
nnoremap <leader>gg :GitGutterToggle<cr>
nnoremap <leader>gh :GitGutterLineHighlightsToggle<cr>
nnoremap <leader>ga :GitGutterStageHunk<cr>
nnoremap <leader>gu :GitGutterUndoHunk<cr>
nnoremap <leader>af :ALEFix<cr>
nnoremap <leader>ad :ALEDetail<cr>
nnoremap <leader>al :ALELint<cr>
nmap <leader>w :w!<cr>
nmap <leader>ws :split<cr>
nmap <leader>wv :vsplit<cr>
nmap <leader>tt :tabnew<cr>
nmap <leader>tn :tabnext<cr>
nmap <leader>tp :tabprevious<cr>
nmap <leader>b :Denite buffer<cr>
nmap <leader>f :Denite file<cr>
nmap <leader>h :Denite command_history<cr>
nmap <leader>j :YcmCompleter GoTo<cr>
nmap <leader>d :YcmCompleter GoToDefinition<cr>
nmap <leader>k :YcmCompleter GetType<cr>
nmap <leader>m :YcmCompleter GetDoc<cr>
nnoremap <F1> <silent>
nnoremap <F2> <silent>
" Quickly move between ALE errors.
nnoremap <F3> <Plug>(ale_previous_wrap)
nnoremap <F4> <Plug>(ale_next_wrap)
" Disable the arrow keys
nnoremap <Down> <NOP>
nnoremap <Up> <NOP>
nnoremap <Right> <NOP>
nnoremap <Left> <NOP>
"""""""""""""""""""""""""""""""""""""""
" Insert Mode
"""""""""""""""""""""""""""""""""""""""
"Leader-q to Escape from insert mode.
inoremap <leader>q <ESC>
"""""""""""""""""""""""""""""""""""""""
" Prosession / Obsession
"""""""""""""""""""""""""""""""""""""""
" Obsession invokes :mksession upon BufEnter and VimLeavePre
" autocommands. Prosession stores and manages the created sessions.
" Store all session files in XDG_DATA_HOME
let g:prosession_dir = $XDG_DATA_HOME . '/nvim/session/'
if !filewritable(g:prosession_dir)
call mkdir(g:prosession_dir)
endif
" Do not create session for a vcs branch.
let g:prosession_per_branch = 0
" Command used to identify the current branch.
let g:prosession_branch_cmd = 'git rev-parse --abbrev-ref HEAD 2>/dev/null'
"""""""""""""""""""""""""""""""""""""""
" Ale
"""""""""""""""""""""""""""""""""""""""
" Do not keep the sign gutter open at all time.
let g:ale_sign_column_always = 0
" Display errors and warnings in the statusline
let g:airline#extensions#ale#enabled = 1
" Run ale upon opening a file.
let g:ale_lint_on_enter = 1
" Linters to use when running ale.
let g:ale_linters = {
\ 'c': [ 'clangd' ],
\ 'cpp': [ 'clangtidy' ],
\ 'sh': [ 'shellcheck' ],
\ 'go': [ 'megacheck' ],
\ 'javascript': [ 'standard' ],
\ 'python': [ $WORKON_HOME . '/neovim/bin/flake8' ],
\ 'rust' : [ 'clippy' ],
\ 'vim' : [ 'vint' ],
\ 'solidity': [ 'solium' ],
\ }
" Fixers correct linter errors automagically!
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'c': [ 'clang-format' ],
\ 'cpp': [ 'clang-format' ],
\ 'sh' : [ 'shfmt' ],
\ 'go' : [ 'gofmt' ],
\ 'javascript': [ 'prettier_standard' ],
\ 'python': [ 'yapf' ],
\ 'rust': [ 'rustfmt']
\ }
" Run ale upon saving a file.
let g:ale_lint_on_save = 1
" Do not run ale upon changes to the file.
let g:ale_lint_on_text_changed = 'never'
" Run ale after leaving insert mode.
let g:ale_lint_on_insert_leave = 1
"""""""""""""""""""""""""""""""""""""""
" Python
"""""""""""""""""""""""""""""""""""""""
let g:python_host_prog = '/usr/bin/python2'
let g:python3_host_prog = '/usr/bin/python3'
"""""""""""""""""""""""""""""""""""""""
" Suda
"""""""""""""""""""""""""""""""""""""""
" Automagically switch a buffer name when the target file is not readable or writable.
let g:suda_smart_edit = 1
let g:suda#prefix = ['suda://', 'sudo://']
"""""""""""""""""""""""""""""""""""""""
" Denite
"""""""""""""""""""""""""""""""""""""""
augroup DeniteSettings
autocmd!
autocmd FileType denite call s:denite_my_settings()
function! s:denite_my_settings() abort
nnoremap <silent><buffer><expr> <CR>
\ denite#do_map('do_action')
nnoremap <silent><buffer><expr> d
\ denite#do_map('do_action', 'delete')
nnoremap <silent><buffer><expr> p
\ denite#do_map('do_action', 'preview')
nnoremap <silent><buffer><expr> q
\ denite#do_map('quit')
nnoremap <silent><buffer><expr> i
\ denite#do_map('open_filter_buffer')
nnoremap <silent><buffer><expr> <Space>
\ denite#do_map('toggle_select').'j'
endfunction
augroup END