-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
235 lines (177 loc) · 6.5 KB
/
vimrc
File metadata and controls
235 lines (177 loc) · 6.5 KB
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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer:
" Eric Liu — qc1iuone AT outlook.com
"
" Sections:
" -> Plugins
" -> General settings
" -> Key mappings
" -> Autocmd
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin()
" See https://junegunn.github.io/vim-plug/example/ for help.
" Make sure you use single quotes
" A command-line fuzzy finder
Plug 'https://gitee.com/e1iu/fzf.git', {'do' : './install --bin'}
Plug 'https://gitee.com/e1iu/fzf.vim'
" Using a terminal buffer instead of raw terminal outputting.
" 80% of screen estate. See https://github.com/junegunn/fzf.vim/issues/869
let g:fzf_layout = { 'window': 'bot'.float2nr(&lines * 0.8).'new' }
" Vim syntax file & snippets for Docker's Dockerfile
Plug 'https://gitee.com/e1iu/Dockerfile.vim'
" surround.vim: quoting/parenthesizing made simple
Plug 'https://gitee.com/e1iu/vim-surround'
" fugitive.vim: A Git wrapper so awesome, it should be illegal
Plug 'https://gitee.com/e1iu/vim-fugitive'
" A light and configurable statusline/tabline plugin for Vim
Plug 'https://gitee.com/e1iu/lightline.vim'
" Vim script for text filtering and alignment
" NOTE: The tabular plugin must come before vim-markdown.
" See https://github.com/plasticboy/vim-markdown
Plug 'https://gitee.com/e1iu/tabular'
" Markdown Vim Mode
Plug 'https://github.com/preservim/vim-markdown.git'
let g:vim_markdown_folding_disabled = 1
" Vim plugin that displays tags in a window, ordered by scope
Plug 'https://gitee.com/e1iu/tagbar'
" Additional Vim syntax highlighting for C++ (including C++11/14/17)
Plug 'https://gitee.com/e1iu/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
" Vim plugin for the_silver_searcher (ag) or ack -- a wicked fast grep
Plug 'https://gitee.com/e1iu/ack.vim'
let g:ackhighlight = 1
" Molokai color scheme for Vim
Plug 'https://gitee.com/e1iu/molokai'
" .tmux is not a vim plugin. Manage it by vim just for fun.
Plug 'https://gitee.com/e1iu/.tmux', {'branch' : 'chuan'}
" Call plug#end to update &runtimepath and initialize the plugin system.
" - It automatically executes `filetype plugin indent on` and `syntax enable`
" You can revert the settings after the call like so:
" filetype indent off " Disable file-type-specific indentation
" syntax off " Disable syntax highlighting
call plug#end()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set the default shell for :term
set shell=/bin/bash
" Set to auto read when a file is changed from the outside
set autoread
" Add a bit extra margin to the left
set foldcolumn=1
" Set 7 lines to the cursor - when moving vertically using j/k
set scrolloff=7
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
if has("win16") || has("win32")
set wildignore+=.git\*,.hg\*,.svn\*
else
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
endif
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" Don't redraw while executing macros (good performance config)
set lazyredraw
" Enable syntax highlighting
syntax on
set t_Co=256
" Set colorscheme to molokai which should be installed by plugin manager.
" Keep silence if molokai not existed.
try
colorscheme molokai
catch
endtry
" If molokai scheme not be loaded, set the background to dark mode for default
" scheme.
set background=dark
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" Use Unix as the standard file type
set ffs=unix
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowritebackup
set noswapfile
" Use spaces instead of tabs
set expandtab
" 1 tab == 2 spaces
set shiftwidth=2
set tabstop=2
" Auto delete indent when go to a new line without input anything.
set autoindent
" Fold mode
set foldmethod=marker
" When a bracket is inserted, briefly jump to the matching one.
set showmatch
" Always display the status line. Require by 'lightline' plugin
set laststatus=2
" No need show mode in status line again since 'lightline' has done this.
set noshowmode
" Enable enhanced mode in command-line completion
set wildmenu
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Key mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Disable arrow keys in Normal, Visual, Select, Insert modes
" Take care of your 'hjkl' keys:P
" NOTE: Be careful when recurive map to these keys.
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
inoremap <Up> <Nop>
inoremap <Down> <Nop>
inoremap <Left> <Nop>
inoremap <Right> <Nop>
" Quicker change to normal mode
inoremap jk <Esc>
" When the <Esc> is part of a mapping, the command is executed(in cmd mode),
" so we use <C-c> instead.
cnoremap jk <C-c>
" Go to end-of-line
cnoremap <C-e> <End>
" Go to head-of-line
cnoremap <C-a> <Home>
" Shortcut key for fzf
" NOTE: <C-p> would not work correctly in tmux when it's in docker container.
" In such situation, double <C-p> maps to <C-p> with unknown reason.
" nnoremap <C-p> :Files<CR>
nnoremap <Leader>f :Files<CR>
nnoremap <Leader>b :Buffers<CR>
nnoremap <Leader>h :History<CR>
nnoremap <Leader>m :Marks<CR>
nnoremap <Leader>t :Tags<CR>
" Opens current buffer in new tab page
nnoremap <Leader>s :tab split<CR>
" Quick exit
nnoremap <Leader>q :q!<CR>
" Quick save.
nnoremap <Leader>w :w!<CR>
" Quick open Ack
nnoremap <Leader>a <Esc>:Ack! --ignore-file=is:tags<Space>
" Quick open and close Tagbar
nnoremap <F12> <Esc>:TagbarToggle<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Autocmd
"
" NOTE: Put all filetype-specific settings to where they should belong in
" ftplugins floder, because FileType autocmds are pointless and wasteful.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Highlight the current insert line
autocmd InsertEnter,InsertLeave * set cul!
" Jump to the last position when reopening a file
" https://stackoverflow.com/a/774599
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| execute "normal! g'\"" | endif