[feature] add nvim

This commit is contained in:
Klesh Wong 2020-06-11 01:04:54 +08:00
parent 3e28b3e210
commit d03de30679
5 changed files with 133 additions and 9 deletions

3
.gitignore vendored
View File

@ -6,3 +6,6 @@ config/ranger/history
config/ranger/tagged config/ranger/tagged
config/ranger/plugins config/ranger/plugins
config/Thunar/accels.scm config/Thunar/accels.scm
config/nvim/autoload
config/nvim/plugged
config/nvim/.*

3
coc-settings.json Normal file
View File

@ -0,0 +1,3 @@
{
"npm.binPath": "yarn"
}

View File

@ -0,0 +1,4 @@
{
"npm.binPath": "yarn",
"python.linting.flake8Enabled": true
}

105
config/nvim/init.vim Normal file
View File

@ -0,0 +1,105 @@
" 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
set hlsearch
set noswapfile
set ignorecase
filetype plugin indent on
syntax on
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 "_dP
nnoremap <leader>q :qall<CR>
" 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
let vim_plug_path = expand("~/.config/nvim/autoload/plug.vim")
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'
"Plug 'jiangmiao/auto-pairs'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'}
Plug 'iamcco/coc-vimlsp', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'}
Plug 'weirongxu/coc-explorer', {'do': 'yarn install --frozen-lockfile'}
Plug 'liuchengxu/eleline.vim'
Plug 'tpope/vim-fugitive' " git 功能
Plug 'scrooloose/nerdcommenter'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'mhinz/vim-grepper', { 'on': ['Grepper', '<plug>(GrepperOperator)'] }
call plug#end()
" ==== coc configuration ====
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>sd :call CocAction('doHover')<CR>
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>fe :CocCommand explorer --toggle<CR>
nmap <silent> <leader>if :CocInfo<CR>
nmap <silent> <leader>cl :CocList<CR>
nmap <silent> <leader>ol <Plug>(coc-openlink)
nnoremap <leader>sg :Grepper -tool git<CR>
nnoremap <leader>sc :Grepper -tool grep<CR>
" ==== 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>
" ==== ctrlp configuration ====
let g:ctrlp_user_command = ['.git', 'git ls-files -co --exclude-standard']

27
vimrc
View File

@ -50,11 +50,14 @@ Plug 'jiangmiao/auto-pairs'
" ide like " ide like
Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'mgedmin/coverage-highlight.vim' Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'}
"Plug 'klesh/vim-fakeclip' Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'}
Plug 'weirongxu/coc-explorer', {'do': 'yarn install --frozen-lockfile'}
Plug 'scrooloose/nerdcommenter' Plug 'scrooloose/nerdcommenter'
Plug 'tpope/vim-fugitive' " git 功能 Plug 'tpope/vim-fugitive' " git 功能
Plug 'scrooloose/nerdtree' "Plug 'scrooloose/nerdtree'
"Plug 'mgedmin/coverage-highlight.vim'
"Plug 'klesh/vim-fakeclip'
" color themes " color themes
Plug 'morhetz/gruvbox' Plug 'morhetz/gruvbox'
@ -66,7 +69,7 @@ Plug 'lunaru/vim-less'
Plug 'posva/vim-vue' Plug 'posva/vim-vue'
Plug 'othree/html5.vim' Plug 'othree/html5.vim'
Plug 'dag/vim-fish' Plug 'dag/vim-fish'
Plug 'vim-python/python-syntax' "Plug 'vim-python/python-syntax'
Plug 'plasticboy/vim-markdown' Plug 'plasticboy/vim-markdown'
"Plug 'digitaltoad/vim-pug' "Plug 'digitaltoad/vim-pug'
@ -80,15 +83,21 @@ nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation) nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references) 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>fe :CocCommand explorer --toggle<CR>
nmap <silent> <leader>if :CocInfo<CR>
nmap <silent> <leader>cl :CocList<CR>
nmap <silent> <leader>ol <Plug>(coc-openlink)
" Highlight symbol under cursor on CursorHold " Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight') autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" Use K to show documentation in preview window " Use K to show documentation in preview window
function! s:show_documentation() function! s:show_documentation()