init.vim 10.5 KB
Newer Older
1
2
3
" --- https://github.com/junegunn/vim-plug ------------------------------
" Minimalist plugin manager. Update with --> :PlugInstall
"
Nelso Jost's avatar
Nelso Jost committed
4
5
6
7
8
9
10
11
12
13
14
15
call plug#begin('~/.local/share/nvim/plugged')

Plug 'flazz/vim-colorschemes'         " molokai, PaperColor, etc
Plug 'scrooloose/nerdcommenter'       " toggle comments and so on
Plug 'vim-airline/vim-airline'        " nice status bar
Plug 'vimlab/split-term.vim'          " better split neovim terminal
Plug 'mhinz/vim-sayonara'             " smart buffer quitting
Plug 'majutsushi/tagbar'              " show file tags (require ctags)
Plug 'kien/ctrlp.vim'                 " fuzzy finder (files, buffer, tags)
Plug 'jiangmiao/auto-pairs'           " Insert quotes/brackets in pairs
Plug 'tpope/vim-obsession'            " create/restore vim sessions
Plug 'scrooloose/nerdtree'            " tree explorer
16
17
18
19
20
21
22
23
24
Plug 'plasticboy/vim-markdown'        " markdown syntax
Plug 'benmills/vimux'                 " exec commands on tmux panels
Plug 'xolox/vim-misc'
Plug 'xolox/vim-colorscheme-switcher'
"Plug 'lvht/tagbar-markdown'
Plug 't4ku/marktag'
Plug 'octol/vim-cpp-enhanced-highlight'

Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Nelso Jost's avatar
Nelso Jost committed
25
"Plug 'davidhalter/jedi'
26
"Plug 'zchee/deoplete-jedi'
Nelso Jost's avatar
Nelso Jost committed
27
28
" Plug 'davidhalter/jedi-vim'

29
"Plug 'roxma/nvim-completion-manager'  " async, dynamic, completion
Nelso Jost's avatar
Nelso Jost committed
30
31
32
33
34


call plug#end()
" -----------------------------------------------------------------------

35
colorscheme nelsobaka
Nelso Jost's avatar
Nelso Jost committed
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

behave mswin
set clipboard=unnamed
"set clipboard=unnamedplus
"
set colorcolumn=80
set nowrap

set showcmd             " Show (partial) command in status line.
set showmatch           " Show matching brackets.
set showmode            " Show current mode.
set ruler               " Show the line and column numbers of the cursor.
set number              " Show the line numbers on the left side.
set formatoptions+=o    " Continue comment marker in new lines.
set textwidth=0         " Hard-wrap long lines as you type them.
set expandtab           " Insert spaces when TAB is pressed.
set tabstop=4           " Render TABs using this many spaces.
set shiftwidth=4        " Indentation amount for < and > commands.

set noerrorbells        " No beeps.
set modeline            " Enable modeline.
set esckeys             " Cursor keys in insert mode.
set linespace=0         " Set line-spacing to minimum.
set nojoinspaces        " Prevents inserting two spaces after punctuation on a join (J)

set ignorecase          " ignore case on vim command/completion
set infercase           " smart case insensitivity

" More natural splits
set splitbelow          " Horizontal split below current.
set splitright          " Vertical split to right of current.

if !&scrolloff
  set scrolloff=3       " Show next 3 lines while scrolling.
endif
if !&sidescrolloff
  set sidescrolloff=5   " Show next 5 columns while side-scrolling.
endif
set nostartofline       " Do not jump to first character with page commands.

" with infinite undo and a bit of saving addiction, those aren't needed
set nobackup
set noswapfile
set undofile                 "turn on the feature
set undodir=$HOME/.config/nvim/undo
set undolevels=1000         " How many undos
set undoreload=10000        " number of lines to save for undo

" ============================================================================
" FILE ESPECIFICS

" use hard tab only on Makefiles (to avoid missing separator error)
autocmd Filetype make setlocal noexpandtab shiftwidth=4 softtabstop=0
autocmd Filetype yaml setlocal tabstop=4 softtabstop=4 shiftwidth=4

autocmd BufNewFile,BufReadPost *.ino,*.pde set filetype=cpp

" ============================================================================
" KEY MAPPINGS

" space enter insertion mode (<esc> still goes back to normal mode)
map <space> i

" disable ex mode
map Q <Nop>

let mapleader=","

nmap <F2> :TagbarToggle<CR>
imap <F2> :TagbarToggle<CR>

nmap <F3> :NERDTreeToggle<CR>

109
110
111
112
113
114
nnoremap <C-e> :update<CR>:VimuxRunCommand "make"<CR>
nnoremap <c-d> :update<CR>:VimuxRunLastCommand<CR>

map <F8> :PrevColorScheme<CR>
map <F9> :NextColorScheme<CR>

Nelso Jost's avatar
Nelso Jost committed
115
116
117
map  <F10> :ed ~/.config/nvim/init.vim<cr>

" open terminal split [term-split.vim]
118
119
"map <C-t> :50VTerm<CR>
"map <C-e> :40VTerm make<CR>
Nelso Jost's avatar
Nelso Jost committed
120
121
122
123
124
125
126
127
128
129
130
131

" delete buffer without closing the window [bclose.vim]
nnoremap q :Sayonara<cr>
nnoremap <C-q> :qa<cr>
inoremap <C-q> <Esc>:Sayonara<cr>
"nnoremap <C-d> :Sayonara<cr>
"inoremap <C-d> :Sayonara<cr>

" toggle comment [NERD commenter]
map <Return> <C-g><leader>c<space>
smap <Return> <C-g><leader>c<space>

132
133
134
135
136
" delete previous word
" imap <C-BS> <C-W>

set backspace=indent,eol,start

Nelso Jost's avatar
Nelso Jost committed
137
138
139
140
141
142
143
" delete word under cursor
noremap <C-Space> ciw
inoremap <C-Space> <ESC>ciw

" easy tab ident
vnoremap <Tab> >
vnoremap <S-Tab> <
144

Nelso Jost's avatar
Nelso Jost committed
145
" easier split navigation
146
147
148
149
"map <C-S-Left> <C-w>h
"map <C-S-Right> <C-w>l
"map <C-S-Down> <C-w>j
"map <C-S-Up> <C-w>k
Nelso Jost's avatar
Nelso Jost committed
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
nmap <Tab> <C-w>w

" move cursor by n lines
nnoremap <C-Up> 5-
nnoremap <C-Down> 5+
inoremap <C-Up> <C-o>5-
inoremap <C-Down> <C-o>5+

" CTRL-Z is Undo; not in cmdline though
noremap <C-Z> u
inoremap <C-Z> <C-O> <Esc>

noremap <C-Y> <C-R>
inoremap <C-Y> <C-O><C-R>

vnoremap <C-X> "+x
vnoremap <C-C> "+y
"map <C-V>		"+gP

" CTRL-S for saving (require "stty -ixon" line on ~/.bashrc)
noremap <silent> <C-S>          :update<CR>
vnoremap <silent> <C-S>         <C-C>:update<CR>
inoremap <silent> <C-S>         <C-O>:update<CR><Esc>

" Switching buffers
map <C-PageDown> :bnext!<cr>
map <C-PageUp> :bprevious!<cr>
imap <C-PageDown> <ESC>:bnext!<cr>
imap <C-PageUp> <ESC>:bprevious!<cr>

" enter CtrlP tag fuzzy search [ctrp.vim]
noremap <C-o> :CtrlPBufTag<CR>
noremap <C-l> :CtrlPLine<CR>

"tnoremap <Esc> <C-\><C-n>

" keep terminal buffer hidden on background on bn
autocmd TermOpen * set bufhidden=hide

let python_highlight_all = 1

" --- Airline -----------------------------------------------------------------

" show buffer bar
let g:airline#extensions#tabline#enabled = 1

" Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'


" --- CtrlP -------------------------------------------------------------------
"
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
" let g:ctrlp_cmd = 'CtrlPLastMode'

   let g:ctrlp_extensions = ['buffertag', 'tag', 'line', 'dir']

let g:ctrlp_custom_ignore = {
  \ 'dir':  '\v[\/]\.(git|hg|svn|venv)$',
  \ 'file': '\v\.(exe|so|dll)$',
  \ 'link': 'some_bad_symbolic_links',
  \ }


let g:tagbar_map_togglesort = "r"
let g:tagbar_map_preview = "<CR>"
let g:tagbar_map_jump = "<C-CR>"
218
let g:tagbar_autofocus = 1
Nelso Jost's avatar
Nelso Jost committed
219
220
221
222
223
224
225
let g:tagbar_expand = 1
let g:tagbar_indent = 1
let g:tagbar_compact = 1
let g:tagbar_sort = 0
let g:tagbar_width = 25


226
227
228
229
230
" don't give |ins-completion-menu| messages.  For example,
" '-- XXX completion (YYY)', 'match 1 of 2', 'The only match',
"set shortmess+=c


Nelso Jost's avatar
Nelso Jost committed
231
232
233
234
"let g:deoplete#enable_at_startup=1
"let g:deoplete#enable_refresh_always=0
"let g:deoplete#file#enable_buffer_path=1
"let g:deoplete#auto_completion_start_length = 0
235
236
237
238
239
240
"
"" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function() abort
  return deoplete#close_popup() . "\<CR>"
endfunction
Nelso Jost's avatar
Nelso Jost committed
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

"function! Completefunc(findstart, base)
    "return "\<c-x>\<c-p>"
"endfunction

" Don't let autocomplete affect usual typing habits
"set completeopt=menuone,preview,noinsert

""""""" Jedi-VIM """""""
" Don't mess up undo history<Paste>
"let g:jedi#show_call_signatures = "0"


"let g:deoplete#sources#jedi#show_docstring = 1


" for python completions
"let g:python_support_python3_requirements = add(get(g:,'python_support_python3_requirements',[]),'jedi')
" language specific completions on markdown file
"let g:python_support_python3_requirements = add(get(g:,'python_support_python3_requirements',[]),'mistune')

" utils, optional
"let g:python_support_python3_requirements = add(get(g:,'python_support_python3_requirements',[]),'psutil')
"let g:python_support_python3_requirements = add(get(g:,'python_support_python3_requirements',[]),'setproctitle')

"inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
"inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
"inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")

270
"set shortmess+=c
Nelso Jost's avatar
Nelso Jost committed
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

"let g:cm_auto_popup = 0
"
"

inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"


"let g:deoplete#disable_auto_complete = 1

"inoremap <silent><expr> <TAB>
"\ pumvisible() ? "\<C-n>" :
"\ <SID>check_back_space() ? "\<TAB>" :
"\ deoplete#mappings#manual_complete()
"function! s:check_back_space() abort "{{{
"let col = col('.') - 1
"return !col || getline('.')[col - 1]  =~ '\s'
"endfunction"}}}

"inoremap <silent> <C-CR> <C-r>=<SID>my_cr_function()<CR>
    "function! s:my_cr_function() abort
      "return deoplete#close_popup() . ""
      "endfunction
      "
"if &term =~ '^screen'
    " tmux will send xterm-style keys when its xterm-keys option is on
    "execute "set <xUp>=\e[1;*A"
    "execute "set <xDown>=\e[1;*B"
    "execute "set <xRight>=\e[1;*C"
    "execute "set <xLeft>=\e[1;*D"
"endif


304
" https://github.com/scrooloose/nerdtree
Nelso Jost's avatar
Nelso Jost committed
305
306
307
308
" How can I open a NERDTree automatically when vim starts up if no files were specified?
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

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

let g:vim_markdown_folding_disabled = 1

"au BufNewFile,BufFilePre,BufRead *.md set filetype=markdown tw=80 fo+=t colorcolumn=80

"=======================================================================
" http://vim.wikia.com/wiki/Move_cursor_by_display_lines_when_wrapping

noremap <silent> <Leader>w :call ToggleWrap()<CR>
function ToggleWrap()
  if &wrap
    echo "Wrap OFF"
    setlocal nowrap
    set virtualedit=all
    silent! nunmap <buffer> <Up>
    silent! nunmap <buffer> <Down>
    silent! nunmap <buffer> <Home>
    silent! nunmap <buffer> <End>
    silent! iunmap <buffer> <Up>
    silent! iunmap <buffer> <Down>
    silent! iunmap <buffer> <Home>
    silent! iunmap <buffer> <End>
  else
    echo "Wrap ON"
    setlocal wrap linebreak nolist
    set virtualedit=
    setlocal display+=lastline
    noremap  <buffer> <silent> <Up>   gk
    noremap  <buffer> <silent> <Down> gj
    noremap  <buffer> <silent> <Home> g<Home>
    noremap  <buffer> <silent> <End>  g<End>
    inoremap <buffer> <silent> <Up>   <C-o>gk
    inoremap <buffer> <silent> <Down> <C-o>gj
    inoremap <buffer> <silent> <Home> <C-o>g<Home>
    inoremap <buffer> <silent> <End>  <C-o>g<End>
  endif
endfunction

" http://vim.wikia.com/wiki/Remove_unwanted_spaces
autocmd BufWritePre * %s/\s\+$//e


let g:tagbar_type_markdown = {
  \ 'ctagstype' : 'markdown',
  \ 'kinds' : [
    \ 'h:Heading_L1',
    \ 'i:Heading_L2',
    \ 'k:Heading_L3'
  \ ]
\ }