-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlite.vimrc
More file actions
382 lines (286 loc) · 9.25 KB
/
lite.vimrc
File metadata and controls
382 lines (286 loc) · 9.25 KB
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
"----------------------------------------------------------------
" Stripped down .vimrc configuration file
"----------------------------------------------------------------"
" Disable vi compatibility
if !has("nvim")
set nocompatible
endif
" Reload .vimrc
nnoremap <F12> :so $MYVIMRC<CR>
" Enable local .vimrc config
set exrc
set secure
" Lines of memory to remember
set history=10000
" Time delay on <Leader> key
set timeoutlen=3000 ttimeoutlen=100
" Update time
set updatetime=250
" Trigger InsertLeave autocmd
inoremap <C-c> <Esc>
" No need for Ex mode
nnoremap Q <NOP>
" Set inc/dec
set nrformats-=octal
" Start NERDTree and put the cursor back in the other window.
autocmd VimEnter * NERDTree | wincmd p
" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | call feedkeys(":quit\<CR>:\<BS>") | endif
nnoremap <leader>tt :FloatermToggle<CR>
"----------------------------------------------------------------
" 2. Plugins (Plug)
"----------------------------------------------------------------
" Install Plugins
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" List of plugins installed
call plug#begin('~/.vim/plugged')
" Statusbar
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'airblade/vim-gitgutter'
" Tools
Plug 'preservim/nerdcommenter', { 'commit': 'a5d1663' }
Plug 'preservim/nerdtree'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'voldikss/vim-floaterm'
" Edition
Plug 'junegunn/vim-easy-align'
Plug 'godlygeek/tabular'
Plug 'tpope/vim-fugitive'
Plug 'jiangmiao/auto-pairs'
" Themes
Plug 'tyrannicaltoucan/vim-deep-space'
call plug#end()
"----------------------------------------------------------------
" Plugin settings
"----------------------------------------------------------------
" --- Statusbar ---
" Airline settings
let g:airline_theme = 'luna'
let g:airline_powerline_fonts = 1
let g:airline_section_z = airline#section#create([
\ '%1p%% ',
\ 'Ξ%l%',
\ '\⍿%c'])
" --- Git tools ---
" Gitgutter settings
let g:gitgutter_max_signs = 5000
let g:gitgutter_sign_added = '+'
let g:gitgutter_sign_modified = '»'
let g:gitgutter_sign_removed = '_'
let g:gitgutter_sign_modified_removed = '»╌'
let g:gitgutter_map_keys = 0
let g:gitgutter_diff_args = '--ignore-space-at-eol'
nmap <Leader>j <Plug>(GitGutterNextHunk)zz
nmap <Leader>k <Plug>(GitGutterPrevHunk)zz
nnoremap <silent> <C-g> :call <SID>ToggleGGPrev()<CR>zz
nnoremap <Leader>ga :GitGutterStageHunk<CR>
nnoremap <Leader>gu :GitGutterUndoHunk<CR>
" Fugitive settings
nnoremap <C-s> :call <SID>ToggleGstatus()<CR>
nnoremap <Leader>gv :Gvdiffsplit<CR>:windo set wrap<CR>
nnoremap <Leader>gh :Gvdiffsplit HEAD<CR>:windo set wrap<CR>
nnoremap <Leader>gb :Gblame<CR>
"----------------------------------------------------------------
" User interface
"----------------------------------------------------------------
" Vim theme"
set background=dark
set termguicolors
colorscheme deep-space
" Vim airline theme"
let g:airline_theme='luna'
" Set X lines to the cursor when moving vertically
set scrolloff=0
" Always show mode
set showmode
" Show command keys pressed
set showcmd
" Enable the WiLd menu
set wildmenu
" Show the current position
set ruler
" Command bar height
set cmdheight=2
" Backspace works on Insert mode
set backspace=eol,start,indent
" Don't redraw while executing macros (good performance config)
set lazyredraw
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set matchtime=2
" No annoying sound on errors
set noerrorbells
set novisualbell
" Mouse
set mouse=a
" Highlight cursor line and cursor column
set cursorline
set nocursorcolumn
" Always show the status line
set laststatus=2
" Change the cursor shape
if !has("nvim")
if &term != "linux"
let &t_SI = "\<Esc>[6 q"
let &t_SR = "\<Esc>[4 q"
let &t_EI = "\<Esc>[2 q"
endif
else
set guicursor=n-v:block-Cursor/lCursor-blinkon0
set guicursor+=i-ci-c:ver100-Cursor/lCursor-blinkon0
set guicursor+=r-cr:hor100-Cursor/lCursor-blinkon0
endif
" Omni completion
if has('autocmd') && exists('+omnifunc')
autocmd Filetype *
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
endif
" Fix italics issue
if !has("nvim")
let &t_ZH="\e[3m"
let &t_ZR="\e[23m"
endif
"----------------------------------------------------------------
" Files and backup
"----------------------------------------------------------------
" Disable swap files
set noswapfile
" No backup (use Git instead)
set nobackup
" Prevents automatic write backup
set nowritebackup
" Use UTF-8 as default encoding
set encoding=utf8
" Use Unix as the standard file type
set fileformats=unix,dos,mac
" Autoread a file when it is changed from the outside
set autoread
" Reload a file when it is changed from the outside
let g:f5msg = 'Buffer reloaded.'
nnoremap <F5> :e<CR>:echo g:f5msg<CR>
" Enable filetype plugins
filetype plugin on
filetype indent on
"----------------------------------------------------------------
" Indentation tabs
"----------------------------------------------------------------
" Enable autoindent & smartindent
set autoindent
set smartindent
" Use tabs, no spaces
set expandtab
" Be smart when using tabs
set smarttab
" Tab size (in spaces)
set shiftwidth=4
set tabstop=4
" Remap indentation
nnoremap <TAB> >>
nnoremap <S-TAB> <<
vnoremap <TAB> >gv
vnoremap <S-TAB> <gv
inoremap <TAB> <C-i>
inoremap <S-TAB> <C-d>
" Don't show tabs
set list
" Show tabs and end-of-lines
set listchars=tab:┊\ ,trail:¬
"----------------------------------------------------------------
" Moving around lines
"----------------------------------------------------------------
" Specify which commands wrap to another line
set whichwrap+=<,>,h,l
" Many jump commands move the cursor to the start of line
set nostartofline
" Wrap lines into the window
set wrap
" Don't break the words
" Only works if I set nolist (F6)
set linebreak
set showbreak=↳\
" Stop automatic wrapping
set textwidth=0
" Listings don't pause
set nomore
" Show line numbers
set number
set numberwidth=2
let g:f3msg = 'Toggle line numbers.'
nnoremap <silent> <F3> :set number!<CR>:echo g:f3msg<CR>
let g:f4msg = 'Toggle relative line numbers.'
nnoremap <silent> <F4> :set norelativenumber!<CR>:echo g:f4msg<CR>
" Treat long lines as break lines (useful when moving around in them)
nnoremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
nnoremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
vnoremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
vnoremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
nnoremap <Home> g^
nnoremap <End> g$
vnoremap <Home> g^
vnoremap <End> g$
" Toggle the cursor position start/end of the line
nnoremap <silent> ñ :call <SID>ToggleCPosition('')<CR>
vnoremap <silent> ñ <Esc>:call <SID>ToggleCPosition('normal! gv')<CR>
" Join / split lines
nnoremap <C-j> J
nnoremap <C-k> i<CR><Esc>
" Duplicate a line
nnoremap cx yyP
nnoremap cv yyp
" Folding
set foldmethod=marker
" Return to last edit position when opening files
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
"----------------------------------------------------------------
" Text edition
"----------------------------------------------------------------
" Toggle case
nnoremap <Leader>z ~
vnoremap <Leader>z y:call setreg('', ToggleCase(@"), getregtype(''))<CR>gv""Pgv
vnoremap ~ y:call setreg('', ToggleCase(@"), getregtype(''))<CR>gv""Pgv
" Toggle and untoggle spell checking
let g:f8msg = 'Toggle spell checking.'
nnoremap <silent> <F8> :setlocal spell!<CR>:echo g:f8msg<CR>
" Toggle spell dictionary
nnoremap <silent> <F9> :call <SID>ToggleSpelllang()<CR>
" Move to next misspelled word
nnoremap zl ]s
" Find the misspelled word before the cursor
nnoremap zh [s
" Suggest correctly spelled words
nnoremap zp z=
" Copy text into the clipboard
vnoremap <Leader>y "+y
" Paste text from the clipboard
nnoremap <Leader>p "+p
" Quickly select the text pasted from the clipboard
nnoremap gV `[v`]
" Yank everything from the cursor to the EOL
nnoremap Y y$
" Yank the last pasted text automatically
vnoremap p pgvy
" Retab the selected text
nnoremap <Leader>tf :retab!<CR>
vnoremap <Leader>tf :retab!<CR>
" Isolate the current line
nnoremap <Leader>o m`o<Esc>kO<Esc>``
" Enter a new line Down from 'Normal Mode'
nnoremap <Leader>f mao<Esc>`a
" Enter a new line Up from 'Normal Mode'
nnoremap <Leader>F maO<Esc>`a
if &term =~ 'xterm'
" When exiting Vim, set cursor to vertical bar |
autocmd VimLeave * silent !echo -ne "\e[6 q"
endif