From ccc0bb0f478cda696ec313a335dd8bd3fc406348 Mon Sep 17 00:00:00 2001 From: wklken Date: Sat, 4 May 2019 17:32:16 +0800 Subject: [PATCH 1/8] v9.3 beta settings --- UltiSnips/python.snippets | 4 +- install.sh | 2 + others/italic/tmux-256color.terminfo | 4 + others/italic/xterm-256color-italic.terminfo | 4 + vimrc | 20 ++- vimrc.bundles | 146 +++++++++++-------- 6 files changed, 117 insertions(+), 63 deletions(-) create mode 100644 others/italic/tmux-256color.terminfo create mode 100644 others/italic/xterm-256color-italic.terminfo diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets index a23487580..c23c8a87f 100644 --- a/UltiSnips/python.snippets +++ b/UltiSnips/python.snippets @@ -49,7 +49,7 @@ self.${1} endsnippet snippet p "print" -print ${1} +print(${1}) endsnippet snippet pr "print " @@ -57,7 +57,7 @@ print "${1}" endsnippet snippet pri "print ''" -print '${1}' +print('${1}') endsnippet snippet prt "print trace" diff --git a/install.sh b/install.sh index 84ab80ec3..507c836f6 100755 --- a/install.sh +++ b/install.sh @@ -92,6 +92,8 @@ git submodule update --init --recursive if [ `which clang` ] # check system clang then python install.py --clang-completer --system-libclang # use system clang + # for golang + # python install.py --clang-completer --system-libclang --go-completer else python install.py --clang-completer fi diff --git a/others/italic/tmux-256color.terminfo b/others/italic/tmux-256color.terminfo new file mode 100644 index 000000000..a1019b69a --- /dev/null +++ b/others/italic/tmux-256color.terminfo @@ -0,0 +1,4 @@ +# A tmux-256color based TERMINFO that adds the escape sequences for italic. +tmux-256color|screen with 256 colors and italic, + sitm=\E[3m, ritm=\E[23m, + use=screen-256color, diff --git a/others/italic/xterm-256color-italic.terminfo b/others/italic/xterm-256color-italic.terminfo new file mode 100644 index 000000000..68407aeeb --- /dev/null +++ b/others/italic/xterm-256color-italic.terminfo @@ -0,0 +1,4 @@ +# A xterm-256color based TERMINFO that adds the escape sequences for italic. +xterm-256color-italic|xterm with 256 colors and italic, + sitm=\E[3m, ritm=\E[23m, + use=xterm-256color, diff --git a/vimrc b/vimrc index 3fc1bdc3b..fcd54ccdc 100644 --- a/vimrc +++ b/vimrc @@ -1,11 +1,11 @@ "========================================== " Author: wklken -" Version: 9.1 +" Version: 9.2 " Email: wklken@yeah.net " BlogPost: http://www.wklken.me " ReadMe: README.md " Donation: http://www.wklken.me/pages/donation.html -" Last_modify: 2015-12-15 +" Last_modify: 2019-05-04 " Sections: " -> Initial Plugin 加载插件 " -> General Settings 基础设置 @@ -417,6 +417,11 @@ noremap L $ nnoremap ; : +" 插入模式跳转到括号尾部 +" https://stackoverflow.com/questions/11037825/how-can-i-go-to-end-of-parenthesis-brackets-quotes-without-switching-insert-mode +inoremap A + + " 命令行模式增强,ctrl - a到行首, -e 到行尾 cnoremap cnoremap @@ -657,8 +662,15 @@ endif set background=dark set t_Co=256 -colorscheme solarized -" colorscheme molokai +" colorscheme solarized +colorscheme molokai + +highlight Normal ctermbg=none +" italic for vim: https://alexpearce.me/2014/05/italics-in-iterm2-vim-tmux/ +" italic for tmux: https://github.com/tmux/tmux/issues/377 +" term or iterm2, use the settings under others/italic +highlight Comment cterm=italic +highlight search ctermfg=Yellow ctermbg=NONE cterm=bold,underline " 设置标记一列的背景颜色和数字一行颜色一致 diff --git a/vimrc.bundles b/vimrc.bundles index 18ed2dcf0..9e886390a 100644 --- a/vimrc.bundles +++ b/vimrc.bundles @@ -5,19 +5,26 @@ "------------------------------------------- begin of configs -------------------------------------------- " ################### 包依赖 ##################### -" package dependence: ctags, ag(he_silver_searcher) -" python dependence: pep8, pyflake +" package dependence: ctags, ag(the_silver_searcher) +" brew install fzf shellcheck +" python dependence: pip install flake8 isort yapf " 非兼容vi模式。去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限 set nocompatible filetype off " required! turn off +" https://github.com/vim/vim/issues/3117 +if has('python3') + silent! python3 1 +endif + " ################### 插件管理 ################### " inspired by spf13, 自定义需要的插件集合 if !exists('g:bundle_groups') + let g:bundle_groups=['python', 'javascript', 'golang', 'shell', 'markdown', 'html', 'css', 'less', 'coffeescript', 'tmux', 'json', 'beta'] " let g:bundle_groups=['python', 'javascript', 'golang', 'php', 'ruby', 'shell', 'markdown', 'html', 'css', 'less', 'coffeescript', 'tmux', 'json', 'beta'] - let g:bundle_groups=['python', 'javascript', 'markdown', 'html', 'css', 'tmux', 'beta'] + " let g:bundle_groups=['python', 'javascript', 'markdown', 'html', 'css', 'tmux', 'beta'] endif " ---------------------------------------------------------------------------- @@ -98,13 +105,8 @@ Plug 'terryma/vim-multiple-cursors' " change to https://github.com/ctrlpvim/ctrlp.vim " ctrlp ctrlpfunky Plug 'ctrlpvim/ctrlp.vim' | Plug 'tacahiroy/ctrlp-funky' -" ctrlsf -" 类似sublimetext的搜索 -" In CtrlSF window: -" 回车/o, 打开 -" t 在tab中打开(建议) -" T - Lkie t but focus CtrlSF window instead of opened new tab. -" q - Quit CtrlSF window. + +" ctrlsf 类似sublimetext的搜索, install ag first Plug 'dyng/ctrlsf.vim' " incsearch " Plug 'haya14busa/incsearch.vim' @@ -155,11 +157,14 @@ Plug 'majutsushi/tagbar' Plug 'kana/vim-textobj-user' " 增加行文本对象: l dal yal cil Plug 'kana/vim-textobj-line' -" 增加文件文本对象: e dae yae cie -Plug 'kana/vim-textobj-entire' " 增加缩进文本对象: i dai yai cii - 相同缩进属于同一块 Plug 'kana/vim-textobj-indent' +" 增加文件文本对象: e dae yae cie +Plug 'kana/vim-textobj-entire' + +Plug 'wellle/targets.vim' + if count(g:bundle_groups, 'tmux') " tmux " For tmux navigator Ctrl-hjkl @@ -179,20 +184,32 @@ endif if count(g:bundle_groups, 'golang') " 1. vim a.go " 2. :GoInstallBinaries - " vimgo https://github.com/fatih/vim-go - Plug 'fatih/vim-go', {'for': 'go'} + " 3. :GoUpdateBinaries + " vimgo https://github.com/fatih/vim-go-tutorial#quick-setup + Plug 'fatih/vim-go' ", {'for': 'go', 'do': ':GoInstallBinaries'} + let g:go_fmt_command = "goimports" + let g:go_highlight_types = 1 + let g:go_highlight_structs = 1 + let g:go_highlight_fields = 1 + let g:go_highlight_operators = 1 + let g:go_highlight_functions = 1 + let g:go_highlight_methods = 1 + let g:go_highlight_extra_types = 1 + let g:go_highlight_build_constraints = 1 + " https://github.com/golang/go/wiki/gopls + let g:go_def_mode='gopls' endif if count(g:bundle_groups, 'python') " for python.vim syntax highlight " pythonsyntax - Plug 'hdima/python-syntax' + " Plug 'hdima/python-syntax' + Plug 'wklken/python-syntax' Plug 'hynek/vim-python-pep8-indent' Plug 'Glench/Vim-Jinja2-Syntax' " isort https://github.com/timothycrosley/isort#readme + https://github.com/fisadev/vim-isort#installation - " pip install isort Plug 'fisadev/vim-isort' " Shift-V 上下选中, ctrl + i 规范化 let g:vim_isort_map = '' @@ -218,7 +235,6 @@ if count(g:bundle_groups, 'javascript') " javascript " 注意: syntax这个插件要放前面 Plug 'othree/yajs.vim' | Plug 'pangloss/vim-javascript' - " Plug 'jelera/vim-javascript-syntax' | Plug 'pangloss/vim-javascript' " TODO: jquery? for, remove or keep Plug 'othree/javascript-libraries-syntax.vim' @@ -256,7 +272,7 @@ endif if count(g:bundle_groups, 'less') " ###### vim.less : less 自动更新########## - Plug 'groenewege/vim-less' + " Plug 'groenewege/vim-less' " autocmd BufWritePost *.less :!lessc % > %:p:r.css endif @@ -268,21 +284,22 @@ endif " this is just for beta version if count(g:bundle_groups, 'beta') " indent - Plug 'nathanaelkane/vim-indent-guides' + " Plug 'nathanaelkane/vim-indent-guides' " ig to trigger - let g:indent_guides_start_level = 2 - let g:indent_guides_guide_size = 1 - let g:indent_guides_auto_colors = 1 - " autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=black - " autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=black + " let g:indent_guides_start_level = 2 + " let g:indent_guides_guide_size = 1 + " let g:indent_guides_auto_colors = 1 - " Plug 'robbles/logstash.vim' - " Plug 'ryanoasis/vim-devicons' - " Plug 'ekalinin/dockerfile.vim' + Plug 'robbles/logstash.vim' + Plug 'ryanoasis/vim-devicons' + Plug 'ekalinin/dockerfile.vim' - " Plug 'ConradIrwin/vim-bracketed-paste' - " Plug 'roxma/vim-paste-easy' + " brew install fzf + Plug '/usr/local/opt/fzf' + Plug 'junegunn/fzf.vim' + " NOTE: ctrl-p for fzf Files + map :Files endif @@ -306,7 +323,6 @@ if has_key(g:plugs, 'syntastic') " checkers " python - " pip install flake8 let g:syntastic_python_checkers=['flake8', ] " 使用pyflakes,速度比pylint快 let g:syntastic_python_flake8_args='--ignore=E501,E225,E124,E712,E116,E131' @@ -371,17 +387,15 @@ endif " ale {{{ if has_key(g:plugs, 'ale') - " pip install flake8 - " npm install -g eslint eslint-plugin-standard eslint-plugin-promise eslint-config-standard - " npm install -g eslint-plugin-import eslint-plugin-node eslint-plugin-html babel-eslint + " install the lint yourself let g:ale_linters = { \ 'python': ['flake8'], \ 'javascript': ['eslint'], + \ 'html': [], + \ 'go': ['golangci-lint'], \} - " E501 -> 120 chars - let g:ale_python_flake8_args="--ignore=E114,E116,E131 --max-line-length=120" - " --ignore=E225,E124,E712,E116 + let g:ale_python_flake8_options="--ignore=E121,E123,E126,E226,E24,E704,W503 --max-line-length=120" let g:ale_sign_error = '>>' let g:ale_sign_warning = '>' @@ -427,12 +441,14 @@ endif let g:ycm_use_ultisnips_completer = 1 "提示UltiSnips let g:ycm_collect_identifiers_from_comments_and_strings = 1 "注释和字符串中的文字也会被收入补全 let g:ycm_collect_identifiers_from_tags_files = 1 - " 开启语法关键字补全 + " 开启语法关键字补全, 不过python关键字都很短,所以,需要的自己打开 let g:ycm_seed_identifiers_with_syntax=1 " 回车作为选中 let g:ycm_key_list_stop_completion = [''] - "let g:ycm_seed_identifiers_with_syntax=1 "语言关键字补全, 不过python关键字都很短,所以,需要的自己打开 + " let g:ycm_python_binary_path = '/usr/local/bin/python3' + let g:ycm_python_binary_path = 'python' + " 跳转到定义处, 分屏打开 let g:ycm_goto_buffer_command = 'horizontal-split' @@ -451,6 +467,7 @@ endif let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py" endif + let g:ycm_extra_conf_globlist = ['!~/*'] " 直接触发自动补全 insert模式下 " let g:ycm_key_invoke_completion = '' " 黑名单,不启用 @@ -511,6 +528,7 @@ endif " nerdcommenter {{{ let g:NERDSpaceDelims=1 let g:NERDAltDelims_python = 1 + let g:NERDDefaultAlign="left" " }}} " trailingwhitespace {{{ @@ -605,6 +623,9 @@ endif " let g:ctrlp_use_caching = 0 " endif + " search in Files, Buffers and MRU files at the same time + nnoremap fm :CtrlPMixed + " ctrlpfunky " ctrlp插件1 - 不用ctag进行函数快速跳转 nnoremap fu :CtrlPFunky @@ -618,6 +639,11 @@ endif " ctrlsf {{{ nmap \ CtrlSFCwordPath + nnoremap :CtrlSF + " " use async in using Vim 8.0+ + if v:version >= 800 + let g:ctrlsf_search_mode = 'async' + endif " let g:ctrlsf_position = 'below' " let g:ctrlsf_winsize = '30%' let g:ctrlsf_auto_close = 0 @@ -625,16 +651,17 @@ endif " Note: cannot use or for open " Use : or let g:ctrlsf_mapping = { - \ "open" : "", - \ "openb" : "O", - \ "tab" : "t", - \ "tabb" : "T", - \ "prevw" : "p", + \ "split" : "", + \ "prevw" : "", \ "quit" : "q", - \ "next" : "", - \ "prev" : "", - \ "pquit" : "q", + \ "next" : "n", + \ "prev" : "p", + \ "popen" : "", + \ "open" : "", \ } + + " ignore those dirs + let g:ctrlsf_ignore_dir = ['static/doc', 'assets'] " }}} " git. git操作还是习惯命令行,vim里面处理简单diff编辑操作 @@ -667,12 +694,11 @@ endif " ################### 显示增强 ################### " airline {{{ + let g:airline_theme="tomorrow" if !exists('g:airline_symbols') let g:airline_symbols = {} endif - let g:airline_left_sep = '▶' let g:airline_left_alt_sep = '❯' - let g:airline_right_sep = '◀' let g:airline_right_alt_sep = '❮' let g:airline_symbols.linenr = '¶' let g:airline_symbols.branch = '⎇' @@ -723,8 +749,9 @@ endif " molokai {{{ " monokai原始背景色 - let g:molokai_original = 1 - let g:rehash256 = 1 + " let g:molokai_original = 1 + let g:rehash256=1 + let g:python_highlight_pycharm_monokai=1 " }}} " ################### 快速导航 ################### @@ -848,7 +875,7 @@ endif let g:go_fmt_fail_silently = 1 " format with goimports instead of gofmt let g:go_fmt_command = "goimports" - let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck'] + let g:syntastic_go_checkers = ['golangci_lint'] let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go', 'java'] } " }}} @@ -875,15 +902,20 @@ endif " ####### temp ####### " beta {{{ - " pip install yapf - " python code format - " format all file - autocmd FileType python nnoremap y :0,$!yapf - " format select block - autocmd FileType python vnoremap y :!yapf + " yapf, python code format: + " - format all file + " autocmd FileType python nnoremap y :0,$!yapf + " - format select block + " autocmd FileType python vnoremap y :!yapf + + " vue " Plug 'posva/vim-vue' + + + " Plug 'xolox/vim-easytags' + " Plug 'millermedeiros/vim-esformatter' " will run esformatter after pressing followed by the 'e' and 's' " keys From 8957cc50f232ba7e8f44087a3db511cb3cf1c2b6 Mon Sep 17 00:00:00 2001 From: wklken Date: Sat, 4 May 2019 17:54:39 +0800 Subject: [PATCH 2/8] add tenfyzhong/CompleteParameter.vim --- vimrc | 6 +++--- vimrc.bundles | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/vimrc b/vimrc index fcd54ccdc..f676f194a 100644 --- a/vimrc +++ b/vimrc @@ -1,7 +1,7 @@ "========================================== " Author: wklken -" Version: 9.2 -" Email: wklken@yeah.net +" Version: 9.3 +" Email: wklken@gmail.com " BlogPost: http://www.wklken.me " ReadMe: README.md " Donation: http://www.wklken.me/pages/donation.html @@ -669,7 +669,7 @@ highlight Normal ctermbg=none " italic for vim: https://alexpearce.me/2014/05/italics-in-iterm2-vim-tmux/ " italic for tmux: https://github.com/tmux/tmux/issues/377 " term or iterm2, use the settings under others/italic -highlight Comment cterm=italic +" highlight Comment cterm=italic highlight search ctermfg=Yellow ctermbg=NONE cterm=bold,underline diff --git a/vimrc.bundles b/vimrc.bundles index 9e886390a..14fcafcaf 100644 --- a/vimrc.bundles +++ b/vimrc.bundles @@ -297,10 +297,17 @@ if count(g:bundle_groups, 'beta') " brew install fzf Plug '/usr/local/opt/fzf' Plug 'junegunn/fzf.vim' - " NOTE: ctrl-p for fzf Files map :Files + Plug 'tenfyzhong/CompleteParameter.vim' + " let g:complete_parameter_use_ultisnips_mapping = 1 + inoremap ( complete_parameter#pre_complete("()") + smap (complete_parameter#goto_next_parameter) + imap (complete_parameter#goto_next_parameter) + smap (complete_parameter#goto_previous_parameter) + imap (complete_parameter#goto_previous_parameter) + endif @@ -914,6 +921,7 @@ endif + " Plug 'xolox/vim-easytags' " Plug 'millermedeiros/vim-esformatter' From f0835f4f9cd2bac50f7d4d807294090a33cbd9be Mon Sep 17 00:00:00 2001 From: wklken Date: Fri, 22 Jan 2021 10:50:15 +0800 Subject: [PATCH 3/8] update vim-go --- UltiSnips/python.snippets | 7 +++++ vimrc | 2 +- vimrc.bundles | 64 +++++++++++++++++++++++++++------------ 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets index c23c8a87f..e1e524b06 100644 --- a/UltiSnips/python.snippets +++ b/UltiSnips/python.snippets @@ -174,3 +174,10 @@ snippet dk "api doc" code: endsnippet + +snippet djadmin "django admin" +class XXAdmin(admin.ModelAdmin): + pass +admin.site.register(XX, XXAdmin) +${1} +endsnippet diff --git a/vimrc b/vimrc index f676f194a..d43fb434d 100644 --- a/vimrc +++ b/vimrc @@ -669,7 +669,7 @@ highlight Normal ctermbg=none " italic for vim: https://alexpearce.me/2014/05/italics-in-iterm2-vim-tmux/ " italic for tmux: https://github.com/tmux/tmux/issues/377 " term or iterm2, use the settings under others/italic -" highlight Comment cterm=italic +highlight Comment cterm=italic highlight search ctermfg=Yellow ctermbg=NONE cterm=bold,underline diff --git a/vimrc.bundles b/vimrc.bundles index 14fcafcaf..6ffea676f 100644 --- a/vimrc.bundles +++ b/vimrc.bundles @@ -187,17 +187,6 @@ if count(g:bundle_groups, 'golang') " 3. :GoUpdateBinaries " vimgo https://github.com/fatih/vim-go-tutorial#quick-setup Plug 'fatih/vim-go' ", {'for': 'go', 'do': ':GoInstallBinaries'} - let g:go_fmt_command = "goimports" - let g:go_highlight_types = 1 - let g:go_highlight_structs = 1 - let g:go_highlight_fields = 1 - let g:go_highlight_operators = 1 - let g:go_highlight_functions = 1 - let g:go_highlight_methods = 1 - let g:go_highlight_extra_types = 1 - let g:go_highlight_build_constraints = 1 - " https://github.com/golang/go/wiki/gopls - let g:go_def_mode='gopls' endif @@ -308,6 +297,17 @@ if count(g:bundle_groups, 'beta') smap (complete_parameter#goto_previous_parameter) imap (complete_parameter#goto_previous_parameter) + Plug 'wakatime/vim-wakatime' + + Plug 'AndrewRadev/splitjoin.vim' + + " pip install black + " https://black.readthedocs.io/en/stable/editor_integration.html + Plug 'psf/black', { 'tag': '19.10b0' } + let g:black_linelength=120 + nnoremap b :Black + " format at save + autocmd BufWritePre *.py execute ':Black' endif @@ -399,7 +399,7 @@ if has_key(g:plugs, 'ale') \ 'python': ['flake8'], \ 'javascript': ['eslint'], \ 'html': [], - \ 'go': ['golangci-lint'], + \ 'go': ['gopls', 'golangci-lint'], \} " E501 -> 120 chars let g:ale_python_flake8_options="--ignore=E121,E123,E126,E226,E24,E704,W503 --max-line-length=120" @@ -772,6 +772,8 @@ endif " s/v 分屏打开文件 let g:NERDTreeMapOpenSplit = 's' let g:NERDTreeMapOpenVSplit = 'v' + " show bookmarks in nerdtree + " let NERDTreeShowBookmarks = 1 " nerdtreetabs @@ -873,15 +875,41 @@ endif " vimgo {{{ + " format with goimports instead of gofmt + let g:go_fmt_command = "goimports" + let g:go_fmt_fail_silently = 1 + let g:go_highlight_types = 1 + let g:go_highlight_fields = 1 let g:go_highlight_functions = 1 - let g:go_highlight_methods = 1 + let g:go_highlight_function_calls = 1 + let g:go_highlight_extra_types = 1 + let g:go_highlight_structs = 1 let g:go_highlight_operators = 1 + let g:go_highlight_methods = 1 let g:go_highlight_build_constraints = 1 + let g:go_highlight_generate_tags = 1 + " https://github.com/golang/go/wiki/gopls + let g:go_def_mode='gopls' + let g:go_info_mode='gopls' - let g:go_fmt_fail_silently = 1 - " format with goimports instead of gofmt - let g:go_fmt_command = "goimports" + + autocmd FileType go nmap t (go-test) + " run :GoBuild or :GoTestCompile based on the go file + function! s:build_go_files() + let l:file = expand('%') + if l:file =~# '^\f\+_test\.go$' + call go#test#Test(0, 1) + elseif l:file =~# '^\f\+\.go$' + call go#cmd#Build(0) + endif + endfunction + autocmd FileType go nmap b :call build_go_files() + autocmd FileType go nmap c (go-coverage-toggle) + + " autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 + + " lint let g:syntastic_go_checkers = ['golangci_lint'] let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go', 'java'] } " }}} @@ -910,7 +938,7 @@ endif " beta {{{ - " yapf, python code format: + " yapf, python code format: " - format all file " autocmd FileType python nnoremap y :0,$!yapf " - format select block @@ -920,8 +948,6 @@ endif " Plug 'posva/vim-vue' - - " Plug 'xolox/vim-easytags' " Plug 'millermedeiros/vim-esformatter' From 1b19a19137c54d8c9e731582d68151fb34ceb006 Mon Sep 17 00:00:00 2001 From: wklken Date: Fri, 2 Apr 2021 19:20:34 +0800 Subject: [PATCH 4/8] update --- vimrc.bundles | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/vimrc.bundles b/vimrc.bundles index 6ffea676f..b8ea6c008 100644 --- a/vimrc.bundles +++ b/vimrc.bundles @@ -299,7 +299,7 @@ if count(g:bundle_groups, 'beta') Plug 'wakatime/vim-wakatime' - Plug 'AndrewRadev/splitjoin.vim' + " Plug 'AndrewRadev/splitjoin.vim' " pip install black " https://black.readthedocs.io/en/stable/editor_integration.html @@ -308,6 +308,25 @@ if count(g:bundle_groups, 'beta') nnoremap b :Black " format at save autocmd BufWritePre *.py execute ':Black' + + if has('nvim') || has('patch-8.0.902') + Plug 'mhinz/vim-signify' + else + Plug 'mhinz/vim-signify', { 'branch': 'legacy' } + endif + + " On-demand lazy load + Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] } + nnoremap :WhichKey '' + " By default timeoutlen is 1000 ms + set timeoutlen=500 + + + " rust + Plug 'rust-lang/rust.vim' + + " Plug 'yuttie/comfortable-motion.vim' + Plug 'andrewradev/splitjoin.vim' endif From dbb1794c663d369afb6493c210a5d19f0cb7787b Mon Sep 17 00:00:00 2001 From: wklken Date: Fri, 30 Apr 2021 15:27:46 +0800 Subject: [PATCH 5/8] merge signcolumn and number column into one; use fzf instead of ctrlp --- vimrc | 15 ++++++++++++- vimrc.bundles | 62 ++++++++++++++++----------------------------------- 2 files changed, 33 insertions(+), 44 deletions(-) diff --git a/vimrc b/vimrc index d43fb434d..a320de52c 100644 --- a/vimrc +++ b/vimrc @@ -243,6 +243,15 @@ function! NumberToggle() endfunc nnoremap :call NumberToggle() +" Always show the signcolumn, otherwise it would shift the text each time +" diagnostics appear/become resolved. +if has("patch-8.1.1564") + " Recently vim can merge signcolumn and number column into one + set signcolumn=number +else + set signcolumn=yes +endif + " 防止tmux下vim的背景色显示异常 " Refer: http://sunaku.github.io/vim-256color-bce.html if &term =~ '256color' @@ -669,7 +678,7 @@ highlight Normal ctermbg=none " italic for vim: https://alexpearce.me/2014/05/italics-in-iterm2-vim-tmux/ " italic for tmux: https://github.com/tmux/tmux/issues/377 " term or iterm2, use the settings under others/italic -highlight Comment cterm=italic +highlight Comment cterm=italic gui=italic highlight search ctermfg=Yellow ctermbg=NONE cterm=bold,underline @@ -687,3 +696,7 @@ highlight clear SpellRare highlight SpellRare term=underline cterm=underline highlight clear SpellLocal highlight SpellLocal term=underline cterm=underline + +" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable +" delays and poor user experience. +set updatetime=300 diff --git a/vimrc.bundles b/vimrc.bundles index b8ea6c008..737ece85b 100644 --- a/vimrc.bundles +++ b/vimrc.bundles @@ -101,10 +101,13 @@ Plug 'terryma/vim-expand-region' Plug 'terryma/vim-multiple-cursors' " quick locate file or function -" 文件搜索 -" change to https://github.com/ctrlpvim/ctrlp.vim -" ctrlp ctrlpfunky -Plug 'ctrlpvim/ctrlp.vim' | Plug 'tacahiroy/ctrlp-funky' +" 文件搜索 +" change to https://github.com/junegunn/fzf.vim +" brew install fzf +Plug '/usr/local/opt/fzf' +Plug 'junegunn/fzf.vim' +Plug 'tracyone/fzf-funky',{'on': 'FzfFunky'} + " ctrlsf 类似sublimetext的搜索, install ag first Plug 'dyng/ctrlsf.vim' @@ -283,11 +286,8 @@ if count(g:bundle_groups, 'beta') Plug 'ryanoasis/vim-devicons' Plug 'ekalinin/dockerfile.vim' - " brew install fzf - Plug '/usr/local/opt/fzf' - Plug 'junegunn/fzf.vim' - " NOTE: ctrl-p for fzf Files - map :Files + + Plug 'tenfyzhong/CompleteParameter.vim' " let g:complete_parameter_use_ultisnips_mapping = 1 @@ -473,7 +473,7 @@ endif let g:ycm_key_list_stop_completion = [''] " let g:ycm_python_binary_path = '/usr/local/bin/python3' - let g:ycm_python_binary_path = 'python' + let g:ycm_python_binary_path = 'python3' " 跳转到定义处, 分屏打开 @@ -627,42 +627,15 @@ endif " ################### 功能相关 ################### -" ctrlp ctrlpfunky{{{ - let g:ctrlp_map = 'p' - let g:ctrlp_cmd = 'CtrlP' - map f :CtrlPMRU - let g:ctrlp_custom_ignore = { - \ 'dir': '\v[\/]\.(git|hg|svn|rvm)$', - \ 'file': '\v\.(exe|so|dll|zip|tar|tar.gz|pyc)$', - \ } - let g:ctrlp_working_path_mode=0 - let g:ctrlp_match_window_bottom=1 - let g:ctrlp_max_height=15 - let g:ctrlp_match_window_reversed=0 - let g:ctrlp_mruf_max=500 - let g:ctrlp_follow_symlinks=1 - " 如果安装了ag, 使用ag - " if executable('ag') - " " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore - " let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' - " " ag is fast enough that CtrlP doesn't need to cache - " let g:ctrlp_use_caching = 0 - " endif - - " search in Files, Buffers and MRU files at the same time - nnoremap fm :CtrlPMixed - - " ctrlpfunky - " ctrlp插件1 - 不用ctag进行函数快速跳转 - nnoremap fu :CtrlPFunky - " narrow the list down with a word under cursor - nnoremap fU :execute 'CtrlPFunky ' . expand('') - let g:ctrlp_funky_syntax_highlight = 1 +" fzf fzf-funky {{{ + nnoremap p :Files + nnoremap f :History - let g:ctrlp_extensions = ['funky'] + nnoremap fu :FzfFunky + " narrow the list down with a word under cursor + nnoremap fU :execute 'FzfFunky ' . expand('') " }}} - " ctrlsf {{{ nmap \ CtrlSFCwordPath nnoremap :CtrlSF @@ -912,6 +885,9 @@ endif let g:go_def_mode='gopls' let g:go_info_mode='gopls' + " automatically highlight variable your cursor is on + let g:go_auto_sameids = 0 + autocmd FileType go nmap t (go-test) " run :GoBuild or :GoTestCompile based on the go file From 8236e06c2356c47570b729358412beee9a66e751 Mon Sep 17 00:00:00 2001 From: wklken Date: Fri, 30 Apr 2021 15:36:38 +0800 Subject: [PATCH 6/8] mhinz/vim-signify as default plugin --- vimrc.bundles | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/vimrc.bundles b/vimrc.bundles index 737ece85b..2af4ba550 100644 --- a/vimrc.bundles +++ b/vimrc.bundles @@ -126,6 +126,12 @@ Plug 'thinca/vim-quickrun' Plug 'tpope/vim-fugitive' " gitgutter Plug 'airblade/vim-gitgutter' +" vim-signify +if has('nvim') || has('patch-8.0.902') + Plug 'mhinz/vim-signify' +else + Plug 'mhinz/vim-signify', { 'branch': 'legacy' } +endif " gundo " edit history, 可以查看回到某个历史状态 @@ -309,11 +315,6 @@ if count(g:bundle_groups, 'beta') " format at save autocmd BufWritePre *.py execute ':Black' - if has('nvim') || has('patch-8.0.902') - Plug 'mhinz/vim-signify' - else - Plug 'mhinz/vim-signify', { 'branch': 'legacy' } - endif " On-demand lazy load Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] } From 5c443eadff6786fad7c0bfefbb5144d1cff33a60 Mon Sep 17 00:00:00 2001 From: wklken Date: Fri, 30 Apr 2021 17:07:27 +0800 Subject: [PATCH 7/8] update --- vimrc.bundles | 84 +++++++++++++++++++++------------------------------ 1 file changed, 35 insertions(+), 49 deletions(-) diff --git a/vimrc.bundles b/vimrc.bundles index 2af4ba550..c690afde7 100644 --- a/vimrc.bundles +++ b/vimrc.bundles @@ -7,7 +7,7 @@ " ################### 包依赖 ##################### " package dependence: ctags, ag(the_silver_searcher) " brew install fzf shellcheck -" python dependence: pip install flake8 isort yapf +" python dependence: pip install flake8 isort black " 非兼容vi模式。去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限 set nocompatible @@ -40,7 +40,7 @@ call plug#begin('~/.vim/bundle') if v:version < 800 Plug 'scrooloose/syntastic' else - Plug 'w0rp/ale' + Plug 'dense-analysis/ale' endif " Group dependencies, vim-snippets depends on ultisnips @@ -76,7 +76,8 @@ Plug 'junegunn/vim-easy-align' " quick movement " easymotion "更高效的移动 [,, + w/fx/h/j/k/l] -Plug 'Lokaltog/vim-easymotion' +" Plug 'Lokaltog/vim-easymotion' +Plug 'easymotion/vim-easymotion' " 更高效的行内移动, f/F/t/T, 才触发 " quickscope @@ -124,8 +125,6 @@ Plug 'thinca/vim-quickrun' " git " fugitive Plug 'tpope/vim-fugitive' -" gitgutter -Plug 'airblade/vim-gitgutter' " vim-signify if has('nvim') || has('patch-8.0.902') Plug 'mhinz/vim-signify' @@ -211,6 +210,14 @@ if count(g:bundle_groups, 'python') Plug 'fisadev/vim-isort' " Shift-V 上下选中, ctrl + i 规范化 let g:vim_isort_map = '' + + " pip install black + " https://black.readthedocs.io/en/stable/editor_integration.html + Plug 'psf/black', { 'tag': '19.10b0' } + let g:black_linelength=120 + nnoremap b :Black + " format at save + autocmd BufWritePre *.py execute ':Black' endif if count(g:bundle_groups, 'php') @@ -288,11 +295,10 @@ if count(g:bundle_groups, 'beta') " let g:indent_guides_guide_size = 1 " let g:indent_guides_auto_colors = 1 - Plug 'robbles/logstash.vim' Plug 'ryanoasis/vim-devicons' - Plug 'ekalinin/dockerfile.vim' - + Plug 'robbles/logstash.vim' + Plug 'ekalinin/dockerfile.vim' Plug 'tenfyzhong/CompleteParameter.vim' @@ -305,22 +311,13 @@ if count(g:bundle_groups, 'beta') Plug 'wakatime/vim-wakatime' - " Plug 'AndrewRadev/splitjoin.vim' - - " pip install black - " https://black.readthedocs.io/en/stable/editor_integration.html - Plug 'psf/black', { 'tag': '19.10b0' } - let g:black_linelength=120 - nnoremap b :Black - " format at save - autocmd BufWritePre *.py execute ':Black' " On-demand lazy load - Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] } - nnoremap :WhichKey '' - " By default timeoutlen is 1000 ms - set timeoutlen=500 + " Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] } + " nnoremap :WhichKey '' + " " By default timeoutlen is 1000 ms + " set timeoutlen=500 " rust @@ -328,6 +325,19 @@ if count(g:bundle_groups, 'beta') " Plug 'yuttie/comfortable-motion.vim' Plug 'andrewradev/splitjoin.vim' + " Plug 'AndrewRadev/splitjoin.vim' + + " vue + " Plug 'posva/vim-vue' + + + " Plug 'xolox/vim-easytags' + + " Plug 'millermedeiros/vim-esformatter' + " will run esformatter after pressing followed by the 'e' and 's' + " keys + " nnoremap es :Esformatter + " vnoremap es :EsformatterVisual endif @@ -416,8 +426,9 @@ endif if has_key(g:plugs, 'ale') " install the lint yourself let g:ale_linters = { + \ '*': ['remove_trailing_lines', 'trim_whitespace'], \ 'python': ['flake8'], - \ 'javascript': ['eslint'], + \ 'javascript': ['prettier', 'eslint'], \ 'html': [], \ 'go': ['gopls', 'golangci-lint'], \} @@ -585,6 +596,7 @@ endif map l (easymotion-lineforward) " 重复上一次操作, 类似repeat插件, 很强大 map . (easymotion-repeat) + let g:EasyMotion_startofline = 0 " keep cursor column when JK motion " }}} @@ -661,7 +673,7 @@ endif \ } " ignore those dirs - let g:ctrlsf_ignore_dir = ['static/doc', 'assets'] + let g:ctrlsf_ignore_dir = ['static/doc', 'assets', 'vendor'] " }}} " git. git操作还是习惯命令行,vim里面处理简单diff编辑操作 @@ -678,15 +690,6 @@ endif " gp maps to :Git push " }}} -" gitgutter {{{ - " 同git diff,实时展示文件中修改的行 - " 只是不喜欢除了行号多一列, 默认关闭,gs时打开 - let g:gitgutter_map_keys = 0 - let g:gitgutter_enabled = 0 - let g:gitgutter_highlight_lines = 1 - nnoremap gs :GitGutterToggle -" }}} - " gundo {{{ noremap h :GundoToggle " }}} @@ -934,23 +937,6 @@ endif " beta {{{ - " yapf, python code format: - " - format all file - " autocmd FileType python nnoremap y :0,$!yapf - " - format select block - " autocmd FileType python vnoremap y :!yapf - - " vue - " Plug 'posva/vim-vue' - - - " Plug 'xolox/vim-easytags' - - " Plug 'millermedeiros/vim-esformatter' - " will run esformatter after pressing followed by the 'e' and 's' - " keys - " nnoremap es :Esformatter - " vnoremap es :EsformatterVisual " }}} From 13a47c3a7a55d0b7f2948da58f0c9f3c6aefc99b Mon Sep 17 00:00:00 2001 From: wklken Date: Wed, 12 May 2021 14:33:30 +0800 Subject: [PATCH 8/8] remove scrooloose/syntastic; add coc.nvim; add shift+j/k to move code blocks --- coc-settings.json | 88 ++++++++++++++ vimrc | 4 + vimrc.bundles | 290 ++++++++++++++++------------------------------ 3 files changed, 190 insertions(+), 192 deletions(-) create mode 100644 coc-settings.json diff --git a/coc-settings.json b/coc-settings.json new file mode 100644 index 000000000..2090b49fa --- /dev/null +++ b/coc-settings.json @@ -0,0 +1,88 @@ +{ + "diagnostic.displayByAle": true, + "languageserver": { + "bash": { + "command": "bash-language-server", + "args": ["start"], + "filetypes": ["sh"], + "ignoredRootPaths": ["~"] + }, + "python": { + "command": "python3", + "args": [ + "-mpyls", + "-vv", + "--log-file", + "/tmp/lsp_python.log" + ], + "trace.server": "verbose", + "filetypes": [ + "python" + ], + "settings": { + "pyls": { + "enable": true, + "trace": { + "server": "verbose" + }, + "commandPath": "", + "configurationSources": [ + "pycodestyle" + ], + "plugins": { + "jedi_completion": { + "enabled": true + }, + "jedi_hover": { + "enabled": true + }, + "jedi_references": { + "enabled": true + }, + "jedi_signature_help": { + "enabled": true + }, + "jedi_symbols": { + "enabled": true, + "all_scopes": true + }, + "mccabe": { + "enabled": true, + "threshold": 15 + }, + "preload": { + "enabled": true + }, + "pycodestyle": { + "enabled": true + }, + "pydocstyle": { + "enabled": false, + "match": "(?!test_).*\\.py", + "matchDir": "[^\\.].*" + }, + "pyflakes": { + "enabled": true + }, + "rope_completion": { + "enabled": false + }, + "yapf": { + "enabled": true + }, + "pyls_mypy": + { + "enabled": true, + "live_mode": false + } + } + } + } + }, + "dockerfile": { + "command": "docker-langserver", + "filetypes": ["dockerfile"], + "args": ["--stdio"] + } + } +} diff --git a/vimrc b/vimrc index a320de52c..ce680d607 100644 --- a/vimrc +++ b/vimrc @@ -533,6 +533,10 @@ vnoremap y "+y " vnoremap p p`] " nnoremap p p`] +" shift-j/k 上下移动选中代码块 +vnoremap :m '>+1gv=gv +vnoremap :m '<-2gv=gv + " select all map sa ggVG diff --git a/vimrc.bundles b/vimrc.bundles index c690afde7..cccaf7af5 100644 --- a/vimrc.bundles +++ b/vimrc.bundles @@ -22,7 +22,7 @@ endif " inspired by spf13, 自定义需要的插件集合 if !exists('g:bundle_groups') - let g:bundle_groups=['python', 'javascript', 'golang', 'shell', 'markdown', 'html', 'css', 'less', 'coffeescript', 'tmux', 'json', 'beta'] + let g:bundle_groups=['python', 'javascript', 'golang', 'rust', 'shell', 'markdown', 'html', 'css', 'less', 'coffeescript', 'tmux', 'json', 'gtd', 'beta'] " let g:bundle_groups=['python', 'javascript', 'golang', 'php', 'ruby', 'shell', 'markdown', 'html', 'css', 'less', 'coffeescript', 'tmux', 'json', 'beta'] " let g:bundle_groups=['python', 'javascript', 'markdown', 'html', 'css', 'tmux', 'beta'] endif @@ -36,10 +36,8 @@ call plug#begin('~/.vim/bundle') " 移动光标到插件名上, 使用'#'快速跳转到每个插件的配置处 -" syntastic -if v:version < 800 - Plug 'scrooloose/syntastic' -else +" lint +if v:version >= 800 Plug 'dense-analysis/ale' endif @@ -50,9 +48,9 @@ Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' " auto complete " 代码自动补全 -" 迄今为止用到的最好的自动VIM自动补全插件 -" 重启 :YcmRestartServer -Plug 'Valloric/YouCompleteMe' +" Use release branch (recommend) +Plug 'neoclide/coc.nvim', {'branch': 'release'} + " 自动补全单引号,双引号等 Plug 'Raimondi/delimitMate' " 自动补全html/xml标签 @@ -102,7 +100,7 @@ Plug 'terryma/vim-expand-region' Plug 'terryma/vim-multiple-cursors' " quick locate file or function -" 文件搜索 +" 文件搜索 " change to https://github.com/junegunn/fzf.vim " brew install fzf Plug '/usr/local/opt/fzf' @@ -125,7 +123,7 @@ Plug 'thinca/vim-quickrun' " git " fugitive Plug 'tpope/vim-fugitive' -" vim-signify +" vim-signify if has('nvim') || has('patch-8.0.902') Plug 'mhinz/vim-signify' else @@ -197,6 +195,9 @@ if count(g:bundle_groups, 'golang') Plug 'fatih/vim-go' ", {'for': 'go', 'do': ':GoInstallBinaries'} endif +if count(g:bundle_groups, 'rust') + Plug 'rust-lang/rust.vim' +endif if count(g:bundle_groups, 'python') " for python.vim syntax highlight @@ -286,6 +287,10 @@ if count(g:bundle_groups, 'html') " Plug 'mattn/emmet-vim' endif +if count(g:bundle_groups, 'gtd') + Plug 'wakatime/vim-wakatime' +endif + " this is just for beta version if count(g:bundle_groups, 'beta') " indent @@ -295,49 +300,26 @@ if count(g:bundle_groups, 'beta') " let g:indent_guides_guide_size = 1 " let g:indent_guides_auto_colors = 1 - Plug 'ryanoasis/vim-devicons' - - Plug 'robbles/logstash.vim' - Plug 'ekalinin/dockerfile.vim' - - Plug 'tenfyzhong/CompleteParameter.vim' + " Plug 'tenfyzhong/CompleteParameter.vim' " let g:complete_parameter_use_ultisnips_mapping = 1 - inoremap ( complete_parameter#pre_complete("()") - smap (complete_parameter#goto_next_parameter) - imap (complete_parameter#goto_next_parameter) - smap (complete_parameter#goto_previous_parameter) - imap (complete_parameter#goto_previous_parameter) - - Plug 'wakatime/vim-wakatime' - - - - " On-demand lazy load - " Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] } - " nnoremap :WhichKey '' - " " By default timeoutlen is 1000 ms - " set timeoutlen=500 + " inoremap ( complete_parameter#pre_complete("()") + " smap (complete_parameter#goto_next_parameter) + " imap (complete_parameter#goto_next_parameter) + " smap (complete_parameter#goto_previous_parameter) + " imap (complete_parameter#goto_previous_parameter) + Plug 'ryanoasis/vim-devicons' - " rust - Plug 'rust-lang/rust.vim' + Plug 'robbles/logstash.vim' + Plug 'ekalinin/dockerfile.vim' " Plug 'yuttie/comfortable-motion.vim' - Plug 'andrewradev/splitjoin.vim' - " Plug 'AndrewRadev/splitjoin.vim' - + " Plug 'andrewradev/splitjoin.vim' " vue " Plug 'posva/vim-vue' - - " Plug 'xolox/vim-easytags' - " Plug 'millermedeiros/vim-esformatter' - " will run esformatter after pressing followed by the 'e' and 's' - " keys - " nnoremap es :Esformatter - " vnoremap es :EsformatterVisual endif @@ -347,81 +329,6 @@ call plug#end() " ################### 基础 ###################### -" syntastic {{{ -if has_key(g:plugs, 'syntastic') - " dependence - " 1. shellcheck `brew install shellcheck` https://github.com/koalaman/shellcheck - - let g:syntastic_error_symbol='>>' - let g:syntastic_warning_symbol='>' - let g:syntastic_check_on_open=1 - let g:syntastic_check_on_wq=0 - let g:syntastic_enable_highlighting=1 - - " checkers - " python - let g:syntastic_python_checkers=['flake8', ] " 使用pyflakes,速度比pylint快 - let g:syntastic_python_flake8_args='--ignore=E501,E225,E124,E712,E116,E131' - - " javascript - " let g:syntastic_javascript_checkers = ['jsl', 'jshint'] - " let g:syntastic_html_checkers=['tidy', 'jshint'] - " npm install -g eslint eslint-plugin-standard eslint-plugin-promise eslint-config-standard - " npm install -g eslint-plugin-import eslint-plugin-node eslint-plugin-html babel-eslint - let g:syntastic_javascript_checkers = ['eslint'] - - " to see error location list - let g:syntastic_always_populate_loc_list = 1 - let g:syntastic_enable_signs = 1 - let g:syntastic_auto_loc_list = 0 - let g:syntastic_auto_jump = 0 - let g:syntastic_loc_list_height = 5 - - function! ToggleErrors() - let old_last_winnr = winnr('$') - lclose - if old_last_winnr == winnr('$') - " Nothing was closed, open syntastic_error location panel - Errors - endif - endfunction - nnoremap s :call ToggleErrors() - - " ,en ,ep to jump between errors - function! LocationPrevious() - try - lprev - catch /^Vim\%((\a\+)\)\=:E553/ - llast - endtry - endfunction - - function! LocationNext() - try - lnext - catch /^Vim\%((\a\+)\)\=:E553/ - lfirst - endtry - endfunction - - nnoremap LocationPrevious :exe 'call LocationPrevious()' - nnoremap LocationNext :exe 'call LocationNext()' - nmap ep LocationPrevious - nmap en LocationNext - - " 修改高亮的背景色, 适应主题 - highlight SyntasticErrorSign guifg=white guibg=black - - " 禁止插件检查java - " thanks to @marsqing, see https://github.com/wklken/k-vim/issues/164 - let g:syntastic_mode_map = {'mode': 'active', 'passive_filetypes': ['java'] } - - " 关闭syntastic语法检查, 鼠标复制代码时用到, 防止把错误标志给复制了 - nnoremap ec :SyntasticToggleMode -endif -" }}} - - " ale {{{ if has_key(g:plugs, 'ale') " install the lint yourself @@ -446,6 +353,7 @@ if has_key(g:plugs, 'ale') nmap ep (ale_previous_wrap) nmap en (ale_next_wrap) + " 关闭语法检查, 鼠标复制代码时用到, 防止把错误标志给复制了 nnoremap ec :ALEToggle " troggle quickfix list @@ -453,7 +361,7 @@ if has_key(g:plugs, 'ale') let old_last_winnr = winnr('$') lclose if old_last_winnr == winnr('$') - " Nothing was closed, open syntastic_error location panel + " Nothing was closed, open location panel lopen endif endfunction @@ -462,89 +370,92 @@ if has_key(g:plugs, 'ale') let g:ale_set_highlights = 1 highlight clear ALEErrorSign highlight clear ALEWarningSign + + " support coc.nvim + let g:ale_disable_lsp = 1 endif " }}} " ################### 自动补全 ################### -" YouCompleteMe {{{ - "youcompleteme 默认tab s-tab 和自动补全冲突 - "let g:ycm_key_list_select_completion=[''] - let g:ycm_key_list_select_completion = [''] - "let g:ycm_key_list_previous_completion=[''] - let g:ycm_key_list_previous_completion = [''] - let g:ycm_complete_in_comments = 1 "在注释输入中也能补全 - let g:ycm_complete_in_strings = 1 "在字符串输入中也能补全 - let g:ycm_use_ultisnips_completer = 1 "提示UltiSnips - let g:ycm_collect_identifiers_from_comments_and_strings = 1 "注释和字符串中的文字也会被收入补全 - let g:ycm_collect_identifiers_from_tags_files = 1 - " 开启语法关键字补全, 不过python关键字都很短,所以,需要的自己打开 - let g:ycm_seed_identifiers_with_syntax=1 - " 回车作为选中 - let g:ycm_key_list_stop_completion = [''] - - " let g:ycm_python_binary_path = '/usr/local/bin/python3' - let g:ycm_python_binary_path = 'python3' - - - " 跳转到定义处, 分屏打开 - let g:ycm_goto_buffer_command = 'horizontal-split' - let g:ycm_register_as_syntastic_checker = 0 - " nnoremap jd :YcmCompleter GoToDefinition - nnoremap jd :YcmCompleter GoToDefinitionElseDeclaration - nnoremap gd :YcmCompleter GoToDeclaration - - " 引入,可以补全系统,以及python的第三方包 针对新老版本YCM做了兼容 - " old version - if !empty(glob("~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py")) - let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py" - endif - " new version - if !empty(glob("~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py")) - let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py" - endif +" coc.nvim {{{ +" TODO: https://github.com/neoclide/coc.nvim#example-vim-configuration +" Don't pass messages to |ins-completion-menu|. +set shortmess+=c + +" Use tab for trigger completion with characters ahead and navigate. +" NOTE: Use command ':verbose imap ' to make sure tab is not mapped by +" other plugin before putting this into your config. +inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() +inoremap pumvisible() ? "\" : "\" + +" inoremap +" \ pumvisible() ? coc#_select_confirm() : +" \ coc#expandableOrJumpable() ? "\=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\" : +" \ check_back_space() ? "\" : +" \ coc#refresh() + +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" let g:coc_snippet_next = '' + +" Use to trigger completion. +if has('nvim') + inoremap coc#refresh() +else + inoremap coc#refresh() +endif - let g:ycm_extra_conf_globlist = ['!~/*'] - " 直接触发自动补全 insert模式下 - " let g:ycm_key_invoke_completion = '' - " 黑名单,不启用 - let g:ycm_filetype_blacklist = { - \ 'tagbar' : 1, - \ 'gitcommit' : 1, - \} +" Make auto-select the first completion item and notify coc.nvim to +" format on enter, could be remapped by other vim plugin +inoremap pumvisible() ? coc#_select_confirm() + \: "\u\\=coc#on_enter()\" + +" Use `K` to show documentation in preview window. +nnoremap K :call show_documentation() +function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) + execute 'h '.expand('') + elseif (coc#rpc#ready()) + call CocActionAsync('doHover') + else + execute '!' . &keywordprg . " " . expand('') + endif +endfunction + +" Highlight the symbol and its references when holding the cursor. +, +" to un-Highlight +autocmd CursorHold * silent call CocActionAsync('highlight') + +" =================== verified here!!!!!! + +" Use `[g` and `]g` to navigate diagnostics +" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. +" nmap [g (coc-diagnostic-prev) +" nmap ]g (coc-diagnostic-next) + +" GoTo code navigation. +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) " }}} - " ultisnips {{{ - let g:UltiSnipsExpandTrigger = "" - let g:UltiSnipsJumpForwardTrigger = "" - let g:UltiSnipsJumpBackwardTrigger = "" + " disable the default for coc.vim + let g:UltiSnipsExpandTrigger="" let g:UltiSnipsSnippetDirectories = ['UltiSnips'] let g:UltiSnipsSnippetsDir = '~/.vim/UltiSnips' " 定义存放代码片段的文件夹 .vim/UltiSnips下,使用自定义和默认的,将会的到全局,有冲突的会提示 " 进入对应filetype的snippets进行编辑 map us :UltiSnipsEdit - - " ctrl+j/k 进行选择 - func! g:JInYCM() - if pumvisible() - return "\" - else - return "\" - endif - endfunction - - func! g:KInYCM() - if pumvisible() - return "\" - else - return "\" - endif - endfunction - inoremap =g:JInYCM() - au BufEnter,BufRead * exec "inoremap " . g:UltiSnipsJumpBackwordTrigger . " =g:KInYCM()" - let g:UltiSnipsJumpBackwordTrigger = "" " }}} @@ -907,10 +818,6 @@ endif autocmd FileType go nmap c (go-coverage-toggle) " autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 - - " lint - let g:syntastic_go_checkers = ['golangci_lint'] - let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go', 'java'] } " }}} " markdown {{{ @@ -937,7 +844,6 @@ endif " beta {{{ - " }}} "------------------------------------------- end of configs --------------------------------------------