-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvimrc
165 lines (133 loc) · 3.83 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
"Get out of VI's compatible mode
set nocompatible
"Encoding
set encoding=utf-8
"Update time
set updatetime=300
"I like using light background terminal
set background=light
"Sets how many lines of history VIM has to remember
set history=1000
"Set to auto read when a file is changed from the outside
set autoread
"Keep buffer during switch files
set hidden
"No fold
set nofoldenable
"Always show current position
set ruler
"Show line number and wrap line
set number
set wrap
"Backspace and cursor keys wrap to
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
"show matching bracets
set showmatch
"Text options
set expandtab
set shiftwidth=4
set tabstop=4
set softtabstop=4
set smarttab
set linebreak
"Auto-complete filename command mode
set wildmode=list:longest,full
"Highlight search things
set hlsearch
set incsearch
"viminfo file
set viminfo+=n~/.vim/.viminfo
"swapfile dir
set directory=/tmp//
"noswapfile
"setlocal noswapfile
"Enable filetype
filetype plugin indent on
"Enable syntax hl
syntax enable
"Highlight trailing spaces/tabs
match ErrorMsg '\s\+$'
"Highlight settings in Visual select and Diff mode
highlight Search ctermfg=DarkBlue
highlight Visual ctermfg=White ctermbg=LightBlue
highlight CocListLine ctermbg=Gray
highlight DiffAdd cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffDelete cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffChange cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffText cterm=bold ctermfg=10 ctermbg=88 gui=none guifg=bg guibg=Red
"highlight Comment ctermfg=Blue
"Don't like q:
map q <Nop>
"When highlight words, don't jump to next
nnoremap * :let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR>:set hls<CR>
nnoremap <silent> <C-l> :nohls<CR><C-l>
"Map :Q to :q, :W to :w
cnoreabbrev Q <C-r>=(getcmdtype()==':'? 'q!' : 'Q')<CR>
cnoreabbrev W <C-r>=(getcmdtype()==':'? 'w' : 'W')<CR>
cnoreabbrev Wq <C-r>=(getcmdtype()==':'? 'wq' : 'Wq')<CR>
cnoreabbrev WQ <C-r>=(getcmdtype()==':'? 'wq' : 'WQ')<CR>
"Map VIM command/insert mode shortcut to bash shortcut
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <C-d> <Del>
cnoremap <C-k> <Nop>
inoremap <C-a> <Home>
inoremap <C-e> <End>
inoremap <C-k> <Up>
inoremap <C-j> <Down>
inoremap <C-b> <Left>
inoremap <C-f> <Right>
inoremap <C-d> <Del>
inoremap <C-c> <ESC>
inoremap <C-z> <ESC><C-z>
noremap <Leader>W :w !sudo tee % > /dev/null
"autocmd settings
if !exists("autocommands_loaded")
let autocommands_loaded = 1
"Strip trailing withspace
fun! StripTrailingWhitespace()
let l = line(".")
let c = col(".")
" if &ft =~ 'mkd'
" return
" endif
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufWritePre * call StripTrailingWhitespace()
endif
"FileType
autocmd FileType go setlocal noexpandtab
autocmd FileType html,javascript,css,json,jsonc,lua,yaml setlocal shiftwidth=2 tabstop=2 softtabstop=2
"vim-plug setting
fun! VimPlug()
call plug#begin('~/.vim/bundle')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'preservim/nerdtree', {'on': 'NERDTreeToggle'}
Plug 'preservim/vim-markdown'
Plug 'vim-airline/vim-airline'
call plug#end()
endfun
silent! call VimPlug()
"nerdtree plugin
nmap <F8> :NERDTreeToggle<CR>
"coc.nvim plugin
highlight CocFloating ctermbg=235 guibg=#13354A
highlight CocMenuSel ctermbg=237 guibg=#13354A
autocmd BufWritePre *.go :call CocAction('organizeImport')
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)
set tagfunc=CocTagFunc
let g:coc_data_home = '~/.vim/coc-data'
let g:coc_global_extensions = [
\'coc-json',
\'coc-yaml',
\'coc-pyright',
\'coc-snippets',
\'coc-tabnine'
\]