-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc.vim
264 lines (215 loc) · 6.66 KB
/
vimrc.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
" Copyright (C) 2020 Ace <[email protected]>
"
" This program is free software: you can redistribute it and/or modify
" it under the terms of the GNU General Public License as published by
" the Free Software Foundation, either version 3 of the License, or
" (at your option) any later version.
"
" This program is distributed in the hope that it will be useful,
" but WITHOUT ANY WARRANTY; without even the implied warranty of
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" GNU General Public License for more details.
"
" You should have received a copy of the GNU General Public License
" along with this program. If not, see <http://www.gnu.org/licenses/>.
set nocompatible
let s:home = expand('<sfile>:p:h')
let s:common_path = s:home . '/bundle'
if !has('nvim')
let g:vimrc = s:home . '/vimrc'
else
let g:vimrc = s:home . '/init.vim'
endif
let s:before_vimrc = s:home . '/before.vim'
if filereadable(s:before_vimrc)
execute('source ' . s:before_vimrc)
endif
let &runtimepath = &runtimepath . ',' . s:home
call aceforeverd#settings#my_init()
" global leader
let g:mapleader = ','
" local leader
let g:maplocalleader = ';'
" =============================================================== "
" Plugin Manager, in order
" 1. minpac
" 2. lazy.nvim
" =============================================================== "
call aceforeverd#plugin#setup()
" =============================================================== "
" Basic settings
" =============================================================== "
filetype plugin on
filetype indent on
let $LANG='en'
set langmenu=en
" Ignore compiled files
set wildignore=*.o,*~,*.pyc,*.gch
if has('win16') || has('win32')
set wildignore+=.git\*,.hg\*,.svn\*
else
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store,*/node_modules/*
endif
set autoread
set ruler
set cmdheight=2
set scrolloff=3
set hidden
set ignorecase
set smartcase
set hlsearch
set incsearch
set lazyredraw
set magic
set showmatch
set matchtime=2
set history=1000
set wildmenu
set backspace=indent,eol,start
set dictionary+=/usr/share/dict/words
set spelllang=en_us,en,cjk
set showcmd
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set signcolumn=yes
" enable italic for vim
let &t_ZH="\e[3m"
let &t_ZR="\e[23m"
set timeoutlen=500
set updatetime=250
if has('gui_macvim')
augroup gp_gui_macvim
autocmd!
autocmd GUIEnter * set vb t_vb=
augroup END
endif
syntax enable
if has('gui_running')
set guioptions-=T
set guioptions-=e
set guitablabel=%M\ %t
endif
set encoding=utf-8
scriptencoding utf-8
set fileformats=unix,dos,mac
set number
" use space for tab
set expandtab
set smarttab
" replace by vim-sleuth
" set shiftwidth=4
" set tabstop=4
set linebreak
set textwidth=500
set autoindent "Auto indent
set smartindent "Smart indent
set wrap "Wrap lines
" magic script from vim/neovim terminal
let $PATH .= ":" . s:home . '/bin'
if has('patch-8.1.0360')
set diffopt+=internal,algorithm:patience
endif
nnoremap <Leader>ec :execute 'edit' g:vimrc<CR>
" Specify the behavior when switching between buffers
set switchbuf=useopen,usetab,newtab
set showtabline=2
if has('nvim-0.7.0')
set laststatus=3
else
set laststatus=2
endif
set mouse=a
if !has('nvim') && !has('gui_running')
" ONLY APPLY VIMS INSIDE TERMINAL
" older vim may problematic, I don't intend fixing that
" Cursor shapes, use a blinking upright bar cursor in Insert mode, a blinking block in normal
" when start insert mode - blinking vertical bar
let &t_SI = "\<Esc>[5 q"
" when end insert/replace mode(common) - blinking block
let &t_EI = "\<Esc>[1 q"
" when start replace mode
if v:version > 800
let &t_SR = "\<Esc>[4 q"
endif
augroup cursor_shape
autocmd!
autocmd VimLeave * let &t_te .= "\<Esc>[3 q"
autocmd VimLeave * set guicursor=a:hor25-blinkon300
augroup END
" if exists('$TMUX')
" let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
" let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
" endif
" better configure TERM of terminal or tmux, t_Co is not needed in most case
set t_Co=256
endif
set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50
\,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor
\,sm:block-blinkwait175-blinkoff150-blinkon175
" Make VIM remember position in file after reopen
augroup gp_cursor_location
" this one is which you're most likely to use?
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
augroup END
" guifont only works on GUIs
if has('mac') || has('macunix')
set guifont=JetBrainsMono\ Nerd\ Font:h13,FiraCode\ Nerd\ Font:h13,SauceCodePro\ Nerd\ Font:h13
elseif has('win16') || has('win32')
set guifont=Hack:h13,Source\ Code\ Pro:h13,Bitstream\ Vera\ Sans\ Mono:h13
elseif has('gui_gtk2')
set guifont=Hack\ 14,Source\ Code\ Pro\ 13,Bitstream\ Vera\ Sans\ Mono\ 13
elseif has('linux')
set guifont=JetBrainsMono\ Nerd\ Font\ 13,FiraCode\ Nerd\ Font\ 13,JetBrains\ Mono\ 13
elseif has('unix')
set guifont=Source\ Code\ Pro\ Medium\ 13
endif
if has('nvim-0.5')
let s:undodir = s:common_path . '/undodir-0.5/'
else
let s:undodir = s:common_path . '/undodir/'
endif
if !isdirectory(s:undodir)
echomsg "creating undodir in" s:undodir
call mkdir(s:undodir, "p")
endif
let &undodir = s:undodir
set undofile
" basic completion settings
set completeopt-=preview
set completeopt+=menuone
set completeopt+=noselect
set mousemodel=popup_setpos
set shortmess+=c
" give the file info when editing a file
set shortmess-=F
" only apply to vim
set shortmess-=S
" =============================================================== "
" essential keymaps & commands
" =============================================================== "
call aceforeverd#keymap#essential#setup()
call aceforeverd#cmd#essential#setup()
" =============================================================== "
" colorscheme
" =============================================================== "
call aceforeverd#settings#basic_color()
" setup sonokai
augroup gp_colorscheme
autocmd!
autocmd ColorSchemePre sonokai call aceforeverd#settings#sonokai_pre()
autocmd ColorScheme sonokai call aceforeverd#settings#sonokai_post()
autocmd ColorScheme * call aceforeverd#settings#hl_groups()
augroup END
colorscheme sonokai
" =============================================================== "
" NVIM
" =============================================================== "
if has('nvim-0.5')
lua require('aceforeverd').setup()
endif
let s:after_vimrc = s:home . '/after.vim'
if filereadable(s:after_vimrc)
execute('source ' . s:after_vimrc)
endif