init.vim 8.2 KB
Newer Older
Nelso Jost's avatar
Nelso Jost committed
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
      " --- https://github.com/junegunn/vim-plug ------------------------------
" Minimalist plugin manager. Update with --> :PlugInstall 
 " 
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

"Plug 'Shougo/deoplete.nvim'
"Plug 'davidhalter/jedi'
"Plug 'zchee/deoplete-jedi' 
" Plug 'davidhalter/jedi-vim'

Plug 'roxma/nvim-completion-manager'  " async, dynamic, completion


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

colorscheme molokai

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>

map  <F10> :ed ~/.config/nvim/init.vim<cr>

" open terminal split [term-split.vim]
map <C-t> :50VTerm<CR>
map <C-e> :40VTerm make<CR>

" 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>

" delete word under cursor
noremap <C-Space> ciw
inoremap <C-Space> <ESC>ciw

" easy tab ident
vnoremap <Tab> >
vnoremap <S-Tab> <
 
" easier split navigation
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    
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>"
let g:tagbar_autofocus = 1 
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


"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

"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>")

"set shortmess+=c 

"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


" https://github.com/scrooloose/nerdtree 
" 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