-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathvimrc
More file actions
271 lines (227 loc) · 7.27 KB
/
vimrc
File metadata and controls
271 lines (227 loc) · 7.27 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
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
265
266
267
268
269
270
271
let g:mapleader=","
syntax on
" auto-install vim-plug
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif
call plug#begin('~/.vim/plugged')
Plug 'tomasr/molokai'
Plug 'scrooloose/nerdtree'
Plug 'vim-scripts/NERD_tree-Project'
Plug 'scrooloose/nerdcommenter'
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
Plug 'majutsushi/tagbar'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-fugitive'
Plug 'w0rp/ale'
Plug 'feiyuw/robotframework-vim'
Plug 'ntpeters/vim-better-whitespace'
Plug 'elzr/vim-json', { 'for': 'json' }
Plug 'pangloss/vim-javascript', { 'for': 'javascript' }
Plug 'mxw/vim-jsx', { 'for': 'javascript' }
Plug 'othree/html5.vim', { 'for': 'html' }
Plug 'airblade/vim-gitgutter'
Plug 'jiangmiao/auto-pairs'
Plug 'ekalinin/Dockerfile.vim', { 'for': 'Dockerfile' }
Plug 'fatih/vim-go', { 'for': 'go' }
Plug 'christoomey/vim-tmux-navigator'
Plug 'rust-lang/rust.vim'
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
Plug 'ncm2/ncm2-jedi', { 'for': 'python' }
Plug 'ncm2/ncm2-go', { 'for': 'go' }
Plug 'ncm2/ncm2-markdown-subscope'
Plug 'ncm2/ncm2-tern', {'do': 'npm install'}
Plug 'davidhalter/jedi-vim', { 'for': 'python' }
Plug 'tpope/vim-sleuth'
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
call plug#end()
"fzf
command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case ".shellescape(<q-args>), 1, {'options': '--delimiter : --nth 4..'}, <bang>0)
nmap <C-p> :Files<CR>
nmap <C-e> :Buffers<CR>
nmap <C-g> :Rg<CR>
"ncm2
autocmd BufEnter * call ncm2#enable_for_buffer()
" IMPORTANT: :help Ncm2PopupOpen for more information
set completeopt=noinsert,menuone,noselect
set shortmess+=c
" When the <Enter> key is pressed while the popup menu is visible, it only
" hides the menu. Use this mapping to close the menu and also start a new
" line.
inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")
" Use <TAB> to select the popup menu:
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
"jedi-vim
let g:jedi#goto_command = ""
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<C-]>"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#rename_command = "<leader>r"
let g:jedi#completions_enabled = 0
"rust.vim
let g:ale_rust_rustc_options = ''
let g:rustfmt_autosave = 1
let g:rust_clip_command = 'pbcopy'
"vim-go
let g:go_version_warning = 1
" gitgutter
if exists('&signcolumn') " Vim 7.4.2201
set signcolumn=yes
else
let g:gitgutter_sign_column_always = 1
endif
" tmux
let g:tmux_navigator_save_on_switch = 1
" jsx
let g:jsx_ext_required = 0 " Allow JSX in normal JS files
" javascript
let g:javascript_ignore_javaScriptdoc = 1
let g:javascript_conceal_function = "ƒ"
let g:javascript_conceal_null = "ø"
let g:javascript_conceal_this = "@"
let g:javascript_conceal_return = "⇚"
let g:javascript_conceal_undefined = "¿"
let g:javascript_conceal_NaN = "ℕ"
let g:javascript_conceal_prototype = "¶"
let g:javascript_conceal_static = "•"
let g:javascript_conceal_super = "Ω"
let g:javascript_plugin_flow = 1
" ale
let g:ale_linters = {'javascript': ['eslint'], 'python': ['flake8'], 'rust': ['cargo'], 'go': ['gometalinter']}
let g:ale_maximum_file_size = 524288 " 512KB
let g:ale_completion_enabled = 0
let g:ale_lint_delay = 250
"let g:ale_lint_on_text_changed = "normal"
let b:ale_warn_about_trailing_whitespace = 0
let g:ale_pattern_options = {
\ '\.min\.js$': {'ale_linters': [], 'ale_fixers': []},
\ '\.min\.css$': {'ale_linters': [], 'ale_fixers': []},
\}
" molokai
set background=dark
set guioptions=i
set guifont=Source\ Code\ Pro\ for\ Powerline\ Book\ 12
set guifontwide=Source\ Code\ Pro\ for\ Powerline\ Book\ 12
set t_Co=256
let g:rehash256 = 1
colorscheme molokai
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/node_modules/*,*/proto/*,*/dist/*,*/.cache/*,*/bower_components/*.tags,__pycache__,*.pyc,*.class
" nerdtree
let NERDTreeIgnore=['\.$', '\~$', '\.pyc$', '\.class$']
map <F12> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" persistent undo
set undofile
" nerd commenter
let NERDShutUp=1
map <leader>m <leader>c<space>
" vim markdown
let g:vim_markdown_folding_disabled = 1
" tagbar
map <F4> :TagbarToggle<CR>
" airline
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_buffers = 1
let g:airline#extensions#tabline#show_tabs = 0
nmap <TAB> :bnext<CR>
nmap <S-TAB> :bprevious<CR>
set noshowmode
set laststatus=2
" strip-whitespace
let g:better_whitespace_enabled=1
let g:strip_whitespace_on_save=1
let g:strip_whitespace_confirm=0
filetype plugin indent on
set number
set ruler
set cursorline
"set cursorcolumn
set cc=120
set fileencodings=utf-8,gb18030,cp936,big5,utf-16le
set list
set listchars=tab:>-,trail:-
set hlsearch
set incsearch
set autoindent
set smartindent
set hidden
set linebreak
set tabstop=4
set softtabstop=4
set smarttab
set ignorecase
set smartcase
if has("unix")
map <leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
map <leader>vs :vsplit <C-R>=expand("%:p:h") . "/" <CR>
map <leader>s :split <C-R>=expand("%:p:h") . "/" <CR>
else
map <leader>e :e <C-R>=expand("%:p:h") . "\\" <CR>
map <leader>vs :vsplit <C-R>=expand("%:p:h") . "\\" <CR>
map <leader>s :split <C-R>=expand("%:p:h") . "\\" <CR>
endif
" 插入模式下移动
inoremap <c-j> <down>
inoremap <c-k> <up>
inoremap <c-l> <right>
inoremap <c-h> <left>
" 在窗口间移动
noremap <C-Down> <C-W>j
noremap <C-Up> <C-W>k
noremap <C-Left> <C-W>h
noremap <C-Right> <C-W>l
"自动格式化
set formatoptions=tcrqn
"在normal模式下使用系统剪贴板
set clipboard+=unnamed
"Show matching bracets
set showmatch
"Get out of VI's compatible mode
set nocompatible
"Enable magic mode
set magic
"Have the mouse enabled all the time
set mouse=a
"Set to auto read when a file is changed from the outside
set autoread
"打开目录时不显示隐藏目录和文件,以及.pyc文件。
let g:netrw_hide= 1
let g:netrw_list_hide= netrw_gitignore#Hide().'.*\.swp$'
"AutoCommand
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
"python,设置缩进格式
autocmd FileType python setlocal cinwords=if,elif,else,for,while,try,expect,finally,def,class,with
let g:python3_host_prog = '/usr/local/bin/python3'
"绑定自动补全的快捷键<C-X><C-O>到<leader>;
imap <leader>; <C-X><C-O>
"绑定复制到系统剪贴板快捷键
vmap <leader>c "+y
nmap <leader>c "+y
"绑定粘贴系统剪贴板内容快捷键
"imap <leader>v <ESC>"+p "不设置insert模式下的快捷键,因为会造成无法输入,v
vmap <leader>v <ESC>"+p
nmap <leader>v "+p
"复制粘贴
cmap <leader>" <C-r>"
cmap <leader>+ <C-r>+
"Ctrl+S
imap <C-s> <ESC>:w<CR>i
nmap <C-s> :w<CR>
"for golang
function! SetGoPath()
let srcDir = fnamemodify(finddir('src', expand("%:p:h") . ';'), ':p:h')
if isdirectory(srcDir) && empty($GOPATH)
let $GOPATH = fnamemodify(srcDir, ':h')
endif
endfunction
autocmd FileType go call SetGoPath()