-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
195 lines (159 loc) · 5.18 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
call plug#begin("~/.vim/plugged")
" editor
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-repeat'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'jesseleite/vim-agriculture'
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
Plug 'preservim/nerdtree'
Plug 'liuchengxu/vista.vim'
Plug 'jiangmiao/auto-pairs'
Plug 'chrisbra/unicode.vim'
Plug 'hashivim/vim-terraform'
Plug 'sheerun/vim-polyglot'
Plug 'honza/vim-snippets'
" Plug 'tidalcycles/vim-tidal'
" git
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'mhinz/vim-signify'
Plug 'flazz/vim-colorschemes'
Plug 'ap/vim-buftabline'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'ryanoasis/vim-devicons'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
call plug#end()
silent! colorscheme molokai_dark
let g:airline_theme="lucius"
set encoding=UTF-8
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" on pressing tab, insert 4 spaces
set expandtab
set foldmethod=indent
set nofoldenable
set nobackup
set nowritebackup
set signcolumn=yes
" show hidden chars
set list listchars=tab:>·,trail:~,extends:>,precedes:<,space:·
highlight SpecialKey ctermfg=darkgrey
" newline between yanks
set cpoptions+=>
" include dashes for text-objects
set iskeyword+=-
" line numbers
set relativenumber
set hidden
set splitright
" backup history
set undofile
if !has("nvim")
set undodir=~/.vim/undo
endif
" default updatetime 4000ms is not good for async update
set updatetime=250
" already been welcomed
set shortmess=I
let g:airline#extensions#tagbar#enabled = 1
let g:airline#extensions#tagbar#flags = 'f'
" better key bindings for UltiSnipsExpandTrigger
" let g:UltiSnipsExpandTrigger = "<tab>"
" let g:UltiSnipsJumpForwardTrigger = "<tab>"
" let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
" ignore files
let g:NERDTreeIgnore = [ "__pycache__" ]
let g:NERDTreeQuitOnOpen=1
let g:gutentags_file_list_command = 'rg --files'
let g:gutentags_cache_dir = "~/.local/share/ctags"
" format tf on save
let g:terraform_fmt_on_save=1
let g:terraform_align=1
" nav
nnoremap <C-j> :bprev<CR>
nnoremap <C-k> :bnext<CR>
nnoremap <C-h> :tabprev<CR>
nnoremap <C-l> :tabnext<CR>
inoremap <C-j> <down>
inoremap <C-k> <up>
cnoremap <C-A> <Home>
cnoremap <C-B> <Left>
" leader key
let mapleader = " "
nmap <leader>/ <Plug>RgRawSearch
vmap <leader>/ <Plug>RgRawVisualSelection
nmap <leader>* <Plug>RgRawWordUnderCursor
nmap <leader>rg :Rg<CR>
nnoremap <leader>x :bd!<CR>
nnoremap <leader>h :set hlsearch!<CR>
nnoremap <leader>f :GitFiles<CR>
nnoremap <leader>F :Files<CR>
nnoremap <leader>vr :source $MYVIMRC<CR>
nnoremap <leader>ve :e $MYVIMRC<CR>
nnoremap <leader>s :w<CR>
nnoremap <leader>z :RgRaw -g % ' '<CR>
nnoremap <leader>t :NERDTreeToggle<CR>
nnoremap <leader>T :Tags<CR>
nnoremap <leader>C :History:<CR>
nnoremap <C-f> :NERDTreeFind<CR>
vnoremap <C-C> "+y :exec "echo 'copied to clipboard'"<CR>h
nmap <leader>R gg=G<C-o><C-o>
" ### coc.nvim START ###
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocActionAsync('format')
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gr <Plug>(coc-references)
" Hover
nmap <silent> <leader>? :call CocActionAsync('doHover')<CR>
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
nmap <silent> <leader>cf :Format<CR>
" Use <c-space> to trigger completion.
inoremap <silent><expr><c-space> coc#refresh()
" Mappings for CoCList
nnoremap <silent><nowait> <leader>cl :<C-u>CocList<CR>
nnoremap <silent><nowait> <leader>cd :<C-u>CocList diagnostics<CR>
nnoremap <silent><nowait> <leader>ce :<C-u>CocList extensions<CR>
nnoremap <silent><nowait> <leader>cc :<C-u>CocList commands<CR>
nnoremap <silent><nowait> <leader>co :<C-u>CocList outline<CR>
nnoremap <silent><nowait> <leader>cs :<C-u>CocList -I symbols<CR>
nnoremap <silent><nowait> <leader>cj :<C-u>CocNext<CR>
nnoremap <silent><nowait> <leader>ck :<C-u>CocPrev<CR>
nnoremap <silent><nowait> <leader>cr :<C-u>CocListResume<CR>
" class/func text objects
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" ### coc.nvim END ###
" Surround like delete/change surrounding function calls
nmap <silent> dsf ds)db
nnoremap <silent> csf [(cb
" change word & repeat with .
nnoremap c* *Ncgn
" git
nnoremap <leader>ge :vsp<CR>:Gedit master:%
vnoremap <leader>gg :GBrowse<CR>
augroup vimrc
autocmd!
autocmd FileType javascript,yaml,json,markdown,terraform,tf,html,css,dosini,vue set tabstop=2 softtabstop=2 shiftwidth=2 expandtab
autocmd FileType go set noexpandtab
autocmd FileType python set foldmethod=indent
autocmd BufNewFile,BufRead *.liq set filetype=liquidsoap
autocmd BufNewFile,BufRead */.kube/config set filetype=yaml
autocmd InsertEnter,InsertLeave * set cul!
augroup END