forked from carlosedp/vimfiles
-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.vim
343 lines (241 loc) · 7.56 KB
/
init.vim
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
"" Use Vim settings, rather then Vi settings (much better!).
"" This must be first, because it changes other options as a side effect.
set nocompatible
set modeline
set ttyfast
"" Hides the buffer instead of closing. Allows switch unsaved buffers.
set hidden
"" No backup and swap files
set nobackup
set noswapfile
" set column color to 80 chars
set colorcolumn=80
" set English language
set langmenu=none
" Better modes. Remeber where we are, support yankring
set viminfo=!,'100,\"100,:20,<50,s10,h,n~/.viminfo
"" Do not return to start of line
set nostartofline
"" Disable ALT keys access to menubar. Makes mappings work.
set winaltkeys=no
set history=500 " keep 500 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set number " show line numbers
"" set search ignorecase
set ignorecase
set smartcase
set incsearch " do incremental searching
set hlsearch
"" Remaps search
nnoremap / /\v
vnoremap / /\v
"" All matches in a line are substituted instead of one
set gdefault
"" Automatically change working dir to current buffer
"set autochdir
"" Disable bell
set vb
"" Set GUI Options and scrollbars
set guioptions=egmrLtTb
"" Remove the 'tear bla bla from menus'
set guioptions-=t
"" Set narrow linespace
set linespace=0
" Tab completion
set wildmenu "Turn on WiLd menu
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,*.rbc,*.class,.svn,test/fixtures/*,vendor/gems/*
"Set magic on, for regular expressions
set magic
" Backspace and cursor keys wrap to previous/next line
set backspace=indent,eol,start
set whichwrap+=<,>,[,],h,l
"" set filetype check on
filetype plugin indent on
syntax on
"" Set colorschemes
set background=dark
colorscheme distinguished
""Minimal number of screen lines to keep above and below the cursor.
set scrolloff=3
set expandtab
""setting about indent
set autoindent
set smartindent
" No extra space when join lines
set nojoinspaces
"" Wrap text
set showbreak=...
set linebreak
set formatoptions=qrn1
" Display invisible characters.
" Use the same symbols as TextMate for tabstops and EOLs
"set listchars=eol:?,tab:>-,trail:~,extends:>,precedes:<
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
set nolist
" add to autocomplete the dictionary
set complete+=k
" for XSL / CSS - completition works great
set iskeyword+=-,:
""setting about old window resizing behavior when open a new window
set winfixheight
"" not let all windows keep the same height/width
set noequalalways
"" Highlight current line and set color
set cursorline
"" Allow cursor to be positioned anywhere in block select mode
set virtualedit=block
"" Use Unix format for files
"set sessionoptions+=unix,slash,localoptions
set sessionoptions=buffers,curdir,folds,help,winpos,winsize,tabpages,unix,slash,localoptions
"" Disable code folding
set nofoldenable
" Remember cursor position
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
" Resize splits when the window is resized
au VimResized * exe "normal! \<c-w>="
" Status line
set laststatus=3
"<home> toggles between start of line and start of text
imap <khome> <home>
nmap <khome> <home>
inoremap <silent> <home> <C-O>:call Home()<CR>
nnoremap <silent> <home> :call Home()<CR>
function! Home()
let curcol = wincol()
normal ^
let newcol = wincol()
if newcol == curcol
normal 0
endif
endfunction
"" Word count functions
let g:word_count="<unknown>"
fun! WordCount()
return g:word_count
endfun
function! UpdateWordCount()
let lnum = 1
let g:word_count = 0
while lnum <= line('$')
let g:word_count = g:word_count + len(split(getline(lnum)))
let lnum = lnum + 1
endwhile
return g:word_count
endfunction
augroup WordCounter
au! BufRead,BufNewFile,BufEnter,CursorHold,CursorHoldI,InsertEnter,InsertLeave * call UpdateWordCount()
augroup END
" how eager are you? (default is 4000 ms)
set updatetime=500
"""""""""""""""""""""""""""""""""""""""
"""""""""" Plugin Parameters """"""""""
"""""""""""""""""""""""""""""""""""""""
"" NERDTree Parameters
"" Quit on opening files from the tree
let NERDTreeQuitOnOpen=0
" Highlight the selected entry in the tree
let NERDTreeHighlightCursorline=1
"" Open NERDTree in same dir
let NERDTreeChDirMode=1
"" Show hidden files by default
let NERDTreeShowHidden=1
"Command-T configuration
let g:CommandTMaxHeight=10
let g:CommandTMatchWindowAtTop=1
""""""""""""""""""""""""""""""""""""""
"""""""""""" Key Mappings """"""""""""
""""""""""""""""""""""""""""""""""""""
"" Fast find selected text
map , y/<C-R>"/<cr>
"" Inserts hard tab in INSERT mode
inoremap <leader><Tab> <C-V><Tab>
"" Edits vimrc file
map <leader>e :e $HOME/.config/nvim/init.vim<CR>
"" Creates new empty buffer
nmap <C-N> :enew<CR>
"" Cycles between windows
nnoremap <leader><tab> <C-W>w
"" Cycles between buffers
map <silent> <C-i> :buffer #<CR>
"" Toggles NERDTree
imap <silent> <F1> <esc>:NERDTreeFind<CR>
nmap <silent> <F1> :NERDTreeFind<CR>
"" List/Next/Previous buffers
map <silent> <F3> <esc>:bp<CR>
imap <silent> <F3> <C-O>:bp<CR>
map <silent> <F4> <esc>:bn<CR>
imap <silent> <F4> <C-O>:bn<CR>
"" Toggle between Wrap and no Wrap lines
map <F5> :set nowrap!<CR> :set wrap?<CR>
imap <F5> <C-O>:set nowrap!<CR>
"" Toggle between display line endings
map <silent> <F6> :set nolist!<CR>
imap <silent> <F6> <C-O>:set nolist!<CR>
"" Closes buffer
nmap <C-x> :bdelete<CR>
"" Remaps Shift + v to select line without newline char in visual mode
nnoremap <leader>v 0vg_
"" Closes current window
nnoremap <M-w> <C-w>c<esc>
"" Pressing < or > will let you indent/unident selected lines
vnoremap < <gv
vnoremap > >gv
" Unimpaired configuration
" Bubble single lines
nmap <C-Up> [e
nmap <C-Down> ]e
" Bubble multiple lines
vmap <C-Up> [egv
vmap <C-Down> ]egv
"" Split vertical window and switch to it
nnoremap <leader>s <C-w>v<C-w>l
"" Split horizontal window and switch to it
nnoremap <leader>h :split<CR>
"" Taglist Toggle
map <silent> <leader>tl :TagbarToggle<CR>
"" Search word under cursor
nnoremap , /<C-R><C-W><CR>N
"" Clear highlight
nnoremap <silent> <leader><space> :noh<CR>
"" Make cursor move as expected with wrapped lines (in insert mode only with Ctrl key)
nnoremap <silent> <Up> gk
nnoremap <silent> <Down> gj
inoremap <silent> <C-Up> <C-O>gk
inoremap <silent> <C-Down> <C-O>gj
"" Changes line filetype endings
map <leader>fu :set ff=unix<CR>
map <leader>fd :set ff=dos<CR>
map <leader>fm :set ff=mac<CR>
"" Remaps J to gJ to join lines without spaces
map J gJ
"" Replace
nnoremap <leader>r :%s/\v/<left>
""Reload VIM
map <silent> <leader>V :source ~/.config/nvim/init.vim<CR>:filetype detect<CR>:exe ":echo 'config reloaded'"<CR>
""Use sudo to open/edit a file
cmap w!! w !sudo tee % >/dev/null
" paste from system clipboard
nnoremap <leader>p :set paste<CR>"+p<CR>:set nopaste<CR>
" yank to system clipboard
nnoremap <leader>y "+y
vnoremap <leader>y "+y"
set completeopt=menu,menuone,noselect,noinsert
set synmaxcol=250
" Terraform
let g:terraform_fmt_on_save=0
" Disable quote concealing in JSON files
let g:vim_json_conceal=0
let g:vim_json_syntax_conceal = 0
"Init lua
lua require('user.init')
" trigger `autoread` when files changes on disk
set autoread
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif
" notification after file change
autocmd FileChangedShellPost *
\ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None
nnoremap <silent> <C-w>- :exe "resize " . (winheight(0) * 3/4)<CR>
nnoremap <silent> <C-w>+ :exe "resize " . (winheight(0) * 10/9)<CR>
hi DiagnosticError ctermfg=Red