diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets index a23487580..e1e524b06 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" @@ -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/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/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..ce680d607 100644 --- a/vimrc +++ b/vimrc @@ -1,11 +1,11 @@ "========================================== " Author: wklken -" Version: 9.1 -" 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 -" Last_modify: 2015-12-15 +" Last_modify: 2019-05-04 " Sections: " -> Initial Plugin 加载插件 " -> General Settings 基础设置 @@ -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' @@ -417,6 +426,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 @@ -519,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 @@ -657,8 +675,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 gui=italic +highlight search ctermfg=Yellow ctermbg=NONE cterm=bold,underline " 设置标记一列的背景颜色和数字一行颜色一致 @@ -675,3 +700,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 18ed2dcf0..cccaf7af5 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 black " 非兼容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', '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'] + " let g:bundle_groups=['python', 'javascript', 'markdown', 'html', 'css', 'tmux', 'beta'] endif " ---------------------------------------------------------------------------- @@ -29,11 +36,9 @@ call plug#begin('~/.vim/bundle') " 移动光标到插件名上, 使用'#'快速跳转到每个插件的配置处 -" syntastic -if v:version < 800 - Plug 'scrooloose/syntastic' -else - Plug 'w0rp/ale' +" lint +if v:version >= 800 + Plug 'dense-analysis/ale' endif " Group dependencies, vim-snippets depends on ultisnips @@ -43,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标签 @@ -69,7 +74,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 @@ -95,16 +101,14 @@ 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' -" ctrlsf -" 类似sublimetext的搜索 -" In CtrlSF window: -" 回车/o, 打开 -" t 在tab中打开(建议) -" T - Lkie t but focus CtrlSF window instead of opened new tab. -" q - Quit CtrlSF window. +" 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' " incsearch " Plug 'haya14busa/incsearch.vim' @@ -119,8 +123,12 @@ 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' +else + Plug 'mhinz/vim-signify', { 'branch': 'legacy' } +endif " gundo " edit history, 可以查看回到某个历史状态 @@ -155,11 +163,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,23 +190,35 @@ 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'} endif +if count(g:bundle_groups, 'rust') + Plug 'rust-lang/rust.vim' +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 = '' + + " 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') @@ -218,7 +241,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 +278,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 @@ -265,24 +287,38 @@ 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 - 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 '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 'robbles/logstash.vim' - " Plug 'ryanoasis/vim-devicons' - " Plug 'ekalinin/dockerfile.vim' + Plug 'ryanoasis/vim-devicons' - " Plug 'ConradIrwin/vim-bracketed-paste' - " Plug 'roxma/vim-paste-easy' + Plug 'robbles/logstash.vim' + Plug 'ekalinin/dockerfile.vim' + " Plug 'yuttie/comfortable-motion.vim' + " Plug 'andrewradev/splitjoin.vim' + " vue + " Plug 'posva/vim-vue' + " Plug 'xolox/vim-easytags' endif @@ -293,95 +329,18 @@ 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 - " pip install flake8 - 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') - " 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 = { + \ '*': ['remove_trailing_lines', 'trim_whitespace'], \ 'python': ['flake8'], - \ 'javascript': ['eslint'], + \ 'javascript': ['prettier', 'eslint'], + \ 'html': [], + \ 'go': ['gopls', '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 = '>' @@ -394,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 @@ -401,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 @@ -410,86 +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 - " 开启语法关键字补全 - 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_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 - " 直接触发自动补全 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 = "" " }}} @@ -511,6 +477,7 @@ endif " nerdcommenter {{{ let g:NERDSpaceDelims=1 let g:NERDAltDelims_python = 1 + let g:NERDDefaultAlign="left" " }}} " trailingwhitespace {{{ @@ -540,6 +507,7 @@ endif map l (easymotion-lineforward) " 重复上一次操作, 类似repeat插件, 很强大 map . (easymotion-repeat) + let g:EasyMotion_startofline = 0 " keep cursor column when JK motion " }}} @@ -583,41 +551,22 @@ 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 - - " 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 + " " 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 +574,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', 'vendor'] " }}} " git. git操作还是习惯命令行,vim里面处理简单diff编辑操作 @@ -651,15 +601,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 " }}} @@ -667,12 +608,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 +663,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 " }}} " ################### 快速导航 ################### @@ -738,6 +679,8 @@ endif " s/v 分屏打开文件 let g:NERDTreeMapOpenSplit = 's' let g:NERDTreeMapOpenVSplit = 'v' + " show bookmarks in nerdtree + " let NERDTreeShowBookmarks = 1 " nerdtreetabs @@ -839,17 +782,42 @@ 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' + + " 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 + 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) - 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_mode_map = { 'mode': 'active', 'passive_filetypes': ['go', 'java'] } + " autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 " }}} " markdown {{{ @@ -875,20 +843,6 @@ 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 - - " Plug 'posva/vim-vue' - - " Plug 'millermedeiros/vim-esformatter' - " will run esformatter after pressing followed by the 'e' and 's' - " keys - " nnoremap es :Esformatter - " vnoremap es :EsformatterVisual " }}}