2020-11-29 15:36:51 +08:00
|
|
|
|
"
|
|
|
|
|
" Tips:
|
|
|
|
|
"
|
|
|
|
|
" - :noh to clear highlighting
|
|
|
|
|
" - g* to search for current word
|
2021-02-25 23:24:40 +08:00
|
|
|
|
" - gq to reformat line into column
|
2021-08-25 23:01:05 +08:00
|
|
|
|
" - y[motion] to yank, d[motion] to cut
|
|
|
|
|
" - "[reg] to yank/cut/paste to reg
|
|
|
|
|
" - ys[motion][char] to add surrounding chars
|
|
|
|
|
" - gS, gJ to split and join multiline statements
|
|
|
|
|
" - gd to go to Go definition
|
2020-11-29 15:36:51 +08:00
|
|
|
|
"
|
|
|
|
|
|
2018-04-01 16:54:18 +08:00
|
|
|
|
call plug#begin()
|
|
|
|
|
|
2021-04-03 13:04:02 +08:00
|
|
|
|
" language server protocol
|
|
|
|
|
|
|
|
|
|
Plug 'prabirshrestha/vim-lsp'
|
|
|
|
|
Plug 'mattn/vim-lsp-settings'
|
|
|
|
|
Plug 'prabirshrestha/asyncomplete.vim'
|
|
|
|
|
Plug 'prabirshrestha/asyncomplete-lsp.vim'
|
2021-04-03 12:38:27 +08:00
|
|
|
|
|
2020-11-03 02:02:04 +08:00
|
|
|
|
" rust
|
2020-11-04 01:18:01 +08:00
|
|
|
|
|
2020-11-03 02:02:04 +08:00
|
|
|
|
Plug 'rust-lang/rust.vim'
|
2020-11-04 03:15:11 +08:00
|
|
|
|
Plug 'racer-rust/vim-racer'
|
2020-11-03 02:02:04 +08:00
|
|
|
|
let g:rustfmt_autosave = 1
|
2020-11-04 03:15:11 +08:00
|
|
|
|
autocmd FileType rust nmap <leader>t :Ctest<CR>
|
|
|
|
|
autocmd FileType rust nmap <leader>b :Cbuild<CR>
|
|
|
|
|
autocmd FileType rust nmap <leader>r :Crun<CR>
|
|
|
|
|
autocmd FileType rust nmap K <Plug>(rust-def)
|
|
|
|
|
" runthis: cargo +nightly install --git https://github.com/racer-rust/racer.git racer
|
2018-04-01 16:54:18 +08:00
|
|
|
|
|
|
|
|
|
" go
|
2019-10-22 22:23:04 +08:00
|
|
|
|
|
2020-11-04 01:18:01 +08:00
|
|
|
|
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
|
2020-11-04 03:15:11 +08:00
|
|
|
|
Plug 'AndrewRadev/splitjoin.vim'
|
|
|
|
|
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
|
|
|
|
|
let g:go_highlight_build_constraints = 1
|
|
|
|
|
let g:go_highlight_generate_tags = 1
|
|
|
|
|
let g:go_metalinter_autosave = 1
|
|
|
|
|
let g:go_fmt_command = "goimports"
|
2020-11-10 09:37:58 +08:00
|
|
|
|
let g:go_list_type_commands = {"GoMetaLinterAutoSave": "quickfix"}
|
2020-11-29 15:36:51 +08:00
|
|
|
|
autocmd FileType go nmap <leader>a <Plug>(go-alternate-edit)
|
2020-11-04 01:18:01 +08:00
|
|
|
|
autocmd FileType go nmap <leader>t <Plug>(go-test)
|
|
|
|
|
autocmd FileType go nmap <Leader>c <Plug>(go-coverage-toggle)
|
|
|
|
|
autocmd FileType go nmap <leader>b <Plug>(go-build)
|
|
|
|
|
autocmd FileType go nmap <leader>r <Plug>(go-run)
|
2020-11-04 03:15:11 +08:00
|
|
|
|
" K -> :GoDoc
|
|
|
|
|
|
2021-04-03 11:42:31 +08:00
|
|
|
|
" vue
|
|
|
|
|
|
|
|
|
|
Plug 'posva/vim-vue'
|
|
|
|
|
|
2021-08-25 23:01:05 +08:00
|
|
|
|
" git
|
2021-04-03 14:16:09 +08:00
|
|
|
|
|
|
|
|
|
Plug 'airblade/vim-gitgutter'
|
2021-08-25 23:01:05 +08:00
|
|
|
|
Plug 'tpope/vim-fugitive'
|
2021-04-03 14:16:09 +08:00
|
|
|
|
|
2021-08-25 23:01:05 +08:00
|
|
|
|
" extra motions
|
2021-08-25 22:46:54 +08:00
|
|
|
|
|
|
|
|
|
Plug 'tpope/vim-surround'
|
|
|
|
|
Plug 'tpope/vim-repeat'
|
|
|
|
|
|
2018-04-01 16:54:18 +08:00
|
|
|
|
call plug#end()
|
|
|
|
|
|
2020-11-04 01:18:01 +08:00
|
|
|
|
" theme
|
|
|
|
|
|
|
|
|
|
set background=dark
|
|
|
|
|
if $LIGHT == 'true'
|
|
|
|
|
set background=light
|
|
|
|
|
endif
|
2020-11-04 22:30:52 +08:00
|
|
|
|
let g:solarized_termtrans=1
|
2020-11-04 01:18:01 +08:00
|
|
|
|
silent! colorscheme solarized
|
|
|
|
|
|
2019-10-22 00:20:23 +08:00
|
|
|
|
" statusline
|
2020-11-04 01:18:01 +08:00
|
|
|
|
|
2019-10-22 00:20:23 +08:00
|
|
|
|
function! GitBranch()
|
2020-11-04 01:18:01 +08:00
|
|
|
|
return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
|
2019-10-22 00:20:23 +08:00
|
|
|
|
endfunction
|
|
|
|
|
function! GitDirty()
|
2020-11-04 01:18:01 +08:00
|
|
|
|
return system("git status --porcelain --ignore-submodules -unormal 2>/dev/null") != ""
|
2019-10-22 00:20:23 +08:00
|
|
|
|
endfunction
|
|
|
|
|
|
2019-10-22 22:23:04 +08:00
|
|
|
|
let w:git_branch = GitBranch()
|
|
|
|
|
let w:git_dirty = GitDirty()
|
2019-10-22 00:20:23 +08:00
|
|
|
|
function! StatuslineUpdateLazy()
|
2020-11-04 01:18:01 +08:00
|
|
|
|
let w:git_branch = GitBranch()
|
|
|
|
|
let w:git_dirty = GitDirty()
|
2019-10-22 00:20:23 +08:00
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! StatuslineGit()
|
2020-11-04 01:18:01 +08:00
|
|
|
|
return strlen(w:git_branch) > 0?' '.w:git_branch.' ':''
|
2019-10-22 00:20:23 +08:00
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" assembly
|
2020-11-04 01:18:01 +08:00
|
|
|
|
|
2019-10-22 00:20:23 +08:00
|
|
|
|
set statusline=
|
|
|
|
|
set statusline+=%#StatuslineModeNormal#%{(mode()=='n')?'\ \ NORMAL\ \ ':''}
|
|
|
|
|
set statusline+=%#StatuslineModeInsert#%{(mode()=='i')?'\ \ INSERT\ \ ':''}
|
2020-11-04 01:18:01 +08:00
|
|
|
|
set statusline+=%#StatuslineModeReplace#%{(mode()=='R')?'\ \ REPLACE\ ':''}
|
2019-10-22 00:20:23 +08:00
|
|
|
|
set statusline+=%#StatuslineModeVisual#%{(mode()=='v')?'\ \ VISUAL\ \ ':''}
|
|
|
|
|
set statusline+=%#StatuslineModeVisualLine#%{(mode()=='V')?'\ \ VISUAL\ \ ':''}
|
|
|
|
|
set statusline+=%#StatuslineModeVisual#%{(mode()==\"\\\<C-V>\")?'\ \ V-BLOCK\ ':''}
|
|
|
|
|
set statusline+=%#StatuslineModeCommand#%{(mode()=='c')?'\ \ COMMAND\ ':''}
|
|
|
|
|
set statusline+=%#StatuslineModeOther#%{(mode()=='s')?'\ \ SELECT\ \ ':''}
|
|
|
|
|
set statusline+=%#StatuslineModeOther#%{(mode()=='S')?'\ \ S-LINE\ \ ':''}
|
|
|
|
|
set statusline+=%#StatuslineModeOther#%{(mode()==\"\\\<C-S>\")?'\ \ S-BLOCK\ ':''}
|
|
|
|
|
set statusline+=%#StatuslineModeOther#%{(mode()=='t')?'\ \ TERMINAL\ ':''}
|
2019-10-22 22:23:04 +08:00
|
|
|
|
set statusline+=%#StatuslineGit#%{(w:git_dirty)?'':StatuslineGit()}
|
|
|
|
|
set statusline+=%#StatuslineGitDirty#%{(w:git_dirty)?StatuslineGit():''}
|
|
|
|
|
set statusline+=%*
|
2019-10-22 00:20:23 +08:00
|
|
|
|
set statusline+=\ %f
|
|
|
|
|
set statusline+=\ %m
|
|
|
|
|
set statusline+=\%r
|
|
|
|
|
set statusline+=%=
|
|
|
|
|
set statusline+=%#StatuslineFileInfo#
|
|
|
|
|
set statusline+=\ %y
|
|
|
|
|
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
|
|
|
|
|
set statusline+=\ %{&fileformat}
|
|
|
|
|
set statusline+=\
|
|
|
|
|
set statusline+=%#StatuslineFileStats#
|
|
|
|
|
set statusline+=\ %L×%p%%
|
|
|
|
|
set statusline+=\
|
|
|
|
|
set statusline+=%#StatuslineCursor#
|
|
|
|
|
set statusline+=\ %l:%c
|
|
|
|
|
set statusline+=\
|
2019-10-22 22:23:04 +08:00
|
|
|
|
augroup StatuslineUpdate
|
2020-11-04 01:18:01 +08:00
|
|
|
|
autocmd BufWritePost,BufEnter,ShellCmdPost * call StatuslineUpdateLazy()
|
2019-10-22 00:20:23 +08:00
|
|
|
|
augroup END
|
|
|
|
|
|
2020-11-04 01:18:01 +08:00
|
|
|
|
" folding, numbering, cursorline
|
2019-10-21 18:08:35 +08:00
|
|
|
|
|
2019-10-22 22:23:04 +08:00
|
|
|
|
set foldcolumn=1
|
2018-04-01 16:54:18 +08:00
|
|
|
|
set number
|
|
|
|
|
set cursorline
|
2020-11-03 02:02:04 +08:00
|
|
|
|
|
2018-04-01 16:54:18 +08:00
|
|
|
|
" indentation
|
2020-11-04 01:18:01 +08:00
|
|
|
|
|
2018-04-01 16:54:18 +08:00
|
|
|
|
set tabstop=4
|
|
|
|
|
set softtabstop=4
|
|
|
|
|
set shiftwidth=4
|
2019-10-22 22:23:04 +08:00
|
|
|
|
|
2020-04-14 11:53:33 +08:00
|
|
|
|
" width
|
2020-11-04 01:18:01 +08:00
|
|
|
|
|
2020-11-03 02:02:04 +08:00
|
|
|
|
set colorcolumn=80
|
2020-11-04 01:18:01 +08:00
|
|
|
|
"set textwidth=80
|
|
|
|
|
|
|
|
|
|
" enable configuring indentation and width using modeline
|
|
|
|
|
|
|
|
|
|
set modeline
|
2020-04-14 11:53:33 +08:00
|
|
|
|
|
2019-10-22 22:23:04 +08:00
|
|
|
|
" skel
|
2020-11-04 01:18:01 +08:00
|
|
|
|
|
2021-03-16 17:36:32 +08:00
|
|
|
|
fun LoadSkel(ext, title)
|
|
|
|
|
exe "0r ~/.config/nvim/skel/skel." . a:ext
|
|
|
|
|
exe "$d"
|
|
|
|
|
exe "%s/Title/" . a:title . "/e"
|
|
|
|
|
endfunction
|
2019-10-22 22:23:04 +08:00
|
|
|
|
augroup Skel
|
2021-03-16 17:36:32 +08:00
|
|
|
|
autocmd BufNewFile *.sh call LoadSkel("sh", expand("%:r"))
|
|
|
|
|
autocmd BufNewFile *.md call LoadSkel("md", expand("%:r"))
|
|
|
|
|
autocmd BufNewFile *.html call LoadSkel("html", expand("%:r"))
|
|
|
|
|
autocmd BufNewFile *.py call LoadSkel("py", expand("%:r"))
|
|
|
|
|
autocmd BufNewFile *.yaml,*.yml call LoadSkel("yaml", expand("%:r"))
|
2019-10-22 22:23:04 +08:00
|
|
|
|
augroup END
|
|
|
|
|
|
2020-11-04 01:18:01 +08:00
|
|
|
|
" characters, hidden characters
|
2018-04-01 16:54:18 +08:00
|
|
|
|
|
2020-11-04 01:18:01 +08:00
|
|
|
|
set fillchars=stl:\ ,stlnc:\ ,vert:\ ,fold:·,diff:-
|
|
|
|
|
set list
|
2020-05-05 10:29:38 +08:00
|
|
|
|
let g:listchars = [ "tab:\\\ \\\ ,extends:›,precedes:‹,nbsp:␣,trail:·", "tab:⇥\\\ ,extends:›,precedes:‹,nbsp:␣,trail:·,space:·", "tab:⇥\\\ ,extends:›,precedes:‹,nbsp:␣,trail:·,space:·,eol:↵"]
|
2020-11-04 01:18:01 +08:00
|
|
|
|
let g:listchars_mode = -1 " -1 means default is 0
|
2019-10-22 22:23:04 +08:00
|
|
|
|
function! ToggleListChars()
|
2020-11-04 01:18:01 +08:00
|
|
|
|
let g:listchars_mode += 1
|
|
|
|
|
if g:listchars_mode >= len(g:listchars)
|
|
|
|
|
let g:listchars_mode = -1
|
|
|
|
|
call ToggleListChars()
|
|
|
|
|
else
|
|
|
|
|
exe "set listchars=".g:listchars[g:listchars_mode]
|
|
|
|
|
endif
|
2019-10-22 22:23:04 +08:00
|
|
|
|
endfunction
|
|
|
|
|
call ToggleListChars()
|
|
|
|
|
command! NonPrintable call ToggleListChars()
|
|
|
|
|
command! NP call ToggleListChars()
|
2018-04-01 16:54:18 +08:00
|
|
|
|
|
2019-01-18 17:58:52 +08:00
|
|
|
|
" file browser
|
2020-11-04 01:18:01 +08:00
|
|
|
|
|
2019-01-18 17:58:52 +08:00
|
|
|
|
let g:netrw_banner=0
|
|
|
|
|
let g:netrw_liststyle=3
|
|
|
|
|
let g:netrw_winsize=25
|
|
|
|
|
|
2018-04-01 16:54:18 +08:00
|
|
|
|
" spellcheck
|
|
|
|
|
|
2020-11-04 01:18:01 +08:00
|
|
|
|
set spell spelllang=en_gb
|