From ccc0bb0f478cda696ec313a335dd8bd3fc406348 Mon Sep 17 00:00:00 2001 From: wklken Date: Sat, 4 May 2019 17:32:16 +0800 Subject: [PATCH 01/13] 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 02/13] 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 03/13] 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 04/13] 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 05/13] 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 06/13] 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 07/13] 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 d4436d2c019a972934c87763c83ab3001cd47a38 Mon Sep 17 00:00:00 2001 From: wklken Date: Sun, 27 Mar 2022 23:07:43 +0800 Subject: [PATCH 08/13] update --- vimrc | 4 ++++ vimrc.bundles | 36 +++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 17 deletions(-) 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..a505da0bc 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', 'rust', 'javascript', 'golang', '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 @@ -220,6 +220,10 @@ if count(g:bundle_groups, 'python') autocmd BufWritePre *.py execute ':Black' endif +if count(g:bundle_groups, 'rust') + Plug 'rust-lang/rust.vim' +endif + if count(g:bundle_groups, 'php') " piv " shift-v可以查看函数手册 / leader-pd生成注释 @@ -286,6 +290,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 @@ -297,21 +305,17 @@ if count(g:bundle_groups, 'beta') Plug 'ryanoasis/vim-devicons' - Plug 'robbles/logstash.vim' + " 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' - - + " 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) " On-demand lazy load " Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] } @@ -320,11 +324,8 @@ if count(g:bundle_groups, 'beta') " set timeoutlen=500 - " rust - Plug 'rust-lang/rust.vim' - " Plug 'yuttie/comfortable-motion.vim' - Plug 'andrewradev/splitjoin.vim' + " Plug 'andrewradev/splitjoin.vim' " Plug 'AndrewRadev/splitjoin.vim' " vue @@ -446,6 +447,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 +455,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 From 9b249fd60db6819f9debf28c36ac096492804f5f Mon Sep 17 00:00:00 2001 From: wklken Date: Mon, 28 Mar 2022 10:56:20 +0800 Subject: [PATCH 09/13] update fzf, do install() --- vimrc.bundles | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vimrc.bundles b/vimrc.bundles index a505da0bc..ecff594c6 100644 --- a/vimrc.bundles +++ b/vimrc.bundles @@ -106,7 +106,7 @@ Plug 'terryma/vim-multiple-cursors' " change to https://github.com/junegunn/fzf.vim " brew install fzf Plug '/usr/local/opt/fzf' -Plug 'junegunn/fzf.vim' +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'tracyone/fzf-funky',{'on': 'FzfFunky'} From 48c2432475c18be43e6cc60554499eea6321744a Mon Sep 17 00:00:00 2001 From: wklken Date: Mon, 28 Mar 2022 12:07:19 +0800 Subject: [PATCH 10/13] update fzf, replace ctrlp --- vimrc.bundles | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/vimrc.bundles b/vimrc.bundles index ecff594c6..6286dffab 100644 --- a/vimrc.bundles +++ b/vimrc.bundles @@ -105,8 +105,16 @@ Plug 'terryma/vim-multiple-cursors' " 文件搜索 " change to https://github.com/junegunn/fzf.vim " brew install fzf -Plug '/usr/local/opt/fzf' +" Plug '/usr/local/opt/fzf' +if !empty(glob("/usr/local/opt/fzf")) + Plug '/usr/local/opt/fzf' +endif +if !empty(glob("~/.fzf")) + Plug '~/.fzf' +endif +" Plug '~/.fzf' Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' Plug 'tracyone/fzf-funky',{'on': 'FzfFunky'} @@ -699,7 +707,8 @@ endif " ################### 显示增强 ################### " airline {{{ - let g:airline_theme="tomorrow" + " let g:airline_theme="tomorrow" + let g:airline_theme="cobalt2" if !exists('g:airline_symbols') let g:airline_symbols = {} endif From e2f5abe02bfd505b3070c5d1e4e97a3cc2814c4f Mon Sep 17 00:00:00 2001 From: wklken Date: Mon, 28 Mar 2022 12:27:48 +0800 Subject: [PATCH 11/13] update black --- vimrc.bundles | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vimrc.bundles b/vimrc.bundles index 6286dffab..e39c76d6a 100644 --- a/vimrc.bundles +++ b/vimrc.bundles @@ -221,7 +221,8 @@ if count(g:bundle_groups, 'python') " pip install black " https://black.readthedocs.io/en/stable/editor_integration.html - Plug 'psf/black', { 'tag': '19.10b0' } + Plug 'psf/black' + let g:black_linelength=120 nnoremap b :Black " format at save From bb3efd1775aa0922db47a2a2f9a5d7d87f31b9ad Mon Sep 17 00:00:00 2001 From: wklken Date: Wed, 11 May 2022 22:21:07 +0800 Subject: [PATCH 12/13] feat(toml): add toml plugin --- vimrc.bundles | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vimrc.bundles b/vimrc.bundles index e39c76d6a..bdf617753 100644 --- a/vimrc.bundles +++ b/vimrc.bundles @@ -317,6 +317,8 @@ if count(g:bundle_groups, 'beta') " Plug 'robbles/logstash.vim' Plug 'ekalinin/dockerfile.vim' + Plug 'cespare/vim-toml', { 'branch': 'main' } + " Plug 'tenfyzhong/CompleteParameter.vim' " let g:complete_parameter_use_ultisnips_mapping = 1 From 86a902303dd7a63b405155b04722e8440e35c056 Mon Sep 17 00:00:00 2001 From: wklken Date: Mon, 30 Jan 2023 17:28:37 +0800 Subject: [PATCH 13/13] fix(plugin/black): black for branch stable --- install.sh | 3 +++ vimrc.bundles | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 507c836f6..c1e8381c4 100755 --- a/install.sh +++ b/install.sh @@ -91,6 +91,9 @@ cd $CURRENT_DIR/bundle/YouCompleteMe/ git submodule update --init --recursive if [ `which clang` ] # check system clang then + # export DYLD_LIBRARY_PATH=/Library/Developer/CommandLineTools/usr/lib/ + # TODO: if the dir exists, do export first? + # TODO: change cli to https://github.com/wklken/k-vim/pull/379 python install.py --clang-completer --system-libclang # use system clang # for golang # python install.py --clang-completer --system-libclang --go-completer diff --git a/vimrc.bundles b/vimrc.bundles index 1bf7badba..6bd29f7ee 100644 --- a/vimrc.bundles +++ b/vimrc.bundles @@ -220,8 +220,8 @@ if count(g:bundle_groups, 'python') let g:vim_isort_map = '' " pip install black - " https://black.readthedocs.io/en/stable/editor_integration.html - Plug 'psf/black' + " https://black.readthedocs.io/en/stable/integrations/editors.html + Plug 'psf/black', { 'branch': 'stable' } let g:black_linelength=120 nnoremap b :Black