-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_vimrc
283 lines (236 loc) · 7.36 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
set rtp +=~/.vim/versioned
syntax off
filetype off
" let me use 2 tabs if i want
let g:python_recommended_style = 0
if filereadable(expand("~/brew/bin/python3"))
let g:python3_host_prog = expand("~/brew/bin/python3")
else
let g:python3_host_prog = '/usr/bin/python3'
endif
" lots of things that neovim does for me already
if !has('nvim')
set autoindent
set backspace=indent,eol,start
" Some locales are silly.
set encoding=utf-8
set history=10000 " Be modern
" search patterns
set hlsearch
" move in file when typing /pattern
set incsearch
set laststatus=2 " Always show statusline.
set mouse=a
set nocompatible
set smarttab
" usually we're fast, but with urxvt color it's not always obvious
set ttyfast
set wildmenu
endif
" mutiple vulnerabilities.
set nomodeline
let s:win_shell = (has('win32') || has('win64')) && &shellcmdflag =~ '/'
let s:vimDir = s:win_shell ? '$HOME/vimfiles' : '~/.vim'
" Avoid issues when running in fish.
set shell=/bin/bash
call plug#begin(expand(s:vimDir . '/plugged'))
" Colorschemes
Plug 'justinmk/molokai'
Plug 'KeitaNakamura/neodark.vim'
Plug 'chriskempson/base16-vim'
Plug 'rakr/vim-one'
" Those 2 go together
" Plug 'sheerun/vim-polyglot'
Plug 'nicdumz/nova-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" This requires fancy patched fonts, e.g. DejaVu Sans Mono for Powerline (10)
" See https://github.com/Lokaltog/powerline-fonts
" The gnome terminal and/or .Xresources must be configured for it.
let g:airline_powerline_fonts = 1
" Different font names for different OSes. :h11 is for MacOS/win.
if has("gui_running")
if has("gui_gtk2")
set guifont=Hack
else
set guifont=Hack:h11
endif
endif
" blank the fileencoding / fileformat part
let g:airline_section_y = ''
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
" Support for color fixes in .vim/after
" Disabled to see how that works with nova theme
" Plug 'vim-scripts/AfterColors.vim'
" Some vcs integration
" Plug 'vim-scripts/vcscommand.vim'
" Open correctly files: vim filename:103
Plug 'paulhybryant/file-line'
" Disable native MatchParen for better things.
Plug 'luochen1990/rainbow'
let g:rainbow_conf = {
\ 'guifgs': ['#DAD996', '#F1C392', '#D08FC1', '#9A95DF'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],}
let g:rainbow_active = 1
let loaded_matchparen = 1
Plug 'nathangrigg/vim-beancount'
let g:linuxsty_patterns = [ "/home/ndumazet/code/kernel" ]
Plug 'vivien/vim-linux-coding-style'
" Some scripts need newer vims
if (v:version > 700)
" Plug 'scrooloose/syntastic'
let g:syntastic_error_symbol = '✗'
let g:syntastic_warning_symbol = '⚠'
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_aggregate_errors = 1
" Faster than syntastic?
" Plug 'w0rp/ale'
let g:ale_sign_error = '✗'
let g:ale_sign_warning = '⚠'
let g:ale_sign_style_error = '✗'
let g:ale_sign_style_warning = '⚠'
let g:airline#extensions#ale#enabled = 1
" Export highlighted html to pastebin.
Plug 'google/maktaba' | Plug 'google/vim-syncopate'
" git / perforce side colors
Plug 'mhinz/vim-signify'
endif
" See all 256 colors with :XtermColorTable
Plug 'guns/xterm-color-table.vim'
let g:signify_vcs_list = ['git', 'perforce']
let g:signify_vcs_cmds = {
\ 'perforce': 'p4 info >& /dev/null && env G4MULTIDIFF=0 P4DIFF=%d p4 diff -dU0 %f'
\ }
let g:signify_sign_delete = '-'
" Whitespace highlighting / :StripWhitespace
Plug 'ntpeters/vim-better-whitespace'
" typescript highlighting
Plug 'leafgarland/typescript-vim'
" Ultisnips engine, no snippets.
Plug 'SirVer/ultisnips'
let g:UltiSnipsExpandTrigger = "<c-j>"
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
let g:UltiSnipsJumpBackwardTrigger = "<c-k>"
" Show content of " registers
Plug 'junegunn/vim-peekaboo'
Plug 'nathangrigg/vim-beancount'
call plug#end()
syntax on
filetype plugin indent on
set background=dark
if has('nvim') || has('termguicolors')
set termguicolors
if !empty(globpath(&rtp, 'colors/nova.vim'))
" Not here during first installation
colorscheme nova
endif
endif
set expandtab
set tabstop=4
set shiftwidth=4
set number " Show line numbers
set ruler " Show cursor position on statusline.
set scrolloff=5 " 5 lines around the cursor
if (v:version > 703 || v:version == 703 && has("patch541"))
set formatoptions+=rj " Remove comment characters and others on J
endif
if exists("+inccommand")
set inccommand=nosplit
endif
set foldmethod=marker
set fillchars=vert:┃,fold:- " Nicer vertical split
set clipboard=unnamed " unify clipboards
" completions
set wildmode=longest,list,full
set wildignore=*.swp,*.bak,*.pyc,*.class
" c was introduced in 7.04
if v:version >= 704
set shortmess=aToOc
else
set shortmess=aToO
endif
set cmdheight=2
set noswapfile
set hidden
" Whitespace and long lines
if v:version >= 703
let &colorcolumn=join(range(81,400),",")
autocmd FileType qf setlocal colorcolumn=
endif
set list
set listchars=tab:»·,extends:#,nbsp:· " Show me tabs and nbsp
augroup filetypedetect
autocmd BufRead,BufNewFile */*localhost*.js* setf javascript
autocmd BufRead,BufNewFile */mediawiki* setlocal noexpandtab
" It's all text/external editor support
" Mail?
autocmd BufRead *mail.google.com* setf mail
autocmd BufRead *tmp/*flagfile* setf sh
autocmd FileType gitcommit DiffGitCached | wincmd p
autocmd FileType html setlocal shiftwidth=2 tabstop=2
autocmd FileType python setlocal shiftwidth=2 tabstop=2
" Regenerating mako files takes a few seconds for webdev things.
autocmd BufWritePost *.mako silent make
" Open cwindow in case of make errors
autocmd QuickFixCmdPost *make* cwindow
augroup END
"{{{ Keyboard
" Unbind the cursor keys in insert, normal and visual modes.
for prefix in ['i', 'n', 'v']
for key in ['<Up>', '<Down>', '<Left>', '<Right>']
exe prefix . "noremap " . key . " <Nop>"
endfor
endfor
" space to PageDown, similar to vimperator
map <space> <C-f>
" easier keyboard, when I accidentally hit F1 instead of Esc.
map <F1> <Esc>
imap <F1> <Esc>
imap <M-Space> <Esc>
" CTRL-h to toggle search highlight
map <C-H> :se invhls<cr>
let mapleader=","
map <leader>v :Vex!<cr>
map <leader>s :Hex<cr>
command WQ wq
command Wq wq
command W w
command Q q
" Use <F7> to toggle between 'paste' and 'nopaste'
set pastetoggle=<F7>
"}}}
let g:ackprg="ack -H --nocolor --nogroup --column --ignore-dir build"
function! SetupDiffFunc()
if &readonly
set nomod nolist noma filetype=diff
map q :q<CR>
endif
endfunction
command! SetupDiff call SetupDiffFunc()
" brace completion
inoremap {<CR> {<CR><Esc>:call MySmartBraceComplete()<CR>O
function! MySmartBraceComplete()
if getline(line('.')-1) =~ '^\s*\(class\|struct\)'
normal i};
else
normal i}
endif
endfunction
" Maximize gvim on startup.
if s:win_shell
au GUIEnter * simalt ~x
endif
" map OSC52 copy-paste (from osc52.vim plugin)
vmap <C-c> y:call SendViaOSC52(getreg('"'))<cr>
" no flashing or beeping
set vb t_vb= novisualbell
" No damn bell in gvim
au GUIEnter * set visualbell t_vb=
" And last, machine / Google-specific settings are there:
if filereadable(expand("~/.vimrc.after"))
source ~/.vimrc.after
endif