-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
476 lines (367 loc) · 10.8 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
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
set encoding=utf-8
scriptencoding utf-8
"""""""""""
" Plugins "
"""""""""""
" Bootstrap autoload
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
endif
call plug#begin('~/.vim/bundle')
" Some nice defaults
Plug 'tpope/vim-sensible'
" Surround
Plug 'tpope/vim-surround'
" Fix . for some plugins
Plug 'tpope/vim-repeat'
" Highlight all search results
Plug 'haya14busa/incsearch.vim'
Plug 'michaeljsmith/vim-indent-object'
" Undo tree
Plug 'sjl/gundo.vim', {'on': 'GundoToggle'}
nnoremap <silent> <leader>u <Esc>:<C-u>GundoToggle<CR>
" Better targets (cin" !)
Plug 'wellle/targets.vim'
" Nerd tree
Plug 'scrooloose/nerdtree'
let g:NERDTreeMouseMode=1
autocmd vimenter * if !argc() | NERDTree | endif
map <silent> <C-n> :NERDTreeToggle<CR>
let NERDTreeIgnore = ['\.pyc$']
" Tag list
Plug 'majutsushi/tagbar'
let g:tagbar_autofocus = 1
map <C-t> :TagbarToggle<CR>
let g:python_host_prog="/usr/bin/python"
let g:python3_host_prog="/usr/bin/python"
let g:pymode_rope = 0
" Syntaxe checking
Plug 'scrooloose/syntastic'
let g:syntastic_auto_loc_list=0
let g:syntastic_enable_loc_list=0
let g:syntastic_enable_highlighting=1
let g:syntastic_error_symbol='✗→'
let g:syntastic_style_error_symbol='✗→'
let g:syntastic_warning_symbol='⚠→'
let g:syntastic_style_warning_symbol='⚠→'
let g:syntastic_aggregate_errors=1
let g:Powerline_symbols = 'unicode'
let g:syntastic_python_checkers=['flake8', 'pyflakes', 'pep8', 'py3kwarn']
let g:syntastic_python_checker_args='--ignore=E501'
let g:syntastic_python_flake8_post_args='--ignore=E501,E128'
let g:syntastic_python_pep8_post_args='--ignore=E501,E128'
let g:syntastic_scala_checkers=[]
let g:syntastic_java_checkers=[]
"Always check when buffers are opened
let g:syntastic_check_on_open=1
" Git signs
Plug 'airblade/vim-gitgutter'
let g:gitgutter_eager = 0 " only update on read/write
let g:gitgutter_sign_column_always = 0
" Tab with buffers
Plug 'ervandew/supertab'
let g:airline#extensions#tabline#enabled = 1
" Python completion
Plug 'davidhalter/jedi-vim'
let g:jedi#use_tabs_not_buffers = 0
set splitbelow
" gc to comment
Plug 'tomtom/tcomment_vim'
Plug 'justinmk/vim-sneak'
" clipboard management
Plug 'svermeulen/vim-easyclip'
let g:EasyClipDoSystemSync=0
" Python settings
Plug 'klen/python-mode'
let g:pymode_lint_on_write = 0
let g:pymode_lint_signs = 0
let g:pymode_folding = 0
let g:pymode_python = 'python3'
let g:pymode_rope_completion = 0
" vv selection
Plug 'gorkunov/smartpairs.vim'
let g:smartpairs_nextpairs_key_i = ''
" Automatic tab detection
Plug 'tpope/vim-sleuth'
" Git commands
Plug 'tpope/vim-fugitive'
" Multiple cursors
Plug 'terryma/vim-multiple-cursors'
let g:multi_cursor_use_default_mapping=0
let g:multi_cursor_next_key='<C-d>'
let g:multi_cursor_prev_key='<C-p>'
let g:multi_cursor_skip_key='<C-x>'
let g:multi_cursor_quit_key='<Esc>'
Plug 'vim-scripts/bufkill.vim'
" Airline
Plug 'bling/vim-airline'
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:airline_powerline_fonts=1
Plug 'ctrlpvim/ctrlp.vim'
Plug 'ryanoasis/vim-webdevicons'
Plug 'unblevable/quick-scope'
Plug 'saltstack/salt-vim'
Plug 'jplaut/vim-arduino-ino'
Plug 'posva/vim-vue'
"Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
"let g:deoplete#enable_at_startup = 1
Plug 'Shougo/context_filetype.vim'
"Plug 'zchee/deoplete-jedi'
Plug 'sheerun/vim-polyglot'
Plug 'psliwka/vim-smoothie'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim', { 'branch': '0.1.x' }
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'rktjmp/lush.nvim'
Plug 'adisen99/codeschool.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'ms-jpq/coq_nvim', {'branch': 'coq'}
call plug#end()
""""""""""""""""""""
" General settings "
""""""""""""""""""""
set hidden
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
" Case sensitive only if upper
set ignorecase smartcase
set cmdheight=2
set switchbuf=useopen
set numberwidth=5
set showtabline=2
set shell=zsh
set scrolloff=3
" Prevent Vim from clobbering the scrollback buffer. See
" http://www.shallowsky.com/linux/noaltscreen.html
set t_ti= t_te=
" No backups
set nobackup
set nowritebackup
set wildmode=longest,list
" Better ladder
let mapleader=" "
" Line numbers
set nu
" Folding
"
set foldcolumn=1
set foldmethod=indent
set foldlevel=99
set mouse=a
" set listchars=tab:⇝·,trail:⚠,extends:⇝,precedes:⇜,eol:⚡
" set listchars=tab:⇝·,trail:⚠,extends:⇝,precedes:⇜,eol:▹
set listchars=tab:\ \ ,trail:⚠,extends:⇝,precedes:⇜,eol:▹
set list
set incsearch
set hlsearch
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CUSTOM AUTOCMDS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
augroup vimrcEx
" Clear all autocmds in the group
autocmd!
autocmd FileType text setlocal textwidth=78
" Jump to last cursor position unless it's invalid or in an event handler
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
"for ruby, autoindent with two spaces, always expand tabs
autocmd FileType ruby,haml,eruby,yaml,html,htmldjango,javascript,sass,cucumber set ai sw=4 sts=4 et
autocmd FileType python set sw=4 sts=4 et
autocmd! BufRead,BufNewFile *.sass setfiletype sass
autocmd BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:>
autocmd BufRead *.markdown set ai formatoptions=tcroqn2 comments=n:>
" Indent p tags
autocmd FileType html,eruby if !exists("g:html_indent_tags") || g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType htmldjango set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
augroup END
""""""""""
" Colors "
""""""""""
set termguicolors
" Highlight currentline
set cursorline
hi CursorLine term=bold gui=bold cterm=bold guibg=Grey40
:set t_Co=256
:set background=dark
:color grb256
set guifont="DejaVu Sans Mono for Powerline Plus Nerd File Types Mono 10"
if has("gui_running") || has('nvim')
" colorscheme codeschool
set foldcolumn=0
endif
lua << EOF
require('lush')(require('codeschool').setup({
plugins = {
"buftabline",
"coc",
"cmp", -- nvim-cmp
"fzf",
"gitgutter",
"gitsigns",
"lsp",
"lspsaga",
"nerdtree",
"netrw",
"nvimtree",
"neogit",
"packer",
"signify",
"startify",
"syntastic",
"telescope",
"treesitter"
},
langs = {
"c",
"clojure",
"coffeescript",
"csharp",
"css",
"elixir",
"golang",
"haskell",
"html",
"java",
"js",
"json",
"jsx",
"lua",
"markdown",
"moonscript",
"objc",
"ocaml",
"purescript",
"python",
"ruby",
"rust",
"scala",
"typescript",
"viml",
"xml"
}
}))
EOF
hi NonText ctermfg=64 guifg=#7A7912
hi SpecialKey ctermfg=64 guifg=#7A7912
highlight SyntasticErrorSign guifg=#ff2222 guibg=#3E3D32 ctermfg=0 ctermbg=1
highlight SyntasticWarningSign guifg=#ff2222 guibg=#3E3D32 ctermfg=0 ctermbg=3
highlight SyntasticStyleErrorSign guifg=#ff2222 guibg=#3E3D32 ctermfg=0 ctermbg=1
highlight SyntasticStyleWarningSign guifg=#ff2222 guibg=#3E3D32 ctermfg=0 ctermbg=3
highlight SignColumn ctermbg=8 guibg=#3E3D32
highlight GitGutterAdd guifg=#009900 guibg=#3E3D32 ctermfg=2 ctermbg=8
highlight GitGutterChange guifg=#bbbb00 guibg=#3E3D32 ctermfg=3 ctermbg=8
highlight GitGutterDelete guifg=#ff2222 guibg=#3E3D32 ctermfg=1 ctermbg=8
lua << EOF
vim.api.nvim_create_autocmd({ "CursorHold" }, {
pattern = "*",
callback = function()
for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do
if vim.api.nvim_win_get_config(winid).zindex then
return
end
end
vim.diagnostic.open_float({
scope = "cursor",
focusable = false,
close_events = {
"CursorMoved",
"CursorMovedI",
"BufHidden",
"InsertCharPre",
"WinLeave",
},
})
end
})
EOF
"""""""""""""""
" Status line "
"""""""""""""""
:set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%)
""""""""""""""""
" Key mappings "
""""""""""""""""
map <c-c> <esc>
:nnoremap <CR> :nohlsearch<cr>
set pastetoggle=<F10>
" F6: Highlight the word under cursor in darkred
highlight ManualHighlight ctermbg=darkred guibg=darkred
noremap <silent> <F6> :exe printf('match ManualHighlight /%s/', escape(expand('<cword>'), '/\'))<CR>
noremap <silent> <c-F6> :match ManualHighlight //<CR>
inoremap <silent> <c-s> <c-o>:w<CR>
nnoremap <silent> <C-S> :<C-u>w<CR>
map <Leader>w :BD<Return>
vnoremap <silent> y y`]
vnoremap <silent> p p`]
nnoremap <silent> p p`]
" Copy paste in copy/paste global buffer
vmap <Leader>y "+y
vmap <Leader>d "+d
nmap <Leader>p "+p
nmap <Leader>P "+P
vmap <Leader>p "+p
vmap <Leader>P "+P
" Fast buffer navigation
map <c-left> :bprevious<CR>
map <c-right> :bnext<CR>
" Select with <enter> completion
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Always select the first element
inoremap <expr> <C-n> pumvisible() ? '<C-n>' :
\ '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
map <Leader><tab> :set shiftwidth=4 expandtab<CR>
"""""""""""""""""
" Misc commands "
"""""""""""""""""
" Sudo write
cmap w!! w !sudo tee % > /dev/null
"""""""""""
" Tab key "
"""""""""""
set completeopt-=preview
" Complete only if not dth=4
" set expandtab dth=4
" set expandtab @ the beggining of a line
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n>
:let $NVIM_TUI_ENABLE_TRUE_COLOR=1
:let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
au BufRead,BufNewFile *.pde set filetype=arduino
au BufRead,BufNewFile *.ino set filetype=arduino
let g:vim_arduino_ino_cmd = 'ano'
:set colorcolumn=80
lua << EOF
local lspconfig = require('lspconfig')
-- require'lspconfig'.gopls.setup{}
-- require'lspconfig'.pyright.setup{}
vim.g.coq_settings = { auto_start = 'shut-up' }
local servers = { 'gopls', 'pyright'}
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup(require('coq').lsp_ensure_capabilities({}))
end
EOF
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fc <cmd>Telescope git_commits<cr>
nnoremap <leader>fd <cmd>Telescope lsp_definitions<cr>
nnoremap <leader>fr <cmd>Telescope lsp_references<cr>
highlight link DiagnosticError CodeschoolError