dotfiles/nvim/config/init.vim

204 lines
5.2 KiB
VimL
Raw Normal View History

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
set laststatus=2
2020-06-11 03:20:12 +00:00
set fillchars=vert:\ ,fold:-
2020-09-25 07:48:12 +00:00
set clipboard=unnamedplus
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>
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>
inoremap <C-w> <esc><C-w>
nmap <silent> <leader>ss :syntax sync fromstart<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
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
else
let vim_plug_path = expand("~/.vim/autoload/plug.vim")
endif
2020-06-10 17:04:54 +00:00
let vim_plug_just_installed = 0
if !filereadable(vim_plug_path)
echo "Installing vim-plug..."
:exe "!curl -fLo " . vim_plug_path . " --create-dirs https://gitee.com/klesh/vim-plug/raw/master/plug.vim"
let vim_plug_just_installed = 1
echo "vim-plug installed"
endif
call plug#begin()
Plug 'editorconfig/editorconfig-vim'
Plug 'tpope/vim-surround'
2020-06-11 03:22:27 +00:00
Plug 'jiangmiao/auto-pairs'
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'posva/vim-vue', { 'for': 'vue' }
Plug 'tpope/vim-repeat'
if $COC_ENABLED == 'yes'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'neoclide/coc-python', {'do': 'yarnpkg install --frozen-lockfile'}
else
Plug 'Vimjas/vim-python-pep8-indent', { 'for': 'python' }
endif
2020-06-10 17:04:54 +00:00
Plug 'liuchengxu/eleline.vim'
Plug 'tpope/vim-fugitive' " git 功能
Plug 'scrooloose/nerdcommenter'
"Plug 'ctrlpvim/ctrlp.vim'
2020-06-10 17:04:54 +00:00
Plug 'mhinz/vim-grepper', { 'on': ['Grepper', '<plug>(GrepperOperator)'] }
2020-06-11 03:20:12 +00:00
Plug 'morhetz/gruvbox'
Plug 'dag/vim-fish', { 'for': 'fish' }
Plug 'chrisbra/Colorizer'
Plug 'alvan/vim-closetag', { 'for': ['vue', 'html', 'xml'] }
Plug 'airblade/vim-gitgutter'
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
Plug 'junegunn/fzf'
2020-06-10 17:04:54 +00:00
call plug#end()
" ==== 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-06-10 17:04:54 +00:00
" ==== coc configuration ====
if $COC_ENABLED == 'yes'
let g:coc_disable_startup_warning = 1
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)
nmap <silent> <leader>fb <Plug>(coc-format)
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)
nmap <silent> <leader>if :CocInfo<CR>
nmap <silent> <leader>cl :CocList<CR>
nmap <silent> <leader>sd :call CocAction('doHover')<CR>
nmap <silent> <leader>ol <Plug>(coc-openlink)
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-06-10 17:04:54 +00:00
nnoremap <leader>sg :Grepper -tool git<CR>
nnoremap <leader>sc :Grepper -tool grep<CR>
2020-09-17 10:24:35 +00:00
" ==== NERDTree configuration ====
nnoremap <leader>fe :NERDTreeToggle<CR>
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>
nnoremap <leader>gl :Glog<CR>
nnoremap <leader>gms :Gvdiffsplit!<CR>
nnoremap <leader>gmh :diffget //2<CR>
nnoremap <leader>gml :diffget //3<CR>
2020-06-10 17:04:54 +00:00
" ==== ctrlp configuration ====
"let g:ctrlp_user_command = ['.git', 'git ls-files -co --exclude-standard']
" ==== fzf configuration ====
nnoremap <C-p> :FZF<CR>
2020-06-11 03:20:12 +00:00
" ==== gruvbox configuration ====
color gruvbox
set background=dark
highlight Normal ctermbg=None
" ==== 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