2020-06-10 17:04:54 +00:00
|
|
|
" basic settings
|
|
|
|
set ts=4
|
|
|
|
set sw=4
|
|
|
|
set cc=120
|
|
|
|
set expandtab
|
|
|
|
set nu
|
|
|
|
set hidden
|
|
|
|
set list
|
|
|
|
set autoindent
|
|
|
|
set confirm
|
|
|
|
set noundofile
|
|
|
|
set nobackup
|
2020-06-17 04:16:05 +00:00
|
|
|
set nowritebackup
|
2020-06-10 17:04:54 +00:00
|
|
|
set hlsearch
|
|
|
|
set noswapfile
|
|
|
|
set ignorecase
|
2020-06-17 04:16:05 +00:00
|
|
|
set smarttab
|
|
|
|
set smartindent
|
|
|
|
set cursorline
|
|
|
|
set incsearch
|
|
|
|
set signcolumn=yes
|
2020-06-11 06:57:01 +00:00
|
|
|
set laststatus=2
|
2020-06-11 03:20:12 +00:00
|
|
|
set fillchars=vert:\ ,fold:-
|
2020-11-08 06:07:30 +00:00
|
|
|
set clipboard=unnamedplus " system clipboard as default register. for vim to work need installing gvim package
|
2020-11-15 16:19:57 +00:00
|
|
|
set mouse=a
|
2020-06-10 17:04:54 +00:00
|
|
|
filetype plugin indent on
|
|
|
|
syntax on
|
2020-06-17 03:13:26 +00:00
|
|
|
au! BufWritePost $MYVIMRC source %
|
|
|
|
|
2020-06-10 17:04:54 +00:00
|
|
|
cnoremap <C-a> <Home>
|
|
|
|
cnoremap <C-e> <End>
|
|
|
|
cnoremap <C-f> <Right>
|
|
|
|
cnoremap <C-b> <Left>
|
|
|
|
cnoremap <C-d> <Delete>
|
|
|
|
cnoremap <C-n> <Down>
|
|
|
|
cnoremap <C-p> <Up>
|
|
|
|
|
|
|
|
inoremap <C-a> <Home>
|
|
|
|
inoremap <C-e> <End>
|
|
|
|
inoremap <C-f> <Right>
|
|
|
|
inoremap <C-b> <Left>
|
|
|
|
inoremap <C-d> <Delete>
|
|
|
|
inoremap <C-n> <Down>
|
|
|
|
inoremap <C-p> <Up>
|
|
|
|
|
|
|
|
noremap <C-a> <Home>
|
|
|
|
noremap <C-e> <End>
|
|
|
|
noremap <C-f> <Right>
|
|
|
|
noremap <C-b> <Left>
|
|
|
|
|
2020-09-30 07:51:31 +00:00
|
|
|
vnoremap <leader>p pgvy
|
2020-06-10 17:04:54 +00:00
|
|
|
nnoremap <leader>q :qall<CR>
|
|
|
|
|
2020-06-20 02:32:33 +00:00
|
|
|
nnoremap <leader>1 :b1<CR>
|
|
|
|
nnoremap <leader>2 :b2<CR>
|
|
|
|
nnoremap <leader>3 :b3<CR>
|
|
|
|
nnoremap <leader>4 :b4<CR>
|
|
|
|
nnoremap <leader>5 :b5<CR>
|
|
|
|
nnoremap <leader>w :w<CR>
|
|
|
|
nnoremap <leader><Esc> :noh<return><esc>
|
|
|
|
|
2020-11-08 06:07:30 +00:00
|
|
|
nmap <leader>"" ysiW"
|
|
|
|
nmap <leader>'' ysiW'
|
|
|
|
nmap <leader>" ysiw"
|
|
|
|
nmap <leader>' ysiw'
|
|
|
|
nmap <leader>`` ysiW`
|
|
|
|
nmap <leader>` ysiw`
|
|
|
|
|
2020-11-14 17:37:26 +00:00
|
|
|
nmap <leader>sb :windo set scrollbind<CR>:windo set cursorbind<CR>:set mouse=a<CR>
|
|
|
|
nmap <leader>nsb :windo set noscrollbind<CR>:windo set nocursorbind<CR>:set mouse=<CR>
|
2020-11-12 17:11:02 +00:00
|
|
|
|
2020-06-20 02:32:33 +00:00
|
|
|
inoremap <C-w> <esc><C-w>
|
2020-10-29 03:57:00 +00:00
|
|
|
nmap <silent> <leader>ss :syntax sync fromstart<CR>
|
2020-06-11 06:57:01 +00:00
|
|
|
|
2020-11-15 16:19:57 +00:00
|
|
|
" // to search highlighted text
|
|
|
|
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
|
2020-06-10 17:04:54 +00:00
|
|
|
|
|
|
|
" trailing spaces
|
|
|
|
highlight ExtraWhitespace ctermbg=red guibg=red
|
|
|
|
au ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
|
|
|
|
au Syntax * match ExtraWhitespace /\s\+$/
|
|
|
|
nnoremap <leader>es :%s/\s\+$//g<CR>
|
|
|
|
|
|
|
|
" auto install vim-plug
|
2020-06-11 06:57:01 +00:00
|
|
|
if has('nvim')
|
2020-07-28 04:07:07 +00:00
|
|
|
if has('win32')
|
|
|
|
let vim_plug_path = $LOCALAPPDATA . "/nvim/autoload/plug.vim"
|
|
|
|
else
|
|
|
|
let vim_plug_path = expand("~/.config/nvim/autoload/plug.vim")
|
|
|
|
endif
|
2020-06-11 06:57:01 +00:00
|
|
|
else
|
2020-12-10 01:54:05 +00:00
|
|
|
set ttymouse=sgr
|
|
|
|
"map <ScrollWheelUp> <C-Y>
|
|
|
|
"map <ScrollWheelDown> <C-E>
|
2020-06-11 06:57:01 +00:00
|
|
|
let vim_plug_path = expand("~/.vim/autoload/plug.vim")
|
2020-11-08 06:07:30 +00:00
|
|
|
set listchars=eol:\ ,tab:>\ ,trail:~,extends:>,precedes:<
|
2020-06-11 06:57:01 +00:00
|
|
|
endif
|
2020-06-10 17:04:54 +00:00
|
|
|
let vim_plug_just_installed = 0
|
|
|
|
if !filereadable(vim_plug_path)
|
|
|
|
echo "Installing vim-plug..."
|
2021-01-13 14:12:27 +00:00
|
|
|
:exe "!curl -fLo \"" . vim_plug_path . "\" --create-dirs https://gitee.com/klesh/vim-plug/raw/master/plug.vim"
|
2020-06-10 17:04:54 +00:00
|
|
|
let vim_plug_just_installed = 1
|
|
|
|
echo "vim-plug installed"
|
|
|
|
endif
|
|
|
|
|
2020-11-02 13:43:09 +00:00
|
|
|
call plug#begin('~/.vim/plugged')
|
2020-06-10 17:04:54 +00:00
|
|
|
Plug 'editorconfig/editorconfig-vim'
|
|
|
|
Plug 'tpope/vim-surround'
|
2020-06-11 03:22:27 +00:00
|
|
|
Plug 'jiangmiao/auto-pairs'
|
2020-10-23 03:48:19 +00:00
|
|
|
Plug 'posva/vim-vue', { 'for': 'vue' }
|
2020-10-20 08:16:02 +00:00
|
|
|
Plug 'tpope/vim-repeat'
|
2020-06-10 17:04:54 +00:00
|
|
|
Plug 'liuchengxu/eleline.vim'
|
2020-11-23 04:12:03 +00:00
|
|
|
Plug 'klesh/vim-fugitive' " git 功能
|
2020-06-10 17:04:54 +00:00
|
|
|
Plug 'scrooloose/nerdcommenter'
|
|
|
|
Plug 'mhinz/vim-grepper', { 'on': ['Grepper', '<plug>(GrepperOperator)'] }
|
2020-06-11 03:20:12 +00:00
|
|
|
Plug 'morhetz/gruvbox'
|
2020-11-14 17:37:26 +00:00
|
|
|
Plug 'klesh/vim-fish', { 'for': 'fish' }
|
2020-10-23 03:48:19 +00:00
|
|
|
Plug 'alvan/vim-closetag', { 'for': ['vue', 'html', 'xml'] }
|
2021-01-16 06:05:29 +00:00
|
|
|
"Plug 'francoiscabrol/ranger.vim'
|
2020-11-05 17:24:45 +00:00
|
|
|
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
|
|
|
|
Plug 'junegunn/fzf.vim'
|
2020-11-23 07:53:21 +00:00
|
|
|
|
|
|
|
if $VIM_MODE == 'enhanced'
|
|
|
|
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
|
|
|
Plug 'chrisbra/Colorizer'
|
2021-01-04 10:24:37 +00:00
|
|
|
Plug 'tpope/vim-markdown', { 'for': 'markdown' }
|
2020-11-23 07:53:21 +00:00
|
|
|
Plug 'cespare/vim-toml', { 'for': 'toml' }
|
|
|
|
" vimspector
|
|
|
|
if has('nvim')
|
|
|
|
Plug 'rbgrouleff/bclose.vim'
|
|
|
|
endif
|
|
|
|
Plug 'puremourning/vimspector'
|
2020-11-25 10:01:46 +00:00
|
|
|
Plug 'vim-scripts/mom.vim'
|
2020-11-23 07:53:21 +00:00
|
|
|
else
|
|
|
|
Plug 'Vimjas/vim-python-pep8-indent', { 'for': 'python' }
|
|
|
|
endif
|
2021-01-16 06:05:29 +00:00
|
|
|
if has('win32')
|
|
|
|
Plug 'zigford/vim-powershell'
|
|
|
|
endif
|
2020-06-10 17:04:54 +00:00
|
|
|
call plug#end()
|
|
|
|
|
2020-10-23 03:48:19 +00:00
|
|
|
" ==== vim-markdown configuration ====
|
|
|
|
let g:vim_markdown_folding_disabled = 1
|
|
|
|
|
2020-06-10 17:04:54 +00:00
|
|
|
|
2020-09-25 07:48:12 +00:00
|
|
|
" ==== vim-closetag configuration ====
|
|
|
|
let g:closetag_filetypes = 'html,xhtml,phtml,vue'
|
|
|
|
|
2020-10-23 03:48:19 +00:00
|
|
|
|
2020-11-02 13:43:09 +00:00
|
|
|
if $VIM_MODE == 'enhanced'
|
|
|
|
" ==== coc configuration ====
|
2020-11-08 06:07:30 +00:00
|
|
|
let g:coc_global_extensions = [
|
|
|
|
\ 'coc-diagnostic',
|
|
|
|
\ 'coc-clangd'
|
|
|
|
\ ]
|
|
|
|
"let g:coc_disable_startup_warning = 1
|
2020-10-29 03:57:00 +00:00
|
|
|
set statusline^=%{coc#status()}
|
|
|
|
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)
|
|
|
|
|
|
|
|
xmap <silent> <leader>fs <Plug>(coc-format-selected)
|
|
|
|
nmap <silent> <leader>fs <Plug>(coc-format-selected)
|
2020-11-08 06:07:30 +00:00
|
|
|
nmap <silent> <leader>fd <Plug>(coc-format)
|
2020-10-29 03:57:00 +00:00
|
|
|
nmap <silent> <leader>rn <Plug>(coc-rename)
|
|
|
|
nmap <silent> <leader>ne <Plug>(coc-diagnostic-next-error)
|
|
|
|
nmap <silent> <leader>pe <Plug>(coc-diagnostic-prev-error)
|
2020-11-08 06:07:30 +00:00
|
|
|
nmap <silent> <leader>oi :CocInfo<CR>
|
2020-12-17 07:18:43 +00:00
|
|
|
"nmap <silent> <leader>ol :<C-u>CocList<CR>
|
2020-11-08 06:07:30 +00:00
|
|
|
nmap <silent> <leader>olr :<C-u>CocListResume<CR>
|
|
|
|
nmap <silent> <leader>od :call CocAction('doHover')<CR>
|
2020-10-29 03:57:00 +00:00
|
|
|
nmap <silent> <leader>ol <Plug>(coc-openlink)
|
2020-11-03 17:26:57 +00:00
|
|
|
nmap <silent> <leader>oc :CocCommand<CR>
|
2020-11-02 13:43:09 +00:00
|
|
|
|
2020-11-08 06:07:30 +00:00
|
|
|
autocmd BufEnter,BufRead,BufNewFile *.js set syntax=typescript
|
|
|
|
|
2020-11-02 13:43:09 +00:00
|
|
|
" ==== vimspector configuration ====
|
2020-11-08 06:07:30 +00:00
|
|
|
let g:vimspector_enable_mappings = 'VISUAL_STUDIO'
|
|
|
|
let g:vimspector_install_gadgets = [ 'debugpy', 'vscode-cpptools' ]
|
2020-10-29 03:57:00 +00:00
|
|
|
endif
|
2020-09-17 10:24:35 +00:00
|
|
|
|
2020-09-19 10:17:28 +00:00
|
|
|
" ==== auto-pairs configuration ====
|
|
|
|
nmap <silent> <leader>ap :call AutoPairsToggle()<CR>
|
|
|
|
let g:AutoPairsShortcutToggle = ''
|
|
|
|
|
2020-09-17 10:24:35 +00:00
|
|
|
|
|
|
|
" ==== grepper configuration ====
|
2020-11-06 17:41:22 +00:00
|
|
|
"
|
2020-06-10 17:04:54 +00:00
|
|
|
nnoremap <leader>sg :Grepper -tool git<CR>
|
|
|
|
nnoremap <leader>sc :Grepper -tool grep<CR>
|
2020-11-06 17:41:22 +00:00
|
|
|
nnoremap <leader>sa :Grepper -tool ag<CR>
|
|
|
|
|
|
|
|
" ==== quickfix configuration ====
|
|
|
|
nnoremap <leader>j :cn<CR>
|
|
|
|
nnoremap <leader>k :cp<CR>
|
2020-06-10 17:04:54 +00:00
|
|
|
|
|
|
|
|
2020-11-10 09:47:35 +00:00
|
|
|
"" ==== NERDTree configuration ====
|
|
|
|
"nnoremap <leader>fe :NERDTreeToggle<CR>
|
|
|
|
|
|
|
|
|
|
|
|
" ==== Ranger configuration ====
|
2020-11-24 10:31:11 +00:00
|
|
|
let g:ranger_map_keys = 0
|
2021-01-16 06:05:29 +00:00
|
|
|
"nnoremap <C-t> :Ranger<CR>
|
|
|
|
|
|
|
|
|
|
|
|
" ==== netrw configuration ====
|
|
|
|
nnoremap <C-t> :e .<CR>
|
2020-11-12 17:11:02 +00:00
|
|
|
|
|
|
|
autocmd BufEnter,BufRead nnoremap <leader>cg :<C-u>call OpenRangerIn(system("git rev-parse --show-toplevel >/dev/null || pwd"), 'edit ')<CR>
|
2020-09-17 10:24:35 +00:00
|
|
|
|
|
|
|
|
2020-06-10 17:04:54 +00:00
|
|
|
" ==== fugitive configuration ====
|
|
|
|
nnoremap <leader>gs :Gstatus<CR>
|
|
|
|
nnoremap <leader>gc :Gcommit<CR>
|
|
|
|
nnoremap <leader>gp :Gpush<CR>
|
|
|
|
nnoremap <leader>gg :Gpull<CR>
|
|
|
|
nnoremap <leader>gd :Gdiff<CR>
|
2020-07-13 08:47:59 +00:00
|
|
|
nnoremap <leader>gb :Gblame<CR>
|
2020-09-28 03:16:59 +00:00
|
|
|
nnoremap <leader>gl :Glog<CR>
|
|
|
|
nnoremap <leader>gms :Gvdiffsplit!<CR>
|
|
|
|
nnoremap <leader>gmh :diffget //2<CR>
|
|
|
|
nnoremap <leader>gml :diffget //3<CR>
|
2020-11-04 07:21:29 +00:00
|
|
|
nnoremap <leader>gsc :exec "!git switch -c " . input("Enter new branch name:")<CR>
|
2020-06-10 17:04:54 +00:00
|
|
|
|
|
|
|
" ==== ctrlp configuration ====
|
2020-10-23 03:48:19 +00:00
|
|
|
"let g:ctrlp_user_command = ['.git', 'git ls-files -co --exclude-standard']
|
|
|
|
|
|
|
|
" ==== fzf configuration ====
|
2020-11-06 17:03:54 +00:00
|
|
|
" enable <C-p> for fzf
|
|
|
|
let g:fugitive_no_maps=1
|
2020-11-10 16:53:29 +00:00
|
|
|
|
2021-01-16 06:05:29 +00:00
|
|
|
nnoremap <C-p> :call fzf#vim#files(trim(system("git rev-parse --show-toplevel \|\| pwd")))<Cr>
|
2020-11-05 04:24:22 +00:00
|
|
|
nnoremap <leader>gco :call fzf#run({'source': 'git branch \| cut -c 3-; git tag -l', 'sink': '!git checkout'})<CR>
|
2020-11-08 06:07:30 +00:00
|
|
|
nnoremap <leader>gm :call fzf#run({'source': 'git branch \| cut -c 3-', 'sink': '!git merge'})<CR>
|
2020-12-08 03:18:26 +00:00
|
|
|
nnoremap <leader>ls :Buffers<CR>
|
2020-06-11 03:20:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
" ==== gruvbox configuration ====
|
|
|
|
color gruvbox
|
|
|
|
set background=dark
|
2020-11-10 04:03:52 +00:00
|
|
|
" for background transparence to work
|
2020-06-11 03:20:12 +00:00
|
|
|
highlight Normal ctermbg=None
|
2020-11-10 04:03:52 +00:00
|
|
|
highlight CursorLine ctermbg=240
|
2020-10-07 16:21:32 +00:00
|
|
|
|
|
|
|
" ==== NERDCommenter for vue ====
|
|
|
|
let g:ft = ''
|
|
|
|
fu! NERDCommenter_before()
|
|
|
|
if &ft == 'vue'
|
|
|
|
let g:ft = 'vue'
|
|
|
|
let stack = synstack(line('.'), col('.'))
|
|
|
|
if len(stack) > 0
|
|
|
|
let syn = synIDattr((stack)[0], 'name')
|
|
|
|
if len(syn) > 0
|
|
|
|
let syn = tolower(syn)
|
|
|
|
exe 'setf '.syn
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endfu
|
|
|
|
fu! NERDCommenter_after()
|
|
|
|
if g:ft == 'vue'
|
|
|
|
setf vue
|
|
|
|
g:ft
|
|
|
|
endif
|
|
|
|
endfu
|
2020-11-24 18:18:32 +00:00
|
|
|
|
|
|
|
" ==== groff ====
|
2020-11-25 10:01:46 +00:00
|
|
|
fu! SilentOK(cmd)
|
|
|
|
let l:ouput = system(substitute(a:cmd, "%", expand("%"), "g"))
|
|
|
|
if v:shell_error != 0
|
|
|
|
echo ouput
|
|
|
|
endif
|
|
|
|
endfu
|
|
|
|
|
|
|
|
fu! ToggleGroffMomAutoCompilation()
|
|
|
|
let g:GroffMomAutoCompilation = !get(g:, "GroffMomAutoCompilation", 0)
|
2020-11-24 18:18:32 +00:00
|
|
|
|
|
|
|
augroup GroffPdf
|
|
|
|
autocmd!
|
|
|
|
augroup END
|
|
|
|
|
2020-11-25 10:01:46 +00:00
|
|
|
if g:GroffMomAutoCompilation
|
2020-11-24 18:18:32 +00:00
|
|
|
augroup GroffPdf
|
2020-11-26 04:57:50 +00:00
|
|
|
autocmd BufWritePost,FileWritePost *.mom :call SilentOK("groff -Kutf8 -mom % > /tmp/tmp.ps && ps2pdf /tmp/tmp.ps %.pdf")
|
2020-11-24 18:18:32 +00:00
|
|
|
augroup END
|
2020-11-25 10:01:46 +00:00
|
|
|
echo "Auto compilation for groff_mom enabled"
|
2020-11-24 18:18:32 +00:00
|
|
|
else
|
2020-11-25 10:01:46 +00:00
|
|
|
echo "Auto compilation for groff_mom disabled"
|
2020-11-24 18:18:32 +00:00
|
|
|
endif
|
2020-11-25 10:01:46 +00:00
|
|
|
endfu
|
|
|
|
nnoremap <leader>ac :call ToggleGroffMomAutoCompilation()<CR>
|
|
|
|
autocmd BufEnter,BufRead *.mom :set ft=mom
|
|
|
|
|