-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
324 lines (251 loc) · 8.3 KB
/
vimrc
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
set nocompatible
" Vundle Install {
let home_dir = expand('$HOME')
if !isdirectory(expand(home_dir . '/.vim/bundle/vundle/.git', 1))
execute "! git clone https://github.com/gmarik/vundle.git " . home_dir . "/.vim/bundle/vundle"
if v:shell_error
finish
else
silent ! vim +BundleInstall +qall
endif
endif
" }
filetype off
set rtp=~/.vim/bundle/vundle/,~/.vim,$VIMRUNTIME
let g:snippets_dir='~/.snippets/'
" Plugins {
call vundle#begin()
Plugin 'gmarik/vundle'
" use rg/ag if available
if executable('rg')
let g:ctrlsf_ackprg = 'rg'
let g:ackprg = 'rg --color=never --column --smart-case'
let g:ctrlp_user_command = 'rg %s -l --color=never -g ""'
elseif executable('ag')
let g:ackprg = 'ag --nogroup --nocolor --column --smart-case'
set grepprg=ag\ --nogroup\ --nocolor
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
endif
Plugin 'morhetz/gruvbox'
Plugin 'moll/vim-bbye'
Plugin 'groenewege/vim-less'
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'honza/vim-snippets'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
Plugin 'pangloss/vim-javascript'
Plugin 'mileszs/ack.vim'
let g:ctrlsf_auto_focus = { "at": "start" }
let g:ctrlsf_mapping = {
\ "quit": "q",
\ "next": "n",
\ "prev": "N",
\ "vsplit": "s",
\ }
Plugin 'dyng/ctrlsf.vim'
Plugin 'editorconfig/editorconfig-vim'
let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']
Plugin 'mattn/emmet-vim'
Plugin 'posva/vim-vue'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-git'
Plugin 'tpope/vim-unimpaired'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-ragtag'
Plugin 'tpope/vim-projectionist'
Plugin 'tpope/vim-dispatch'
Plugin 'tpope/vim-eunuch'
Plugin 'tpope/vim-rhubarb'
let g:ragtag_global_maps = 1
Plugin 'ctrlpvim/ctrlp.vim'
let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp'
let g:ctrlp_cmd = 'CtrlPMRU'
Plugin 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plugin 'junegunn/fzf.vim'
Plugin 'junegunn/goyo.vim'
if executable('prettier')
autocmd FileType javascript set formatprg=prettier\ --stdin
endif
Plugin 'mbbill/undotree'
if has("persistent_undo")
set undodir=~/.undodir/
set undofile
endif
set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v]
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
set laststatus=2
Plugin 'Lokaltog/vim-powerline'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'guns/vim-sexp'
Plugin 'tmhedberg/matchit'
" TypeScript
Plugin 'leafgarland/typescript-vim'
Plugin 'Shougo/vimproc.vim'
Plugin 'neoclide/coc.nvim', {'branch': 'release'}
let g:coc_global_extensions = [ 'coc-tsserver', 'coc-java', 'coc-snippets' ]
if executable('rustc')
" Rust
Plugin 'rust-lang/rust.vim'
endif
" Markdown
Plugin 'nelstrom/vim-markdown-folding'
let g:markdown_fold_style = 'nested'
if executable('stack')
" Haskell
Plugin 'eagletmt/ghcmod-vim.git'
Plugin 'eagletmt/neco-ghc'
Plugin 'godlygeek/tabular.git'
Plugin 'Shougo/neocomplete.vim.git'
Plugin 'haskell.vim'
Plugin 'cabal.vim'
if !executable('hlint')
execute "! stack install hlint ghc-mod"
endif
map <silent> <leader>ht :GhcModType<CR>
map <silent> <leader>hi :GhcModTypeInsert<CR>
map <silent> <leader>hc :GhcModTypeClear<CR>
map <silent> <leader>hs :GhcModSplitFunCase<CR>
map <silent> <leader>hc :GhcModCheck<CR>
endif
call vundle#end()
" }
" General {
set hidden
set clipboard=unnamedplus,unnamed
set encoding=utf-8
let g:gruvbox_contrast_dark = 'hard'
colorscheme gruvbox
" searching
set ignorecase
set smartcase
set incsearch
set showmatch
set hlsearch
set wrapscan
" avoid swap, temp and backup files
set nobackup
set nowritebackup
set noswapfile
" show the cursor position all the time
set ruler
" display incomplete commands
set showcmd
set wildmenu
" terminal settings
set t_Co=256
set mouse=a
set updatetime=300
if !has('nvim')
set ttymouse=xterm2
endif
" }
" Keyboard {
let mapleader=","
noremap <C-S> :w<CR>
inoremap <C-S> <C-O>:w<CR>
noremap <S-CR> <Esc>
set backspace=indent,eol,start " make backspace behave consistently with other apps
" delete trailing whitespace
nnoremap <silent> <leader>w :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" toggle NerdTree
noremap <leader>n<Space> :NERDTreeToggle<CR>
noremap <leader>nf :NERDTreeFind<CR>
noremap <leader>nr :NERDTreeRefreshRoot<CR>
" toggle UndoTree
nnoremap <leader>u :UndotreeToggle<CR>
" fzf
nnoremap <C-f> :FZF<CR>
" ctrlsf map
nmap <leader>f <Plug>CtrlSFPrompt
vmap <leader>f <Plug>CtrlSFVwordPath
vmap <leader>F <Plug>CtrlSFVwordExec
nnoremap R :CtrlSF <C-R><C-W> -R -W<CR>
" open file from same dir
map <leader>ew :e <C-R>=expand("%:h") . "/" <CR>
map <leader>vsw :vs <C-R>=expand("%:h") . "/" <CR>
" indent!
nnoremap <Tab> >>
nnoremap <S-Tab> <<
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" forward-back in history
noremap ( <C-o>
noremap ) <C-i>
" toggle spell
nnoremap <F8> :setlocal spell! spell?<CR>
" toggle paste
nnoremap <F9> :set invpaste paste?<CR>
set pastetoggle=<F9>
" local replace
vnoremap <C-r> "hy:%s/\<<C-r>h\>//gc<left><left><left>
nmap <leader>rn <Plug>(coc-rename)
nmap <leader>cx <Plug>(coc-codeaction)
nmap <leader>cf <Plug>(coc-fix-current)
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
nmap <silent> <c-k> <Plug>(coc-diagnostic-prev)
nmap <silent> <c-j> <Plug>(coc-diagnostic-next)
nmap <leader>b :Git blame<CR>
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#confirm() :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm(): "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
inoremap <silent><expr> <c-@> coc#refresh()
let g:coc_snippet_next = '<tab>'
" close buffer
nmap <leader>q :Bdelete<CR>
" eval buffer
nmap <leader>eb :%Eval<CR>
" focus mode
nnoremap <silent> <leader>z :Goyo<cr>:set linebreak<cr>
" cyrillic langmap
set langmap =Ч~,ЯQ,ВW,ЕE,РR,ТT,ЪY,УU,ИI,ОO,ПP,Ш{,Щ},АA,СS,ДD,ФF,ГG,ХH,ЙJ,КK,ЛL,ЗZ,ЬZ,ЦC,ЖV,БB,НN,МM,ч`,яq,вw,еe,рr,тt,ъy,уu,иi,оo,пp,ш[,щ],аa,сs,дd,фf,гg,хh,йj,кk,лl,зz,ьx,цc,жv,бb,нn,мm
" λ
inoremap ¬ <C-K>*l
if has("python")
python << EOL
import vim
def EvaluateCurrentRange():
eval(compile('\n'.join(vim.current.range).strip(),'','exec'),globals())
EOL
map <leader>py :py EvaluateCurrentRange()<CR>
endif
" }
" Coding {
set guifont=Consolas:h10
set number
syntax on
command FormatJsonFile %!jq
" show trailing whitespace
set list listchars=tab:>-,trail:.
" ignore binaries and artifacts
set wildignore=*.o,*.obj,*.bin,*.dll,*.zip
" exclude version control directories
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*
set wildignore+=*\\.git\\*,*\\.hg\\*,*\\.svn\\*
set completeopt=menuone
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set autoindent
set smartindent
set smarttab
filetype plugin indent on
autocmd BufRead,BufNewFile *.cshtml set filetype=html
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd BufRead,BufNewFile *.md set foldlevel=2
autocmd BufRead,BufNewFile *.json set filetype=json
autocmd FileType gitcommit setlocal spell
autocmd FileType markdown setlocal linebreak
autocmd FileType markdown nmap j gj
autocmd FileType markdown nmap k gk
let g:haskellmode_completion_ghc = 1
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
" }