-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
209 lines (181 loc) · 5.9 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
" plugins
call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'ludovicchabant/vim-gutentags'
Plug 'dense-analysis/ale'
Plug 'fatih/vim-go'
Plug 'rhysd/vim-clang-format'
Plug 'maxboisvert/vim-simple-complete'
Plug 'zivyangll/git-blame.vim'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'ntpeters/vim-better-whitespace'
Plug 'vim-scripts/DoxygenToolkit.vim'
Plug 'altercation/vim-colors-solarized'
call plug#end()
" junegunn/fzf.vim
nnoremap <silent> <Leader>gg :Ag <C-R><C-W><CR>
nnoremap <silent> <c-p> :Files <CR>
" ludovicchabant/vim-gutentags
let g:gutentags_enabled = 1
let g:gutentags_add_default_project_roots = 0
let g:gutentags_project_root = ['.root', '.git']
let g:gutentags_ctags_tagfile = 'gutentags'
let s:vim_tags = expand('~/.cache/tags')
let g:gutentags_cache_dir = s:vim_tags
if !isdirectory(s:vim_tags)
silent! call mkdir(s:vim_tags, 'p')
endif
" ctags/gtags
" universal ctags(https://github.com/universal-ctags/ctags)
let g:gutentags_modules = []
if executable('ctags')
let g:gutentags_modules += ['ctags']
endif
if executable('gtags-cscope') && executable('gtags')
let g:gutentags_modules += ['gtags_cscope']
endif
let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
let g:gutentags_ctags_extra_args += ['--c++-kinds=+pxI']
let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
" dense-analysis/ale
let g:ale_fix_on_save = 1
let g:ale_sign_error = '✗'
let g:ale_sign_warning = '⚡'
let g:ale_cpp_gcc_options = ' -std=c++11 '
let g:ale_cpp_clang_options = ' -std=c++11 '
let g:ale_linters_explicit = 1
let g:ale_linters = {
\ 'csh': ['shell'],
\ 'zsh': ['shell'],
\ 'python': ['pylint'],
\ 'go': ['gofmt', 'golint'],
\ 'c': ['clang', 'gcc'],
\ 'cpp': ['clang', 'g++'],
\ }
" fatih/vim-go
let g:go_fmt_command = "gofmt"
"let g:go_fmt_command = "goimports"
let g:go_version_warning = 0
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_operators = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_chan_whitespace_error = 0
let g:go_highlight_methods = 1
let g:go_highlight_generate_tags = 1
let g:go_highlight_diagnostic_errors = 1
let g:go_highlight_diagnostic_warnings = 1
" rhysd/vim-clang-format
let g:clang_format#command = 'clang-format'
autocmd FileType c ClangFormatAutoEnable
autocmd FileType h ClangFormatAutoEnable
autocmd FileType cpp ClangFormatAutoEnable
autocmd FileType hpp ClangFormatAutoEnable
autocmd FileType cc ClangFormatAutoEnable
autocmd FileType hh ClangFormatAutoEnable
autocmd FileType cxx ClangFormatAutoEnable
autocmd FileType hxx ClangFormatAutoEnable
" detects the style file like .clang-format
let g:clang_format#detect_style_file=1
let g:clang_format#auto_format=1
let g:clang_format#filetype_style_options = {
\ "proto" : {
\ "Language" : "Proto",
\ "DisableFormat" : "true"
\ },
\ "cpp" : {
\ "Language" : "Cpp",
\ "BasedOnStyle" : "LLVM",
\ "UseTab" : "Never",
\ "TabWidth" : 4,
\ "IndentWidth" : 4,
\ "ColumnLimit" : 0,
\ "MaxEmptyLinesToKeep" : 1,
\ "AccessModifierOffset" : -4,
\ "IndentCaseLabels" : "false",
\ "FixNamespaceComments" : "true",
\ "DerivePointerAlignment" : "true",
\ "PointerAlignment" : "Left",
\ "BreakBeforeBraces" : "Custom",
\ "SpacesInAngles" : "false",
\ "AllowShortFunctionsOnASingleLine" : "Inline",
\ "BraceWrapping" : {
\ "AfterCaseLabel" : "true",
\ "AfterUnion" : "true",
\ "AfterStruct" : "true",
\ "AfterClass" : "true",
\ "AfterEnum" : "true",
\ "AfterFunction" : "true",
\ "AfterControlStatement" : "true",
\ "BeforeCatch" : "true",
\ "BeforeElse" : "true",
\ "AfterNamespace" : "false"
\ }
\ }
\ }
" zivyangll/git-blame.vim
nnoremap <Leader>f :<C-u>call gitblame#echo()<CR>
" octol/vim-cpp-enhanced-highlight
let g:cpp_class_scope_highlight = 1
let g:cpp_member_variable_highlight = 1
let g:cpp_class_decl_highlight = 1
let g:cpp_posix_standard = 1
" template configs are very low performance
"let g:cpp_experimental_simple_template_highlight = 1
"let g:cpp_experimental_template_highlight = 1
" vim-scripts/DoxygenToolkit.vim
let g:DoxygenToolkit_briefTag_funcName = "yes"
let g:DoxygenToolkit_briefTag_pre = "@brief "
let g:DoxygenToolkit_paramTag_pre = "@param "
let g:DoxygenToolkit_returnTag = "@return "
let g:DoxygenToolkit_throwTag_pre = "@throw "
let g:DoxygenToolkit_fileTag = "@file "
let g:DoxygenToolkit_versionTag = "@version "
let g:DoxygenToolkit_blockTag = "@name "
let g:DoxygenToolkit_classTag = "@class "
let g:doxygen_enhanced_color = 1
" relative line number
function! ToggleRelativeNumberTemporary()
echo "enabling relative line number"
set rnu
call timer_start(1000, 'DisableRelativeNumber')
endfunction
function! DisableRelativeNumber(timer_id)
echo "disabling relative line number"
set nornu
endfunction
command! ToggleRelativeNumberTemporary call ToggleRelativeNumberTemporary()
nnoremap <leader>r :ToggleRelativeNumberTemporary<CR>
" internal plugin and hot keys
" vim internal netrw plugin key
nnoremap <F3> :Vexplore<CR>
let g:netrw_winsize = 30
" basic settings
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
set nu
set hlsearch
set backspace=2
set ts=4
set expandtab
set shiftwidth=4
set autoindent
set smartindent
set showmatch
set colorcolumn=150
set cursorline
set cursorcolumn
set complete-=t
set complete-=i
set shortmess+=c
set statusline=%F\ %m\ %=Ln\ %l,\ Col\ %c\ %p%%
set laststatus=2
" colorscheme
syntax enable
set background=dark
let g:solarized_termtrans = 1
colorscheme solarized