-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnvimrc
More file actions
383 lines (335 loc) · 13.5 KB
/
nvimrc
File metadata and controls
383 lines (335 loc) · 13.5 KB
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
" Eli's vimrc ಠ_ಠ
" TODO: Think about splitting this up into separate files
" set nocompatible
let g:mapleader = ','
let g:neovim2_venv=expand('~/venvs/neovim2/bin/python')
let g:neovim3_venv=expand('~/venvs/neovim3/bin/python')
let g:plugins_location=expand('~/.config/nvim/plugged')
augroup vimrc
autocmd!
augroup END
if !empty(glob(g:neovim2_venv))
let g:python_host_prog=g:neovim2_venv
endif
if !empty(glob(g:neovim3_venv))
let g:python3_host_prog=g:neovim3_venv
endif
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
if empty(expand('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Plugins {
call plug#begin(g:plugins_location)
Plug 'Chiel92/vim-autoformat' " Autoformatting of code
Plug 'Xuyuanp/nerdtree-git-plugin' " Git plugin for nerdtree
Plug 'airblade/vim-gitgutter' " Show git changes
Plug 'airblade/vim-rooter' " Change pwd to root for a file
Plug 'benekastah/neomake' " Syntax checking
Plug 'ctrlpvim/ctrlp.vim' " Fuzzy file finder
Plug 'ervandew/supertab' " Supertab!
Plug 'haya14busa/incsearch.vim' " Better searching
Plug 'jiangmiao/auto-pairs' " Auto pair parens and brackets
Plug 'jszakmeister/vim-togglecursor' " Toggle cursor in insert mode
Plug 'luochen1990/rainbow' " Rainbow parenthesis
Plug 'mbbill/undotree' " Undo tree
Plug 'mhinz/vim-startify' " Nice start screen
Plug 'morhetz/gruvbox' " Really nice colorscheme
Plug 'nathanaelkane/vim-indent-guides' " Indent Guides
Plug 'powerline/fonts' " Powerline fonts for airline
Plug 'rking/ag.vim' " Silver searcher searching
Plug 'schickling/vim-bufonly' " Close all buffers except one
Plug 'scrooloose/nerdtree' " File tree viewer
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-commentary' " Comment all the things
Plug 'tpope/vim-fugitive' " Git stuff (Mainly for :Gblame)
Plug 'tpope/vim-sleuth' " Detect tabs / spaces
Plug 'tpope/vim-surround' " Surround things with things
Plug 'vim-airline/vim-airline' " Cool ass statusline
" Setting vim specific autocomplete
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'tpope/vim-sensible' " Sensible vim settings
Plug 'Shougo/neocomplete.vim' " Autocomplete for vim
endif
" Python specific {
Plug 'python-mode/python-mode', { 'for': 'python', 'branch': 'develop' }
Plug 'davidhalter/jedi-vim', {'for': 'python'}
" }
" Go specific {
Plug 'fatih/vim-go', {'for': 'go'}
let g:go_metalinter_autosave = 0
let editor_name='vim'
if has('nvim')
let editor_name='nvim'
endif
let gocode_script=g:plugins_location . '/gocode/'. editor_name .'/symlink.sh'
Plug 'nsf/gocode', {'for': 'go', 'rtp': editor_name, 'do': gocode_script } " Go autocompletion
Plug 'godoctor/godoctor.vim', {'for': 'go'} " Gocode refactoring tool
" }
"
" Powershell specific {
Plug 'PProvost/vim-ps1', {'for': 'ps1'}
" }
" TOML {
Plug 'cespare/vim-toml', {'for': 'toml'}
" }
" Rust {
Plug 'rust-lang/rust.vim', {'for': 'rust'}
Plug 'racer-rust/vim-racer', {'for': 'rust'}
let g:racer_cmd = substitute(system('which racer'), '\n', '', '')
au FileType rust nmap gd <Plug>(rust-def)
au FileType rust nmap gs <Plug>(rust-def-split)
au FileType rust nmap gx <Plug>(rust-def-vertical)
au FileType rust nmap <leader>gd <Plug>(rust-doc)
" }
call plug#end()
" vim-bufonly {
nnoremap <Leader>bo :Bufonly<CR>
" }
" neomake {
" Mainly for python only right now, could expand to other things
let g:neomake_python_enabled_makers = ['flake8']
nnoremap <Leader>zz :Neomake flake8<CR>
" Run neomake on write
autocmd! vimrc BufWritePost * Neomake
" }
" python-mode {
let g:pymode_rope_completion=0
let g:pymode_rope_completion_bind = ''
let g:pymode_rope_complete_on_dot = 0
let g:pymode_lint=0
let g:pymode_folding=0
let g:pymode_virtualenv=0
" }
" incsearch.vim {
" Set it so that we actually use the plugin
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
" Set it so that ugly search highlights automagically go away
set hlsearch
let g:incsearch#auto_nohlsearch = 1
map n <Plug>(incsearch-nohl-n)
map N <Plug>(incsearch-nohl-N)
map * <Plug>(incsearch-nohl-*)
map # <Plug>(incsearch-nohl-#)
map g* <Plug>(incsearch-nohl-g*)
map g# <Plug>(incsearch-nohl-g#)
" }
" indent-guides {
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
let g:indent_guides_enable_on_vim_startup = 1
" }
" deoplete / neocomplete {
if has('nvim')
let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_smart_case = 2
else
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 2
endif
" }
" Jedi-Vim {
autocmd vimrc FileType python setlocal completeopt-=preview
let g:jedi#show_call_signatures = '0'
" }
" vim-airline {
let g:airline_theme='gruvbox'
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
" }
"
" NERDTree {
map <C-e> :NERDTreeToggle<CR>
map <Leader>e :NERDTreeFind<CR>
map <Leader>nt :NERDTreeFind<CR>
let g:NERDTreeShowBookmarks=1
let g:NERDTreeIgnore=['\.py[cd]$', '\~$', '\.swo$', '\.swp$', '^\.git$', '^\.hg$', '^\.svn$', '\.bzr$', '^\.ropeproject$']
let g:NERDTreeChDirMode=0
let g:NERDTreeQuitOnOpen=0
let g:NERDTreeMouseMode=2
let g:NERDTreeShowHidden=1
let g:NERDTreeKeepTreeInNewTab=1
let g:nerdtree_tabs_open_on_gui_startup=0
" }
" UndoTree {
nnoremap <Leader>u :UndotreeToggle<CR>
let g:undotree_SetFocusWhenToggle=1
" }
" Git Fugitive {
let g:has_fugitive=1
" }
" rainbow {
let g:rainbow_active = 1
" }
" }
" General {
" Allow a trigger for the background
set background=dark " Dark backgrounds cause we're emo
function! ToggleBG()
let s:tbg = &background
" Inversion
if s:tbg ==# 'dark'
set background=light
else
set background=dark
endif
endfunction
nnoremap <Leader>bg :call ToggleBG()<CR>
filetype plugin indent on " Automatically detect file types.
syntax on " Syntax highlighting
set mousehide " Hide the mouse cursor while typing
set encoding=utf8
scriptencoding utf-8
set clipboard+=unnamed " Enable clipboard from OSX
set viewoptions=folds,options,cursor,unix,slash
set virtualedit=onemore " Allow for cursor beyond last character
set history=1000 " Store a ton of history
set nospell " Turn spellcheck off
set hidden " Allow buffer switching without saving
" Set it to the first line when editing a git commit message
augroup gcommit
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
augroup END
" Restore cursor to file position in previous editing session
function! ResCur()
if line("'\"") <= line("$")
silent! normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
" Sets central temp file location, to prevent local default behavior.
if isdirectory($HOME . '/.vim/.tmp') == 0
:silent !mkdir -m 700 -p ~/.vim/.tmp > /dev/null 2>&1
endif
set backupdir=~/.vim/.tmp ",~/.local/tmp/vim,/var/tmp,/tmp,
set directory=~/.vim/.tmp ",~/.local/tmp/vim,/var/tmp,/tmp,
if exists('+undofile')
" undofile -- This allows you to use undos after exiting and
" restarting. NOTE: only present in 7.3+
" :help undo-persistence
if isdirectory( $HOME . '/.vim/.undo' ) == 0
:silent !mkdir -m 700 -p ~/.vim/.undo > /dev/null 2>&1
endif
set undodir=~/.vim/.undo
set undofile
endif
" }
" UI Options {
if has('gui_running')
set guioptions-=r
set guioptions-=l
set guioptions-=R
set guioptions-=L
endif
if has("nvim")
" True color support
set termguicolors
endif
color gruvbox
set splitbelow
set splitright
set tabpagemax=15 " Only show 15 tabs
set showmode " Display the current mode
if exists('&inccommand')
set inccommand=split " Turn on live preview substitute
endif
highlight clear SignColumn
highlight clear LineNr
" Enable transparency
highlight Normal ctermbg=none
highlight NonText ctermbg=none
if has('cmdline_info')
set ruler
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%)
set showcmd
endif
if has('statusline')
set laststatus=2
set statusline=%<%f\ " Filename
set statusline+=%w%h%m%r " Options
if g:has_fugitive == 1
set statusline+=%{fugitive#statusline()}
endif
set statusline+=\ [%{&ff}/%Y] " Filetype
set statusline+=\ [%{getcwd()}] " Current dir
set statusline+=%=%-14.(%l,%cV%)\ %p%% " Right aligned file nav info
endif
set backspace=indent,eol,start " Working backspace
set number " Line numbers are on
set showmatch " Show matching brackets/parenthesis
set incsearch " Find as you type search
set ignorecase " Case insensitive search
set smartcase " Case sensitive when uc present
set wildmenu " Show a list of completions for commands
set wildmode=list:longest,full " Command <Tab> completion, list matches,then longest part, then all.
set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
set scrolljump=5 " Lines to scroll when cursor leaves screen
set scrolloff=3 " Minimum lines to keep above/below cursor
set list
set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
set foldmethod=indent
set foldlevelstart=99
autocmd vimrc FileType python let &colorcolumn=80
" Disable the annoying bells
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd vimrc GUIEnter * set visualbell t_vb=
endif
au TermOpen * setlocal nonumber norelativenumber
" }
" Formatting {
set nowrap " No wrapping
set autoindent " Indent at the same level of the prev line
set shiftwidth=4 " Use indents of 4 spaces
set expandtab " Tabs are spaces
set tabstop=4 " An indentation every four columns
set softtabstop=4 " Let backspace delete indent
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
function! StripTrailingWhitespace()
let l:_s=@/
let l:l = line('.')
let l:c = line('.')
%s/\s\+$//e
let @/=l:_s
call cursor(l:l, l:c)
endfunction
" Deletes trailing whitespace
nnoremap <Leader>sw :call StripTrailingWhitespace()<CR>
autocmd vimrc FileType c,cpp,java,php,javascript,puppet,python,rust,twig,xml,yml,perl,sql,groovy,sh autocmd BufWritePre <buffer> :call StripTrailingWhitespace()
" Auto put things to 2 spaces when doing haskell, puppet, ruby, yml
autocmd vimrc FileType haskell,puppet,ruby,yml setlocal expandtab shiftwidth=2 softtabstop=2
" }
" Key Mappings {
" Easier moving in tabs and windows
nnoremap <C-J> <C-W>j " Move up
nnoremap <C-K> <C-W>k " Move down
nnoremap <C-L> <C-W>l " Move left
nnoremap <C-H> <C-W>h " Move right
" Easier moving in tabs
map <S-H> gT
map <S-L> gt
" Change working directory to that of the current file
cmap cwd lcd %:p:h
cmap cd. lcd %:p:h
" Adjust viewports to the same size
map <Leader>= <C-w>=
" Easy horizontal scrolling
map zl zL
map zh zH
" Easier indenting
vmap q <gv
vmap <TAB> >gv
" }