forked from nikitavoloboev/ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
343 lines (279 loc) · 9.18 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
" Autocomplete engine
function! DoRemote(arg)
UpdateRemotePlugins
endfunction
" Install plugins
call plug#begin()
" Looks
Plug 'nikitavoloboev/vim-monokai-night' " Theme
Plug 'itchyny/lightline.vim' " Light and configurable statusline/tabline plugin.
" Utility
Plug 'romainl/vim-cool' " Stop matching after search is done.
Plug 'jiangmiao/auto-pairs' " Insert or delete brackets, parens, quotes in pair.
Plug 'w0rp/ale' " Asynchronous Lint Engine.
Plug 'honza/vim-snippets' " Snippet files for various programming languages.
Plug 'sbdchd/neoformat' " Format code.
Plug 'rizzatti/dash.vim' " Search Dash app.
Plug 'jremmen/vim-ripgrep' " Use RipGrep in Vim and display results in a quickfix list.
" Prettier support
Plug 'prettier/vim-prettier', {
\ 'do': 'npm install',
\ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown', 'vue'] }
Plug 'scrooloose/nerdcommenter' " Quick comments.
Plug 'unblevable/quick-scope' " Highlight f, F jumps.
Plug 'Shougo/vimproc.vim', {'do' : 'make'} " Interactive command execution.
Plug 'tpope/vim-repeat' " Enable repeating supported plugin maps.
Plug 'tpope/vim-surround' " Quoting/parenthesizing made simple.
Plug 'junegunn/vim-easy-align' " Simple, easy-to-use alignment.
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } " Fzf search.
Plug 'junegunn/fzf.vim' " Fzf search.
Plug 'wakatime/vim-wakatime' " Automatic time tracking.
Plug 'haya14busa/incsearch.vim' " Improved incremental searching.
Plug 'easymotion/vim-easymotion' " Vim motions on speed.
Plug 'thinca/vim-quickrun' " Run commands quickly.
" Git
Plug 'tpope/vim-fugitive' " Git wrapper.
Plug 'mhinz/vim-signify' " Show a diff using Vim its sign column.
" Deoplete
Plug 'Shougo/deoplete.nvim', { 'do': function('DoRemote') } " Asynchronous completion framework.
Plug 'zchee/deoplete-jedi' " Deoplete source for jedi.
" Vim
Plug 'Shougo/neco-vim', { 'for': 'vim' } " Vim source for neocomplete/deoplete.
" Nix
Plug 'LnL7/vim-nix', { 'for': 'nix' } " Vim configuration files for Nix.
call plug#end()
" Options
set mouse=a " Copy selected text with mouse to system clipboard
set undofile " Save undos after file closes
set wildmode=longest:list,full " Complete longest common string, then each full match
set updatetime=250 " If this many milliseconds nothing is typed the swap file will be written to disk
set visualbell " Turn off the audio bell
set clipboard^=unnamed " Copy text to system clipboard
set gdefault " Always do global substitutions
set title " Set terminal title
set whichwrap+=<,>,[,]
set completeopt-=preview " No annoying scratch preview above
set expandtab " Spaces on tabs
set shiftwidth=4
set softtabstop=2
set undolevels=1000
set smartindent " Indentation
set shortmess=Ia " Disable startup message
set fileencoding=utf-8 " Encoding when written to file
set fileformat=unix " Line endings
set timeout timeoutlen=1000 ttimeoutlen=10 " TODO: ?
set autowrite " Automatically save before :next, :make etc
set ignorecase " Search case insensitive:
set smartcase " .. but not when search pattern contains upper case characters
set nocursorcolumn
set nocursorline
set number
set wrap
set textwidth=79
set formatoptions=qrn1
set notimeout
set ttimeout
set ttimeoutlen=10
set nobackup " Don't create annoying backup files
set path=+** " Search down into subfolders
" Folding
set foldcolumn=1
set foldlevel=20
set foldlevelstart=7
set foldmethod=syntax
set foldignore=""
set nofoldenable
" Buffers
set hidden
" Searching
set wrapscan
set ignorecase
set smartcase
set gdefault
" Usable 'Tab'
set shiftwidth=4
set tabstop=4
set softtabstop=4
set expandtab
" UI
set cursorline " Highlight current line
set showmatch
set tabstop=4 " Default indentation is 4 spaces long and uses tabs, not spaces
set matchtime=2
set termguicolors " Enable true colors support
let python_highlight_all = 1
set completeopt+=menu,menuone " Completion
let $NVIM_TUI_ENABLE_TRUE_COLOR=1 " True color
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" Open help vertically
command! -nargs=* -complete=help Help vertical belowright help <args>
autocmd FileType help wincmd L
:autocmd InsertEnter,InsertLeave * set cul! " Notify on mode change visually
set grepprg=rg\ --vimgrep
set grepformat^=%f:%l:%c:%m
set viewoptions=cursor,slash,unix
" Plugins
let g:deoplete#enable_at_startup = 1 " Activate deoplete
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] " Trigger a highlight in the appropriate direction when pressing these keys
let g:incsearch#auto_nohlsearch = 1 " TODO
" Theme
colorscheme monokai-night
" Bufferline
let g:bufferline_echo = 0
" Called once right before you start selecting multiple cursors
function! Multiple_cursors_before()
if exists('g:deoplete#disable_auto_complete')
let g:deoplete#disable_auto_complete = 1
endif
endfunction
" Called once only when the multiple selection is canceled (default <Esc>)
function! Multiple_cursors_after()
if exists('g:deoplete#disable_auto_complete')
let g:deoplete#disable_auto_complete = 0
endif
endfunction
let g:multi_cursor_exit_from_visual_mode = 0
let g:multi_cursor_exit_from_insert_mode = 0
let g:AutoPairsFlyMode = 0
let g:AutoPairsShortcutToggle = '<C-P>'
au filetype vim let b:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'", '`':'`'} " Don't autocomplete in vim
" Vim session
let g:session_autosave="no"
let g:session_autoload="no"
" Autocomplete with tab
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" Activate leader for easymotion
map <Leader> <Plug>(easymotion-prefix)
" Advanced customization using autoload functions
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'})
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nnoremap ga <Plug>(EasyAlign)
" _Insert mappings
inoremap jk <Esc>
inoremap kj <Esc>
inoremap (; ();<Esc>o
inoremap () ()
"Command mappings
cabbrev rp Rp
" CTRL mappings
nnoremap <C-L> :Files<CR>
" Space mappings
nnoremap <SPACE> <Nop>
let mapleader="\<Space>"
let maplocalleader = "\<Space>"
nnoremap <leader>= yypVr=
" Space z
nmap <Leader>ze :enew <CR>
nmap <Leader>zt :tabnew<CR>
" Space p
nnoremap <Leader>pi :PlugInstall<CR>
nnoremap <Leader>pu :PlugUpdate<CR>
" Space w
" Save
nmap <Leader>w :w<CR>
" Space e
"nmap <Leader>e <Plug>(Prettier) :w<CR>
" Space e
" nmap <Leader>e. :e .<CR>
" Search files inside current dir
" nnoremap <Leader>e :Files<CR>
" Space d
nmap <Leader>d :bd<CR>
" Space a
nnoremap <Leader>a :wq<CR>
" Space v
" Write all changed buffers and exit vim
nnoremap <Leader>vq :wqall<CR>
nnoremap <Leader>vQ :qa<CR>
nnoremap <Leader>vm :make<CR>
" Space o
" Move 10 lines down (for karabiner sticky keys)
nnoremap <Leader>o 29jzz
" Space i
nnoremap <Leader>ii :PlugInstall<CR>
" Update plugins
nnoremap <Leader>iu :PlugUpdate<CR>
" Check vim health
nnoremap <Leader>ih :CheckHealth<CR>
" Space c
" Switch dir for fzf searching to current dir
map <Leader>cd :lcd %:p:h<CR>
" Space l
" Yank xml block to next line
nnoremap <Leader>l vat:t'><CR>'[<Esc><CR>
" Space t
nmap <Leader>to :e %:p:h<CR>
" Yank function block
nnoremap <Leader>tgt :exe search('^function','cb')';/}/y'<CR>
" Dash doc lookup
nnoremap <Leader>ttt :Dash<CR>
" Write all changed buffers
nnoremap <Leader>tttt :wa<CR>
" Run commands in new splits
nnoremap <Leader>tt :tabedit <Bar> term.
nnoremap <Leader>ts :split <Bar> term.
nnoremap <Leader>tv :vsplit <Bar> term.
" Space s
" Buffer control
nmap <Leader>s :bprevious<CR>
" Source vimrc
nnoremap <Leader>ss :source ~/.dotfiles/nvim/init.vim<CR>
" Space n
nmap <Leader>n :bnext<CR>
" Search lines with fzf
nnoremap <silent> <Leader>n :Lines<CR>
" Space q
nmap <Leader>q :q<CR>
" Space y
" Yank whole file
nnoremap <Leader>y :%y<CR>
" Space f
nmap <Leader>fw :Autoformat<CR>
nmap <Leader>ff :FZF <CR>
nmap <Leader>fb :Buffers <CR>
nmap <Leader>fl :BLines <CR>
nmap <Leader>fL :Lines <CR>
nmap <Leader>fh :History<CR>
nmap <Leader>f; :History:<CR>
nmap <Leader>f: :Commands<CR>
nmap <Leader>ft :BTags<CR>
nmap <Leader>fT :Tags<CR>
nmap <Leader>fm :Marks<CR>
nmap <Leader>fw :Windows<CR>
nmap <Leader>fs :Snippets<CR>
nmap <Leader>fg :BCommits<CR>
nmap <Leader>fG :Commits<CR>
" Space o
nmap <Leader>o :Files %:p:h<CR>
nmap <Leader>O :GFiles <CR>
" Mapping selecting mappings
nnoremap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
" For conceal markers
if has('conceal')
set conceallevel=2 concealcursor=nc
endif
" Auto commands
au FileType dirvish call fugitive#detect(@%)
au FocusLost * :wa " Auto save everything
" Remaps
" Search and replace
xnoremap gs y:%s/<C-r>"//g<Left><Left>
" Yank a line with Y.
nnoremap Y y$
" Functions
" Other
set guicursor=n-v-c:hor20,i-ci:ver20 " Make cursor block in insert mode and underline in normal mode
autocmd VimLeave * set guicursor=a:ver25-blinkon25 " Make cursor block when leaving to shell
" Testing
set signcolumn=yes
nnoremap <C-q> :q<cr>:q<cr>
set foldcolumn=0 " Remove sidebar column