2021-03-25 12:52:44 +00:00
|
|
|
|
" Specify a directory for plugins
|
|
|
|
|
" - For Neovim: stdpath('data') . '/plugged'
|
|
|
|
|
" - Avoid using standard Vim directory names like 'plugin'
|
|
|
|
|
call plug#begin(stdpath('data').'/plugged')
|
|
|
|
|
|
|
|
|
|
" Make sure you use single quotes
|
|
|
|
|
Plug 'neovim/nvim-lspconfig'
|
|
|
|
|
Plug 'nvim-lua/completion-nvim'
|
|
|
|
|
|
|
|
|
|
Plug 'tomasr/molokai'
|
|
|
|
|
Plug 'scrooloose/nerdcommenter'
|
|
|
|
|
Plug 'vim-scripts/DrawIt'
|
|
|
|
|
Plug 'easymotion/vim-easymotion'
|
|
|
|
|
Plug 'mattn/emmet-vim'
|
|
|
|
|
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
|
|
|
|
|
Plug 'pangloss/vim-javascript'
|
|
|
|
|
" tagbar
|
|
|
|
|
" golang install go get -u github.com/jstemmer/gotags
|
|
|
|
|
Plug 'majutsushi/tagbar'
|
|
|
|
|
Plug 'w0rp/ale'
|
|
|
|
|
Plug 'godlygeek/tabular'
|
|
|
|
|
Plug 'ctrlpvim/ctrlp.vim'
|
|
|
|
|
Plug 'kien/tabman.vim'
|
|
|
|
|
Plug 'vim-airline/vim-airline'
|
|
|
|
|
" for git
|
|
|
|
|
Plug 'tpope/vim-fugitive'
|
|
|
|
|
Plug 'christoomey/vim-conflicted'
|
|
|
|
|
|
|
|
|
|
" for mark
|
|
|
|
|
Plug 'inkarkat/vim-ingo-library'
|
|
|
|
|
Plug 'inkarkat/vim-mark'
|
|
|
|
|
|
|
|
|
|
Plug 'rking/ag.vim'
|
|
|
|
|
Plug 'terryma/vim-multiple-cursors'
|
|
|
|
|
Plug 'vim-scripts/TaskList.vim'
|
|
|
|
|
Plug 'rust-lang/rust.vim'
|
2021-03-25 15:05:54 +00:00
|
|
|
|
Plug 'buoto/gotests-vim'
|
2021-03-25 12:52:44 +00:00
|
|
|
|
|
|
|
|
|
" color scheme
|
|
|
|
|
Plug 'danilo-augusto/vim-afterglow'
|
|
|
|
|
|
|
|
|
|
" defx explorer
|
|
|
|
|
if has('nvim')
|
|
|
|
|
Plug 'Shougo/defx.nvim', { 'do': ':UpdateRemotePlugins' }
|
|
|
|
|
else
|
|
|
|
|
Plug 'Shougo/defx.nvim'
|
|
|
|
|
Plug 'roxma/nvim-yarp'
|
|
|
|
|
Plug 'roxma/vim-hug-neovim-rpc'
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
" Initialize plugin system
|
|
|
|
|
call plug#end()
|
|
|
|
|
|
|
|
|
|
syntax on
|
|
|
|
|
set number
|
|
|
|
|
set tabstop=2
|
|
|
|
|
set shiftwidth=2
|
|
|
|
|
set expandtab
|
|
|
|
|
set nofoldenable
|
|
|
|
|
|
|
|
|
|
set pastetoggle=<F2>
|
|
|
|
|
" always show status
|
|
|
|
|
set laststatus=2
|
|
|
|
|
" show cursor position
|
|
|
|
|
set ruler
|
|
|
|
|
set cursorline
|
|
|
|
|
set cursorcolumn
|
|
|
|
|
set hlsearch
|
|
|
|
|
" no wrap line
|
|
|
|
|
set nowrap
|
|
|
|
|
" enable backspace
|
|
|
|
|
set backspace=indent,eol,start
|
|
|
|
|
set encoding=utf-8
|
|
|
|
|
" set font
|
|
|
|
|
" set guifont=Hack\ Nerd\ Font:h11
|
|
|
|
|
|
|
|
|
|
set background=dark
|
|
|
|
|
|
|
|
|
|
function! AdaptColorscheme()
|
|
|
|
|
highlight clear CursorLine
|
|
|
|
|
highlight Normal ctermbg=none
|
|
|
|
|
highlight LineNr ctermbg=none
|
|
|
|
|
highlight Folded ctermbg=none
|
|
|
|
|
highlight NonText ctermbg=none
|
|
|
|
|
highlight SpecialKey ctermbg=none
|
|
|
|
|
highlight VertSplit ctermbg=none
|
|
|
|
|
highlight SignColumn ctermbg=none
|
|
|
|
|
endfunction
|
|
|
|
|
autocmd ColorScheme * call AdaptColorscheme()
|
|
|
|
|
colorscheme afterglow
|
|
|
|
|
|
|
|
|
|
" define leader key
|
|
|
|
|
let mapleader=";"
|
|
|
|
|
filetype indent on
|
|
|
|
|
" 開啟檔案類型偵測
|
|
|
|
|
filetype on
|
|
|
|
|
" 根據檔案類型載入plugin
|
|
|
|
|
filetype plugin on
|
|
|
|
|
autocmd BufWritePost $MYVIMRC source $MYVIMRC
|
|
|
|
|
|
|
|
|
|
" split window
|
|
|
|
|
nmap <leader>sw <c-w>
|
|
|
|
|
nmap <leader>sww <c-w>k
|
|
|
|
|
nmap <leader>sws <c-w>j
|
|
|
|
|
nmap <leader>swa <c-w>h
|
|
|
|
|
nmap <leader>swd <c-w>l
|
|
|
|
|
nmap <leader>aa gT
|
|
|
|
|
nmap <leader>dd gt
|
|
|
|
|
|
|
|
|
|
nnoremap <silent> <leader>gd <cmd>lua vim.lsp.buf.definition()<CR>
|
|
|
|
|
nnoremap <silent> <leader>gt <cmd>tab split<CR><cmd>lua vim.lsp.buf.definition()<CR>
|
|
|
|
|
nnoremap <silent> <leader>p <cmd>lua vim.lsp.buf.hover()<CR>
|
|
|
|
|
nnoremap <silent> <leader>gr <cmd>lua vim.lsp.buf.references()<CR>
|
|
|
|
|
nnoremap <silent> <leader>i <cmd>lua vim.lsp.buf.implementation()<CR>
|
|
|
|
|
nnoremap <silent> <leader>gs <cmd>split \| lua vim.lsp.buf.definition()<CR>
|
|
|
|
|
nnoremap <silent> <leader>gv <cmd>vsplit \| lua vim.lsp.buf.definition()<CR>
|
|
|
|
|
nnoremap <silent> <leader>grn <cmd>lua vim.lsp.buf.rename()<CR>
|
|
|
|
|
|
|
|
|
|
" initialize lsp
|
|
|
|
|
lua require'lspconfig'.gopls.setup{on_attach=require'completion'.on_attach}
|
2021-03-25 12:59:31 +00:00
|
|
|
|
lua require'lspconfig'.rust_analyzer.setup{on_attach=require'completion'.on_attach}
|
|
|
|
|
lua require'lspconfig'.tsserver.setup{on_attach=require'completion'.on_attach}
|
2021-03-25 12:52:44 +00:00
|
|
|
|
|
|
|
|
|
" autocomplete setting
|
|
|
|
|
" --------------------
|
|
|
|
|
let g:completion_enable_auto_popup = 0
|
|
|
|
|
let g:completion_trigger_character = ['.', '::']
|
|
|
|
|
|
|
|
|
|
function! s:check_back_space() abort
|
|
|
|
|
let col = col('.') - 1
|
|
|
|
|
return !col || getline('.')[col - 1] =~ '\s'
|
|
|
|
|
endfunction
|
|
|
|
|
" Use <Tab> and <S-Tab> to navigate through popup menu
|
|
|
|
|
inoremap <expr> <Tab>
|
|
|
|
|
\ pumvisible() ? "\<C-n>" :
|
|
|
|
|
\ "\<Tab>"
|
|
|
|
|
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
|
|
|
|
|
|
|
|
|
" Set completeopt to have a better completion experience
|
|
|
|
|
set completeopt=menuone,noinsert,noselect
|
|
|
|
|
|
|
|
|
|
" Avoid showing message extra message when using completion
|
|
|
|
|
set shortmess+=c
|
|
|
|
|
|
|
|
|
|
imap <silent> <c-p> <Plug>(completion_trigger)
|
|
|
|
|
imap <tab> <Plug>(completion_smart_tab)
|
|
|
|
|
imap <s-tab> <Plug>(completion_smart_s_tab)
|
|
|
|
|
|
|
|
|
|
" --------------------
|
|
|
|
|
|
|
|
|
|
" defx settings
|
|
|
|
|
call defx#custom#option('_', {
|
|
|
|
|
\ 'winwidth': 40,
|
|
|
|
|
\ 'split': 'vertical',
|
|
|
|
|
\ 'direction': 'topleft',
|
|
|
|
|
\ 'buffer_name': '',
|
|
|
|
|
\ 'toggle': 1,
|
|
|
|
|
\ 'resume': 1,
|
|
|
|
|
\ })
|
|
|
|
|
nmap <F3> :Defx<CR>
|
|
|
|
|
nmap <leader>me :Defx<CR>
|
|
|
|
|
autocmd FileType defx call s:defx_my_settings()
|
|
|
|
|
function! s:defx_my_settings() abort
|
|
|
|
|
" Define mappings
|
|
|
|
|
nnoremap <silent><buffer><expr> <CR>
|
|
|
|
|
\ defx#is_directory() ?
|
|
|
|
|
\ defx#do_action('open_tree', 'toggle') :
|
|
|
|
|
\ defx#do_action('drop')
|
|
|
|
|
nnoremap <silent><buffer><expr> T
|
|
|
|
|
\ defx#do_action('open', 'tabe')
|
|
|
|
|
nnoremap <silent><buffer><expr> s
|
|
|
|
|
\ defx#do_action('drop', 'vsplit')
|
|
|
|
|
nnoremap <silent><buffer><expr> mc
|
|
|
|
|
\ defx#do_action('copy')
|
|
|
|
|
nnoremap <silent><buffer><expr> mm
|
|
|
|
|
\ defx#do_action('move')
|
|
|
|
|
nnoremap <silent><buffer><expr> mp
|
|
|
|
|
\ defx#do_action('paste')
|
|
|
|
|
nnoremap <silent><buffer><expr> P
|
|
|
|
|
\ defx#do_action('preview')
|
|
|
|
|
nnoremap <silent><buffer><expr> o
|
|
|
|
|
\ defx#do_action('open_tree', 'toggle')
|
|
|
|
|
nnoremap <silent><buffer><expr> ma
|
|
|
|
|
\ defx#do_action('new_file')
|
|
|
|
|
nnoremap <silent><buffer><expr> C
|
|
|
|
|
\ defx#do_action('toggle_columns',
|
|
|
|
|
\ 'mark:indent:icon:filename:type:size:time')
|
|
|
|
|
nnoremap <silent><buffer><expr> S
|
|
|
|
|
\ defx#do_action('toggle_sort', 'time')
|
|
|
|
|
nnoremap <silent><buffer><expr> md
|
|
|
|
|
\ defx#do_action('remove')
|
|
|
|
|
nnoremap <silent><buffer><expr> mr
|
|
|
|
|
\ defx#do_action('rename')
|
|
|
|
|
nnoremap <silent><buffer><expr> !
|
|
|
|
|
\ defx#do_action('execute_command')
|
|
|
|
|
nnoremap <silent><buffer><expr> x
|
|
|
|
|
\ defx#do_action('execute_system')
|
|
|
|
|
nnoremap <silent><buffer><expr> yy
|
|
|
|
|
\ defx#do_action('yank_path')
|
|
|
|
|
nnoremap <silent><buffer><expr> .
|
|
|
|
|
\ defx#do_action('toggle_ignored_files')
|
|
|
|
|
nnoremap <silent><buffer><expr> ;
|
|
|
|
|
\ defx#do_action('repeat')
|
|
|
|
|
nnoremap <silent><buffer><expr> h
|
|
|
|
|
\ defx#do_action('cd', ['..'])
|
|
|
|
|
nnoremap <silent><buffer><expr> ~
|
|
|
|
|
\ defx#do_action('cd')
|
|
|
|
|
nnoremap <silent><buffer><expr> q
|
|
|
|
|
\ defx#do_action('quit')
|
|
|
|
|
nnoremap <silent><buffer><expr> <Space>
|
|
|
|
|
\ defx#do_action('toggle_select') . 'j'
|
|
|
|
|
nnoremap <silent><buffer><expr> *
|
|
|
|
|
\ defx#do_action('toggle_select_all')
|
|
|
|
|
nnoremap <silent><buffer><expr> j
|
|
|
|
|
\ line('.') == line('$') ? 'gg' : 'j'
|
|
|
|
|
nnoremap <silent><buffer><expr> k
|
|
|
|
|
\ line('.') == 1 ? 'G' : 'k'
|
|
|
|
|
nnoremap <silent><buffer><expr> r
|
|
|
|
|
\ defx#do_action('redraw')
|
|
|
|
|
nnoremap <silent><buffer><expr> <C-g>
|
|
|
|
|
\ defx#do_action('print')
|
|
|
|
|
nnoremap <silent><buffer><expr> cd
|
|
|
|
|
\ defx#do_action('change_vim_cwd')
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" tagbar
|
|
|
|
|
nmap <F8> :TagbarToggle<CR>
|
|
|
|
|
|
|
|
|
|
" <Leader>f{char} to move to {char}
|
|
|
|
|
map <Leader>f <Plug>(easymotion-bd-f)
|
|
|
|
|
nmap <Leader>f <Plug>(easymotion-overwin-f)
|
|
|
|
|
" s{char}{char} to move to {char}{char}
|
|
|
|
|
nmap s <Plug>(easymotion-overwin-f2)
|
|
|
|
|
" Move to line
|
|
|
|
|
map <Leader>L <Plug>(easymotion-bd-jk)
|
|
|
|
|
nmap <Leader>L <Plug>(easymotion-overwin-line)
|
|
|
|
|
" Move to word
|
|
|
|
|
map <Leader>w <Plug>(easymotion-bd-w)
|
|
|
|
|
nmap <Leader>w <Plug>(easymotion-overwin-w)
|
|
|
|
|
|
|
|
|
|
" lint
|
|
|
|
|
let g:ale_linters = {
|
|
|
|
|
\ 'javascript': ['standard'],
|
|
|
|
|
\ 'go': ['gopls'],
|
|
|
|
|
\ 'rust': ['analyzer'],
|
|
|
|
|
\}
|
|
|
|
|
let g:ale_fixers = {'javascript': ['standard']}
|
|
|
|
|
let g:ale_lint_on_save = 1
|
|
|
|
|
let g:ale_fix_on_save = 1
|
|
|
|
|
nmap <leader>= <Plug>(ale_fix)
|
|
|
|
|
|
|
|
|
|
" NERDCommenter
|
|
|
|
|
let g:NERDSpaceDelims=1
|
|
|
|
|
let g:NERDDefaultAlign='left'
|
|
|
|
|
|
|
|
|
|
let g:tagbar_type_go = {
|
|
|
|
|
\ 'ctagstype' : 'go',
|
|
|
|
|
\ 'kinds' : [
|
|
|
|
|
\ 'p:package',
|
|
|
|
|
\ 'i:imports:1',
|
|
|
|
|
\ 'c:constants',
|
|
|
|
|
\ 'v:variables',
|
|
|
|
|
\ 't:types',
|
|
|
|
|
\ 'n:interfaces',
|
|
|
|
|
\ 'w:fields',
|
|
|
|
|
\ 'e:embedded',
|
|
|
|
|
\ 'm:methods',
|
|
|
|
|
\ 'r:constructor',
|
|
|
|
|
\ 'f:functions'
|
|
|
|
|
\ ],
|
|
|
|
|
\ 'sro' : '.',
|
|
|
|
|
\ 'kind2scope' : {
|
|
|
|
|
\ 't' : 'ctype',
|
|
|
|
|
\ 'n' : 'ntype'
|
|
|
|
|
\ },
|
|
|
|
|
\ 'scope2kind' : {
|
|
|
|
|
\ 'ctype' : 't',
|
|
|
|
|
\ 'ntype' : 'n'
|
|
|
|
|
\ },
|
|
|
|
|
\ 'ctagsbin' : 'gotags',
|
|
|
|
|
\ 'ctagsargs' : '-sort -silent'
|
|
|
|
|
\ }
|
|
|
|
|
|
|
|
|
|
let g:go_fmt_fail_silently = 1
|
|
|
|
|
let g:go_fmt_command = "goimports"
|
|
|
|
|
let g:go_def_mode = 'godef'
|
|
|
|
|
let g:go_decls_includes = "func,type"
|
|
|
|
|
let g:go_highlight_types = 1
|
|
|
|
|
let g:go_highlight_fields = 1
|
|
|
|
|
let g:go_highlight_functions = 1
|
|
|
|
|
let g:go_highlight_function_calls = 1
|
|
|
|
|
let g:go_highlight_operators = 1
|
|
|
|
|
let g:go_highlight_extra_types = 1
|
|
|
|
|
|
|
|
|
|
" for rust-vim
|
|
|
|
|
let g:rust_recommended_style = 0
|
|
|
|
|
let g:rustfmt_autosave = 1
|
|
|
|
|
let g:syntastic_rust_checkers = ['cargo']
|
|
|
|
|
|
|
|
|
|
let g:airline#extensions#tabline#enabled = 1
|
|
|
|
|
let g:airline#extensions#tabline#show_buffers = 0
|
|
|
|
|
let g:airline#extensions#tabline#show_splits = 0
|
|
|
|
|
let g:airline#extensions#tabline#show_tabs = 1
|
|
|
|
|
let g:airline#extensions#tabline#show_tab_nr = 0
|
|
|
|
|
let g:airline#extensions#tabline#show_tab_type = 0
|
|
|
|
|
let g:airline#extensions#tabline#close_symbol = '×'
|
|
|
|
|
let g:airline#extensions#tabline#show_close_button = 0
|
|
|
|
|
|
|
|
|
|
let g:multi_cursor_use_default_mapping=0
|
|
|
|
|
|
|
|
|
|
" Default mapping
|
|
|
|
|
let g:multi_cursor_start_word_key = "<C-n>"
|
|
|
|
|
let g:multi_cursor_select_all_word_key = '<A-n>'
|
|
|
|
|
let g:multi_cursor_start_key = "g<C-n>"
|
|
|
|
|
let g:multi_cursor_select_all_key = 'g<A-n>'
|
|
|
|
|
let g:multi_cursor_next_key = "<C-n>"
|
|
|
|
|
" let g:multi_cursor_prev_key = '<C-p>'
|
|
|
|
|
let g:multi_cursor_skip_key = '<C-x>'
|
|
|
|
|
let g:multi_cursor_quit_key = '<Esc>'
|
|
|
|
|
|
|
|
|
|
let g:javascript_plugin_jsdoc = 1
|