From 35d646461b68bfc0a1adbbdbee77e84b16e86227 Mon Sep 17 00:00:00 2001 From: Egor Kovetskiy Date: Fri, 19 Jun 2020 14:55:16 +0300 Subject: [PATCH] add vim.d --- .vimrc | 1348 +-------------------------------- .zshrc | 7 +- vim.d/00-base.vim | 83 ++ vim.d/01-plugins.vim | 120 +++ vim.d/10-eclim.vim | 9 + vim.d/11-fzf.vim | 62 ++ vim.d/11-nofolding.vim | 5 + vim.d/32-misc-func.vim | 158 ++++ vim.d/35-misc-command.vim | 3 + vim.d/40-coc.vim | 26 + vim.d/41-lexical.vim | 37 + vim.d/43-whitespace.vim | 17 + vim.d/44-sneak.vim | 19 + vim.d/45-visual-multi.vim | 25 + vim.d/46-lightline.vim | 20 + vim.d/50-misc-autogroup.vim | 23 + vim.d/50-snippets.vim | 77 ++ vim.d/60-langs.vim | 24 + vim.d/61-langs-java.vim | 76 ++ vim.d/62-langs-javascript.vim | 39 + vim.d/63-langs-go.vim | 126 +++ vim.d/64-langs-python.vim | 1 + vim.d/90-map.vim | 141 ++++ 23 files changed, 1099 insertions(+), 1347 deletions(-) create mode 100644 vim.d/00-base.vim create mode 100644 vim.d/01-plugins.vim create mode 100644 vim.d/10-eclim.vim create mode 100644 vim.d/11-fzf.vim create mode 100644 vim.d/11-nofolding.vim create mode 100644 vim.d/32-misc-func.vim create mode 100644 vim.d/35-misc-command.vim create mode 100644 vim.d/40-coc.vim create mode 100644 vim.d/41-lexical.vim create mode 100644 vim.d/43-whitespace.vim create mode 100644 vim.d/44-sneak.vim create mode 100644 vim.d/45-visual-multi.vim create mode 100644 vim.d/46-lightline.vim create mode 100644 vim.d/50-misc-autogroup.vim create mode 100644 vim.d/50-snippets.vim create mode 100644 vim.d/60-langs.vim create mode 100644 vim.d/61-langs-java.vim create mode 100644 vim.d/62-langs-javascript.vim create mode 100644 vim.d/63-langs-go.vim create mode 100644 vim.d/64-langs-python.vim create mode 100644 vim.d/90-map.vim diff --git a/.vimrc b/.vimrc index 958a1c64..9a34e46c 100644 --- a/.vimrc +++ b/.vimrc @@ -1,1347 +1,5 @@ -set nocompatible - -if empty(glob('~/.vim/autoload/plug.vim')) - silent !mkdir -p ~/.vim/autoload - silent !curl -fLo ~/.vim/autoload/plug.vim - \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - autocmd VimEnter * PlugInstall -endif - -let g:plug_url_format = 'git@github.com:%s' -let g:plug_shallow = 0 - -let g:mapleader="\" -let mapleader=g:mapleader - -let g:python3_host_prog = '/usr/bin/python3' - -augroup plugvim - au! -call plug#begin('~/.vim/bundle') - -" set up indent/vim.vim -let g:vim_indent_cont = shiftwidth() - -let g:py_modules = [] - -Plug 'kovetskiy/vim-hacks' - -Plug 'junegunn/fzf' -Plug 'junegunn/fzf.vim' -" let $FZF_DEFAULT_COMMAND='sk' - let g:fzf_prefer_tmux = 1 - let g:fzf_layout = { 'down': '~40%' } - - func! _select_file(...) - let dir = "" - if a:0 > 0 - let dir = a:1 - endif - - call _snippets_stop() - - call fzf#run(fzf#wrap({ - \ 'source': 'prols ' . dir, - \ 'options': '--sort --no-exact --tiebreak=index' - \ })) - endfunc! - - func! _select_file_cwd() - call _select_file(expand('%:h')) - endfunc! - - func! _select_buffer() - call _snippets_stop() - call fzf#vim#buffers({'options': '--sort --no-exact --tiebreak=index'}) - endfunc! - - map :call _select_file() - map :call _select_file_cwd() - - let g:grep_last_query = "" - - func! _grep(query) - let g:grep_last_query = a:query - - let @/ = a:query - call fzf#vim#ag(a:query, {'options': '--delimiter : --nth 4..'}) - endfunc! - - func! _grep_word() - let l:word = expand('') - call _grep(l:word) - endfunc! - - func! _grep_slash() - let l:slash = strpart(@/, 2) - call _grep(l:slash) - endfunc! - - func! _grep_recover() - call _grep(g:grep_last_query) - endfunc! - - command! -nargs=* Grep call _grep() - - nnoremap :Grep - nnoremap :call _grep_word() - - func! _lstags() - call fzf#vim#ag("", {'source': 'lstags', 'options': '--delimiter : --nth 4..'}) - endfunc! - - nnoremap :call _lstags() - -"Plug 'marijnh/tern_for_vim', {'for': 'javascript'} - augroup _js_settings - au! - au BufNewFile,BufRead *.js setlocal noet - augroup end - -Plug 'itchyny/lightline.vim' - let g:lightline = { - \ 'component_function': { - \ 'filename': '_relative_filename' - \ } - \ } - - function! _relative_filename() - return expand('%') - endfunction - - let g:lightline.enable = { - \ 'statusline': 1, - \ 'tabline': 0 - \ } - - if &background == "light" - let g:lightline.colorscheme = 'one' - else - let g:lightline.colorscheme = 'wombat' - endif - - -if $BACKGROUND == "dark" - Plug 'reconquest/vim-colorscheme' - func! _setup_colorscheme() - colorscheme reconquest - - hi! CursorLineNr ctermbg=1 - hi! GitDeleted ctermfg=88 - hi! GitAdded ctermfg=22 - hi! GitModified ctermfg=238 - hi! MoreMsg ctermbg=none ctermfg=238 - endfunc! -endif - -Plug 'scrooloose/nerdcommenter' - -Plug 'kovetskiy/synta' - let g:synta_go_highlight_calls = 0 - let g:synta_go_highlight_calls_funcs = 1 - let g:synta_use_sbuffer = 0 - let g:synta_use_go_fast_build = 0 - let g:synta_go_build_recursive = 1 - let g:synta_go_build_recursive_cwd = 1 - -Plug 'fatih/vim-go', {'for': ['go', 'yaml', 'template']} - nnoremap i :!go-install-deps - let g:go_rename_command = 'gopls' - - hi! link goCall Function - - func! _extend_yaml() - if exists("b:yaml_extended") - return - endif - - runtime! syntax/yaml.vim - if exists("b:current_syntax") - unlet b:current_syntax - endif - runtime! syntax/gotexttmpl.vim - - let b:current_syntax = 'yaml' - - let b:yaml_extended = 1 - endfunc! - - func! _extend_templatego() - if exists("b:templatego_extended") - return - endif - - call plug#load('vim-go') - if exists("b:current_syntax") - unlet b:current_syntax - endif - runtime! syntax/gotexttmpl.vim - - let b:templatego_extended = 1 - endfunc! - - augroup _yaml_settings - au! - au BufEnter *.yaml call _extend_yaml() - augroup end - - augroup _template_go - au! - au BufEnter *.template call _extend_templatego() - augroup end - - let g:go_template_autocreate = 0 - - let g:go_fmt_fail_silently = 0 - let g:go_fmt_command = "gofumports" - let g:go_fmt_autosave = 0 - let g:go_bin_path = $GOPATH . "/bin" - let g:go_metalinter_command="golangci-lint run" - let g:go_list_type = "quickfix" - let g:go_auto_type_info = 0 - let g:go_gocode_autobuild = 1 - - let g:go_doc_keywordprg_enabled = 0 - let g:go_def_mapping_enabled = 0 - let g:go_def_mode = 'godef' - let g:go_info_mode = 'gopls' - - - func! _goto_prev_func() - call search('^func ', 'b') - nohlsearch - normal zt - endfunc! - - func! _goto_next_func() - call search('^func ', '') - nohlsearch - normal zt - endfunc! - - augroup _go_settings - au! - au FileType go nmap :call _goto_prev_func() - - au FileType go let w:go_stack = 'fix that shit' - au FileType go let w:go_stack_level = 'fix that shit' - au FileType go nmap gt :call go#def#Jump('', 1) - au FileType go nmap gd :call go#def#Jump('', 0) - au FileType go nmap gl :call go#def#Jump('vsplit', 0) - au FileType go nmap gk :call go#def#Jump('split', 0) - - au FileType go nmap :w:call synta#go#build() - au FileType go imap :w:call synta#go#build() - - au FileType go nnoremap r :GoRename - augroup end - - - augroup _json_settings - au! - au BufNewFile,BufRead *.dump set filetype=dump - au BufNewFile,BufRead *.json set filetype=json - au BufNewFile,BufRead *.yaml,*.yml,*.ts,*.js setlocal ts=2 sts=2 sw=2 expandtab - "au BufNewFile,BufRead *.js setlocal ts=4 sts=4 sw=4 expandtab - augroup end - -Plug 'vim-scripts/l9' - -" need to press enter -"Plug 'rstacruz/vim-closer' -" lexima doesn't detect closing pair -"Plug 'cohama/lexima.vim' -" disabled due to weird behavior with {} the end bracket disappears -"Plug 'tmsvg/pear-tree' - "let g:pear_tree_smart_openers = 0 - "let g:pear_tree_smart_closers = 0 - "let g:pear_tree_smart_backspace = 0 - "let g:pear_tree_pairs = { - " \ '(': {'closer': ')'}, - " \ '[': {'closer': ']'}, - " \ '{': {'closer': '}'}, - " \ "'": {'closer': "'"}, - " \ '"': {'closer': '"'} - " \ } - -" breaks snippets -"Plug 'jiangmiao/auto-pairs' - -" doesn't even add a new line in case of for{|} ENTER -"Plug 'Raimondi/delimitMate' - -Plug 'sirver/ultisnips', { 'frozen': 1 } - let g:UltiSnipsJumpForwardTrigger="" - let g:UltiSnipsJumpBackwardTrigger="" - - let g:UltiSnipsUsePythonVersion = 2 - - let g:snippets_dotfiles = $HOME . '/.vim/snippets/' - let g:snippets_reconquest = $HOME . '/.vim/bundle/snippets/' - - let g:UltiSnipsSnippetDirectories = [ - \ g:snippets_reconquest, - \ g:snippets_dotfiles, - \] - - let g:UltiSnipsEnableSnipMate = 0 - let g:UltiSnipsExpandTrigger="" - let g:UltiSnipsEditSplit="horizontal" - - func! _snippets_stop() - python "UltiSnips_Manager._leave_buffer()" - endfunc! - - func! _snippets_get_filetype() - let l:dot = strridx(&filetype, ".") - if l:dot != -1 - return strpart(&filetype, 0, dot) - endif - - return &filetype - endfunc! - - func! _snippets_open_dotfiles() - split - execute "edit" g:snippets_dotfiles . - \ _snippets_get_filetype() . ".snippets" - endfunc! - - func! _snippets_open_reconquest() - split - execute "edit" g:snippets_reconquest . - \ _snippets_get_filetype() . ".snippets" - endfunc! - - nnoremap :call _snippets_open_dotfiles() - nnoremap :call _snippets_open_reconquest() - - smap a - smap oi - - augroup _disable_textwidth - au! - au FileType snippets set textwidth=0 - au FileType dockerfile set textwidth=0 - augroup end - - func! _expand_snippet() - let g:_expand_snippet = 1 - call UltiSnips#ExpandSnippet() - let g:_expand_snippet = 0 - - if g:ulti_expand_res == 0 - if pumvisible() - "&& !empty(v:completed_item) - return coc#_select_confirm() - else - call coc#refresh() - let col = col('.') - 1 - if !col || getline('.')[col - 1] =~# '\s' - return "\" - end - end - else - call coc#refresh() - return "" - end - - return "\" - endfunc - - inoremap =_expand_snippet() - xnoremap :call UltiSnips#SaveLastVisualSelection()gvs - - inoremap pumvisible() ? "\" : "\" - inoremap pumvisible() ? "\" : "\" - -Plug 'tpope/vim-surround' - -Plug 'pangloss/vim-javascript', { 'for': 'js' } - -Plug 'danro/rename.vim' - nnoremap r :noautocmd Rename - - func! _delete_file() - call system("rm " . expand("%")) - call _close_it() - endfunc! - - nnoremap x :call _delete_file() - -Plug 'plasticboy/vim-markdown', { 'for': 'markdown' } - augroup _md_settings - au! - au BufRead,BufNewFile *.md set filetype=markdown - au BufRead,BufNewFile *.md set fo-=l - au BufRead,BufNewFile *.md setlocal tw=120 - augroup end - let g:vim_markdown_folding_disabled=0 - -Plug 'AndrewRadev/sideways.vim' - nnoremap sh :SidewaysLeft - nnoremap sl :SidewaysRight - - nnoremap h :SidewaysJumpLeft - nnoremap l :SidewaysJumpRight - - -Plug 'octol/vim-cpp-enhanced-highlight', { 'for': ['c', 'cpp'] } - -"Plug 'terryma/vim-multiple-cursors' - "function! Multiple_cursors_before() - "let b:deoplete_disable_auto_complete = 1 - "endfunction - - "function! Multiple_cursors_after() - "let b:deoplete_disable_auto_complete = 0 - "endfunction - -Plug 'justinmk/vim-sneak' - " bullshit - nmap S Sneak_s - vmap s Sneak_s - nmap Sneak_S - vmap Sneak_S - - nmap f Sneak_f - nmap F Sneak_F - xmap f Sneak_f - xmap F Sneak_F - omap f Sneak_f - omap F Sneak_F - "replace 't' with 1-char Sneak - nmap t Sneak_t - nmap T Sneak_T - xmap t Sneak_t - xmap T Sneak_T - omap t Sneak_t - omap T Sneak_T - -Plug 'reconquest/vim-pythonx' - let g:pythonx_highlight_completion = 0 - let g:pythonx_go_info_mode = 'coc' - - vnoremap v :python px.langs.go.transform.to_variable() - nmap $T{i - - -Plug 'reconquest/snippets' - augroup _snippets_reload - au! - au VimEnter * py - \ import vim; - \ import px; - \ import snippets; - \ [ - \ vim.command("call add(g:py_modules, '%s')" % library) - \ for library in px.libs() - \ ] - \ and - \ [ - \ vim.command("call add(g:py_modules, '%s')" % library) - \ for library in px.libs('snippets') - \ ] - augroup end - -Plug 'kovetskiy/vim-empty-lines' - nnoremap j :call DelEmptyLineBelow() - nnoremap k :call DelEmptyLineAbove() - nnoremap j :call AddEmptyLineBelow() - nnoremap k :call AddEmptyLineAbove() - -Plug 'kovetskiy/vim-plugvim-utils', {'on': 'NewPlugFromClipboard'} - nnoremap c :call NewPlugFromClipboard() - -Plug 'kovetskiy/vim-ski' - let g:skeletons_dir=$HOME . '/.vim/bundle/snippets/skeletons/' - - augroup _sh_filetype - au! - au BufRead,BufNewFile */bin/* set ft=sh - augroup end - -Plug 'bronson/vim-trailing-whitespace' - let g:extra_whitespace_ignored_filetypes = [ - \ 'diff', 'markdown', 'go' - \ ] - - func! _spaces_fix() - if ShouldMatchWhitespace() - FixWhitespace - if &expandtab - retab! - endif - endif - endfunc! - - augroup _whitespace_auto - au! - au BufWritePre * call _spaces_fix() - augroup end - -Plug 'sjl/gundo.vim', { 'on': 'GundoShow' } - -Plug 'kovetskiy/kb-train', { 'on': 'Train' } - -if $BACKGROUND == "light" - Plug 'NLKNguyen/papercolor-theme' - Plug 'sonph/onehalf', {'rtp': 'vim/'} - - func! _setup_colorscheme() - set background="light" - colorscheme papercolor - - hi! SpecialKey ctermfg=250 - hi! String ctermfg=33 - hi! PreProc ctermfg=19 - hi! CursorLineNr ctermbg=1 - endfunc! -endif - -Plug 'justinmk/vim-syntax-extra', { 'for': 'c' } - -Plug 'yssl/QFEnter' - -Plug 'rust-lang/rust.vim', {'for': 'rust' } - -Plug 'rhysd/vim-go-impl' - -Plug 'wellle/targets.vim' - -Plug 'kovetskiy/vim-bash' - -Plug 'FooSoft/vim-argwrap', {'on': 'ArgWrap'} - augroup _go_argwarap - au! - au BufRead,BufNewFile *.go let b:argwrap_tail_comma = 1 - augroup end - - func! _search_wrappable() - let l:bracket = '\([^\)]' - let l:squares = '\[[^\]]' - let l:braces = '\{[^\}]' - let l:pattern = '\v[^ ](' . l:bracket . '|' . l:squares . '|' . l:braces . ')' - - call search(l:pattern, 'cs') - endfunc! - nnoremap @l :call _search_wrappable()ll:ArgWrap - - func! _chain_wrap(first) - let match = search(').', 'cs', line('.')) - if match == 0 - return - endif - call cursor(match, 0) - - let cmd = "lli\r" - if a:first == 1 - let l:cmd = l:cmd . "\t" - endif - - exec "normal" l:cmd - - call _chain_wrap(0) - endfunc! - - nnoremap @h :call _chain_wrap(1) - -Plug 'kovetskiy/sxhkd-vim' - -Plug 'PotatoesMaster/i3-vim-syntax', {'for': 'i3'} - -"Plug 'brooth/far.vim' -" "nmap f :Farp -" augroup _far_settings -" au! -" au FileType far_vim nmap d :Fardo -" augroup end - -"Plug 'reconquest/vim-autosurround' -"Plug 'kovetskiy/vim-autoresize' - -Plug 'w0rp/ale' - let g:ale_enabled = 0 - - function! _ale_gts_fixer(buffer) abort - let l:options = ale#Var(a:buffer, 'typescript_gts_options') - let l:executable = ale#Var(a:buffer, 'typescript_gts_executable') - - - if !executable(l:executable) - return 0 - endif - - return { - \ 'command': ale#Escape(l:executable) - \ . ' ' . (empty(l:options) ? '' : ' ' . l:options) - \ . ' %t', - \ 'read_temporary_file': 1, - \} - endfunction - - let g:ale_fixers = { - \ 'go': [function("synta#ale#goimports#Fix"), function("synta#ale#goinstall#Fix")], - \ 'ruby': [function('ale#fixers#rufo#Fix')], - \ 'java': [function('ale#fixers#google_java_format#Fix')], - \ 'rust': ['rustfmt'], - \ 'sh': ['shfmt'], - \ 'bash': ['shfmt'], - \ 'javascript': ['prettier', 'eslint'], - \ 'pug': [function('ale#fixers#prettier#Fix')], - \ 'scss': [function('ale#fixers#prettier#Fix')], - \ 'typescript': [function('_ale_gts_fixer')], - \} - let g:ale_linters = { - \ 'go': ['gobuild'], - \} - - let g:ale_fix_on_save = 1 - - - augroup _codestyle - au! - au BufRead,BufNewFile *.java setlocal ts=2 sts=2 sw=2 expandtab - au BufRead,BufNewFile *.py setlocal ts=4 sts=4 sw=4 expandtab - - au BufRead,BufNewFile *.java - \ call ale#Set('java_google_java_format_executable', - \ 'palantir-java-format') - au BufRead,BufNewFile *.java - \ call ale#Set('java_google_java_format_options', - \ '--skip-removing-unused-imports --skip-sorting-imports') - au FileType go - \ call ale#Set('go_goimports_executable', - \ 'gofumports') - au BufRead,BufNewFile *.ts - \ call ale#Set('typescript_gts_executable', - \ 'npx') - au BufRead,BufNewFile *.ts - \ call ale#Set('typescript_gts_options', - \ 'gts fix') - augroup end - - - func! _save_typescript() - execute "normal" "w" - call CocAction('diagnosticFirst', 'error') - endfunc! - - augroup _ts - au! - au FileType typescript nnoremap :call coc#rpc#request('runCommand', ['tsserver.organizeImports']) - au FileType typescript nnoremap :call _save_typescript() - augroup end - -Plug 'mg979/vim-visual-multi' - let g:VM_custom_remaps = {'': '[', '': 'q'} - let g:VM_no_meta_mappings = 1 - let g:VM_maps = { - \ 'Select All': '', - \ } - - let g:VM_leader = "\\" - - fun! VM_before_auto() - call MacroBefore() - endfun - - fun! VM_after_auto() - call MacroAfter() - endfun - - function! MacroBefore(...) - unmap f - unmap F - unmap t - unmap T - unmap , - unmap ; - endfunction! - - function! MacroAfter(...) - map f Sneak_f - map F Sneak_F - map t Sneak_t - map T Sneak_T - map , Sneak_, - map ; Sneak_; - endfunction! - -Plug 'tmhedberg/matchit' - -Plug 'pangloss/vim-javascript' - -Plug 'markonm/traces.vim' - nnoremap M :%s/\C\V=expand('')/ - nnoremap H :%s/\v - vnoremap H :s/\v - nmap L VH - - -Plug 'tpope/vim-dispatch' - func! _cnext() - try - cnext - catch - try - cfirst - catch - echom "No errors" - endtry - endtry - endfunc! - - func! _cprev() - try - cprev - catch - try - clast - catch - echom "No errors" - endtry - endtry - endfunc! - - nmap ,d :call _cprev() - nmap ,f :call _cnext() - - func! _spotbugs() - setlocal errorformat=%f:%l:%m - setlocal makeprg=/bin/cat\ target/spotbugs - execute "make" - endfunc! - - func! _atlas_compile() - setlocal errorformat=[ERROR]\ %f:[%l\\,%v]\ %m - setlocal makeprg=atlas-mvn\ compile\ -q - execute "Dispatch" - endfunc! - - func! _format_java() - call coc#rpc#request('runCommand', ['java.action.organizeImports']) - call ale#fix#Fix(bufnr(''), '') - endfunc! - - func! _save_java() - noautocmd w - call _format_java() - call CocAction('diagnosticFirst', 'error') - endfunc! - - augroup _java_bindings - au! - au FileType java nmap :ALEFix - au FileType java nmap :call _save_java() - au FileType java inoremap :call _format_java() - au FileType java nmap - au FileType java nmap ;n (coc-diagnostic-next-error) - au FileType java nmap ; (coc-diagnostic-prev-error) - au FileType java nmap ,x :call _atlas_compile() - au FileType java nmap ,s :call _spotbugs() - augroup end - - -Plug 'fvictorio/vim-extract-variable' - - -Plug 'kovetskiy/coc.nvim', {'do': { -> coc#util#install()}} - func! _coc_restart() - redir @x - silent execute "CocRestart" - redir end - echom "[coc] restarted" - endfunc! - - func! _coc_references() - call lens#disable() - call CocAction('jumpReferences') - call lens#enable() - endfunc! - nmap [g (coc-diagnostic-prev) - nmap ]g (coc-diagnostic-next) - nmap (coc-refactor) - nmap (coc-rename) - nmap (coc-codeaction-selected)l - nmap :call _coc_restart() - nmap gi :call CocActionAsync('doHover') - nmap gr :call _coc_references() - nmap gd (coc-definition) - nmap rn (coc-rename) - nmap - - nmap f (coc-format) - vmap f (coc-format-selected) - - func! _coc_timer_hold() - if exists('b:_coc_timer_moved') && b:_coc_timer_moved == 1 - redir @x - silent call CocAction('showSignatureHelp') - redir end - let b:_coc_timer_moved = 0 - endif - endfunc! - - func! _coc_timer_moved() - let b:_coc_timer_moved = 1 - endfunc! - - autocmd CursorHold *.java call _coc_timer_hold() - autocmd CursorHoldI *.java call _coc_timer_hold() - autocmd CursorMoved *.java call _coc_timer_moved() - autocmd CursorMovedI *.java call _coc_timer_moved() - - - func! _expand_braces() - let l:pattern = '\v\{\}' - - call search(l:pattern, 'cs') - - call feedkeys("a") - call feedkeys("\") - endfunc! - - nmap :call _expand_braces() - -Plug 'majutsushi/tagbar' - -Plug 'kovetskiy/sherlock.vim' - cnoremap esherlock#completeBackward() - cnoremap esherlock#completeForward() - -Plug 'uiiaoo/java-syntax.vim' - -Plug 'lambdalisue/gina.vim' - let g:gina#command#blame#formatter#format="%su%=%au on %ti %ma%in" - -Plug 'tpope/vim-fugitive' - nmap ,a :Git add . - nmap ,s :Gstatus - nmap ,c :Gcommit -v - nmap ,t :Gpush origin - nmap ,g :Dispatch lab ci trace - -Plug 'junegunn/vim-easy-align' - vmap :EasyAlign* - let g:easy_align_ignore_groups = [] - -Plug 'cespare/vim-toml' -" too greedy and too stupid -"Plug 'ggvgc/vim-fuzzysearch' -" let g:fuzzysearch_prompt = '/' -" let g:fuzzysearch_hlsearch = 1 -" let g:fuzzysearch_ignorecase = 1 -" let g:fuzzysearch_max_history = 30 -" let g:fuzzysearch_match_spaces = 0 -" nnoremap / :FuzzySearch - -Plug 'tpope/vim-abolish' - -Plug 'neoclide/coc-tslint-plugin', {'do': 'yarn install --frozen-lockfile'} - -Plug 'lfilho/cosco.vim' - "let g:cosco_filetype_whitelist = ['java'] - "let g:auto_comma_or_semicolon = 1 - "let g:auto_comma_or_semicolon_events = ["InsertLeave"] - "let g:cosco_ignore_comment_lines = 1 - -Plug 'camspiers/animate.vim' - let g:animate#duration = 100.0 - -Plug 'camspiers/lens.vim' - let g:lens#disabled_filenames = ['coc:.*', 'list:.*'] - -Plug 'digitaltoad/vim-pug' - augroup _amber_pug - au! - au BufEnter *.amber setlocal ft=pug - au FileType pug setlocal ts=2 sts=2 sw=2 et - augroup end - - -Plug 'reedes/vim-lexical' - let g:lexical#spell_key = 's' - - if empty(glob('~/.vim/thesaurus/mthesaur.txt')) - silent !mkdir -p ~/.vim/thesaurus/ - silent !curl -fLo ~/.vim/thesaurus/mthesaur.txt - \ https://raw.githubusercontent.com/zeke/moby/master/words.txt - autocmd VimEnter * PlugInstall - endif - - func! _lexical_init() - if expand('%:p') =~ 'coc:' - return - endif - - call lexical#init() - let b:_lexical = '1' - endfunc! - - func! _lexical_toggle() - if !exists('b:_lexical') || b:_lexical == '0' - :call _lexical_init() - else - setlocal spelllang= - setlocal spellfile= - setlocal nospell - setlocal thesaurus= - setlocal dictionary= - let b:_lexical = '0' - endif - endfunc! - - nmap el :call _lexical_toggle() - - augroup lexical - autocmd! - autocmd FileType markdown,md call _lexical_init() - augroup END - -Plug 'rakr/vim-one' - -Plug 'kovetskiy/vim-list-mappings' - nmap :call FzfListMap() - -Plug 'ActivityWatch/aw-watcher-vim' - -Plug 'hashivim/vim-terraform' - let g:terraform_align=1 - let g:terraform_fmt_on_save=1 - -Plug 'ddrscott/vim-side-search' - - func! _sidesearch() - let word = expand('') - if word == "" - let word = input('search: ') - endif - - call SideSearch(word) - endfunc! - nmap s :call _sidesearch() - - nmap a :SideSearch - -"Plug 'paulkass/jira-vim', { 'do': 'pip install -r requirements.txt' } -" source ~/.config/jiravim.vim - -Plug 'junegunn/vader.vim' - -Plug 'matze/vim-move' - -Plug 'kovetskiy/neovim-move', { 'do' : ':UpdateRemotePlugins' } - nmap m :Move - -call plug#end() - -augroup END - -let g:EclimLoggingDisabled = 1 -let g:EclimJavaCompilerAutoDetect = 0 -let g:EclimShowCurrentError = 0 -let g:EclimShowCurrentErrorBalloon = 0 -let g:EclimMakeQfFilter = 0 -let g:EclimSignLevel = 'off' -let g:EclimBuffersTabTracking = 0 -let g:EclimMenus = 0 -let g:EclimJavaCompilerAutoDetect = 0 - -au VimEnter * au! plugvim - -au FileType go au! vim-go -au FileType go au! vim-go-buffer - -set rtp-=~/.vim -set rtp^=~/.vim - -syntax on -filetype plugin indent on - -set shortmess+=sAIc - -set encoding=utf-8 -set printencoding=cp1251 -set fileformat=unix - -set textwidth=80 -set timeoutlen=400 -set wildmenu - -set undofile -set undodir=$HOME/.vim/runtime/undo/ -set directory=$HOME/.vim/runtime/tmp/ -set backupdir=$HOME/.vim/runtime/backup/ -set writebackup -set backup - - -set lazyredraw - -set ttyfast - -set number -set relativenumber - -set history=500 - -set hlsearch -set incsearch - -set ignorecase -set smartcase - -set expandtab -set autoindent -set shiftwidth=4 -set softtabstop=4 -set tabstop=4 -set backspace=2 -set splitright - -set laststatus=2 - -set gdefault -set completeopt-=preview -set nowrap -set updatetime=150 - -set timeoutlen=400 -set showtabline=0 -set cino=(s,m1,+0 - -set list -set lcs=trail:·,tab:→\ " - -set pastetoggle= - -augroup _foldings - au! - au VimEnter,WinEnter,BufRead,BufNewFile * set nofoldenable - au VimEnter,WinEnter,BufRead,BufNewFile * au! matchparen -augroup end - -set noequalalways -set winminheight=0 -set clipboard=unnamedplus - -set tags=./.tags;/ - -if has('nvim') - set viminfo+=n~/.vim/runtime/neoviminfo -else - set viminfo+=n~/.vim/runtime/viminfo -endif - -au FileType help setlocal number - -au BufWritePre * if !isdirectory(expand('%:h')) | call mkdir(expand('%:h'),'p') | endif - -set cc=80,100 - -map Q -map K - -imap tx -au FileType go vmap ctx -vmap oo - -imap context. - -let g:_pwd_startup = getcwd() -func! _cd_root() - let l:root = system("git rev-parse --show-toplevel 2>/dev/null") - if l:root == "" - let l:root = g:_pwd_startup - endif - - execute "cd" l:root -endfunc! - -nnoremap :cd %:p:h -nnoremap :call _cd_root() - -nnoremap o o -nnoremap O O - -nnoremap X S -vnoremap $ g_ - -nnoremap > >> -nnoremap < << - -nnoremap ` :tabedit ~/.vimrc -nnoremap % :so ~/.vimrc - -vnoremap > >gv -vnoremap < - -nnoremap g< '< -nnoremap g> '> - -nnoremap g. '> -nnoremap g, '< - -nnoremap vs :vsp - -nnoremap e :e! - -nnoremap ,q :q -nnoremap :w! -"inoremap :w - -" _close_it closes current window, but if current buffer is opened in two -" windows then only current window will be closed, desu -func! _close_it() - py < 1: - break - -if found > 1: - vim.command("wincmd q") -else: - vim.command("bdelete!") -CODE - call lens#run() -endfunc! - -nnoremap n :call _close_it() -nnoremap q :qa! - -nnoremap d V"_d -vnoremap d "_d - -vnoremap s y:%s/"/ - -vnoremap "kyy -vnoremap "kdgvd -vnoremap "kygvx -vnoremap "kp -vnoremap "kP -vnoremap "ks - -nnoremap v"kx -nnoremap "kp -nnoremap "kP - -nnoremap ] :tnext - -"nnoremap :retab - -"nnoremap :silent !rm -rf ~/.vim/view/*:redraw! - -imap A - -nmap = -nmap h -nmap j -nmap k -nmap l - -imap -vmap - -imap =strpart(search("[)}\"'`\\]]", "c"), -1, 0) - -inoremap o - -imap ua - -imap - -nnoremap :source ~/.vimrc:echom "vimrc sourced" - -nnoremap Q qq -nnoremap @@ @q - -tnoremap - -augroup _zsh_filetype - au! - au BufRead,BufNewFile ~/.zshrc set ft=zsh.sh - au BufRead,BufNewFile *.zsh set ft=zsh.sh -augroup end - -augroup _filetypes - au! - au BufRead,BufNewFile *.service set noet ft=systemd - au BufRead,BufNewFile PKGBUILD set et ft=pkgbuild.sh - au BufRead,BufNewFile *.snippets set noet ft=snippets.python - au BufRead,BufNewFile *.skeleton set noet ft=snippets.python - au BufRead,BufNewFile *.chart set noet ft=mermaid - au BufRead,BufNewFile *.go set noet - au FileType python setlocal et ts=4 sw=4 sts=4 -augroup end - -"augroup _window_size -" au! -" au WinEnter * wincmd = -"augroup end - -nmap K :s///gi - -let @k="^f=i:" -let @j="^t=x" - -func! _tab_space() - keepjumps %s/\t/ / - normal '' -endfunc! - -nmap @t :call _tab_space() - -imap :call CocActionAsync('showSignatureHelp') -nmap :call CocActionAsync('showSignatureHelp') -cmap - -vmap S - -func! DiffApplyBottom() - let start = line('.') - call search("<<<<<", "bcs") - let end = line('.') - execute start.",".end "delete" - call search(">>>>>", "bcs") - execute "delete" - nohlsearch -endfunc! - -func! DiffEnable() - nmap :Grep '\=\=\=\=\=\=\=' - nmap rr :/=====zz:noh - nmap rk :call DiffApplyTop()rr - nmap rj :call DiffApplyBottom()rr -endfunc! - -"func! QueryWrap() -" let l:line = line('.') -" call search(').\w', '', l:line+1) - -" let l:line_data = getline('.') -" let l:col = col('.') -" echom l:col - -" let l:first_line = l:line_data[0:l:col] -" let l:second_line = l:line_data[(l:col+1):-1] - -" call setline(l:line, l:first_line) -" call append(l:line, l:second_line) -" call cursor(l:line+1, 1) -"endfunc! - -command! - \ Diff - \ call DiffEnable() - -let g:profiling = 0 -func! ProfileToggle() - if g:profiling == 0 - let g:profiling = 1 - profile start /tmp/profile - profile func * - profile file * - else - let g:profiling = 0 - profile stop - endif -endfunc! - -command! - \ Profile - \ call ProfileToggle() - -nmap Y yy - -map y "0y -map p "0p - -augroup setup_colorscheme - au! - au VimEnter * call _setup_colorscheme() -augroup end - -augroup window_resize - au! - au VimResized,BufNewFile,BufRead * wincmd = -augroup end - -nnoremap / :noh - -func! _get_github_link() - silent call system("github-link " . expand('%:p') . " " . line('.')) -endfunc! - -nnoremap g :call _get_github_link() - -func! _split_set_content() - let l:dirname = expand('%:h') - let l:ext = expand('%:e') - return l:dirname . '/.' . l:ext -endfunc! - -func! _split_move_cursor() - let l:ext = expand('%:e') - call setcmdpos(len(getcmdline()) - len(expand(l:ext))) - return "" -endfunc! - -nnoremap w :e =_split_set_content()=_split_move_cursor() -nnoremap x :vsp =_split_set_content()=_split_move_cursor() -nnoremap t :sp =_split_set_content()=_split_move_cursor() - -func! _dir_up() - let l:cmd = getcmdline() - let l:pos = getcmdpos() - 1 - - let l:before = strpart(l:cmd, 0, l:pos) - let l:after = strpart(l:cmd, l:pos) - - let l:separator = strridx(l:before, "/") - let l:before = strpart(l:before, 0, l:separator) - - let l:separator = strridx(l:before, "/") - let l:before = strpart(l:before, 0, l:separator) - - let l:before = l:before . "/" - - call setcmdpos(len(l:before) + 1) - - let l:cmdline = l:before . l:after - return l:cmdline -endfunc! - -cnoremap e_dir_up() - - -func! _sys_read(cmdline) - let l:result = system(a:cmdline) - execute "normal" "a" . l:result -endfunc! - -command! -nargs=1 SysRead call _sys_read("") - -if !has('nvim') - set signcolumn=number -else - set signcolumn=yes -endif - -function! SynStack() - if !exists("*synstack") - return - endif - echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') -endfunc +for f in split(glob('~/dotfiles/vim.d/*.vim'), '\n') + exe 'source' f +endfor noh diff --git a/.zshrc b/.zshrc index e92bf42b..98d56fdd 100644 --- a/.zshrc +++ b/.zshrc @@ -1121,8 +1121,10 @@ git-commit-branch() { # :alias -alias bl='batrak -L -K -s -w' -alias bb='batrak -L -K -s -m' +alias bl='batrak -L' +alias blm='batrak -L -m' +alias bk='batrak -L -K -s -w' +alias bkm='batrak -L -K -s -m' alias bm='batrak -M' alias gpd=:git-push-delete alias gpt='git push origin --tags' @@ -1272,6 +1274,7 @@ alias pf=pkgfile alias pl='packages-local' alias pla='packages-local -a' +alias vd='cd ~/dotfiles/vim.d/; vim' alias viz='vim ~/.zshrc' alias tiz='terminal-vim ~/.zshrc' alias zr='source ~/.zshrc && print "zsh config has been reloaded"' diff --git a/vim.d/00-base.vim b/vim.d/00-base.vim new file mode 100644 index 00000000..58b6088c --- /dev/null +++ b/vim.d/00-base.vim @@ -0,0 +1,83 @@ +set nocompatible + +let g:mapleader="\" +let mapleader=g:mapleader + +let g:python3_host_prog = '/usr/bin/python3' + +" set up indent/vim.vim +let g:vim_indent_cont = shiftwidth() + +set shortmess+=sAIc +set encoding=utf-8 +set printencoding=cp1251 +set fileformat=unix +set textwidth=80 +set timeoutlen=400 +set wildmenu +set undofile +set undodir=$HOME/.vim/runtime/undo/ +set directory=$HOME/.vim/runtime/tmp/ +set backupdir=$HOME/.vim/runtime/backup/ +set writebackup +set backup +set lazyredraw +set ttyfast +set number +set relativenumber +set history=500 +set hlsearch +set incsearch +set ignorecase +set smartcase +set expandtab +set autoindent +set shiftwidth=4 +set softtabstop=4 +set tabstop=4 +set backspace=2 +set splitright +set laststatus=2 +set gdefault +set completeopt-=preview +set nowrap +set updatetime=150 +set timeoutlen=400 +set showtabline=0 +set cino=(s,m1,+0 +set list +set lcs=trail:·,tab:→\ " +set pastetoggle= +set noequalalways +set winminheight=0 +set clipboard=unnamedplus +set tags=./.tags;/ +set cc=80,100 + +set rtp-=~/.vim +set rtp^=~/.vim + +syntax on +filetype plugin indent on + +if !has('nvim') + set signcolumn=number +else + set signcolumn=yes +endif + +if empty(glob('~/.vim/autoload/plug.vim')) + silent !mkdir -p ~/.vim/autoload + silent !curl -fLo ~/.vim/autoload/plug.vim + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + autocmd VimEnter * PlugInstall +endif + +let g:plug_url_format = 'git@github.com:%s' +let g:plug_shallow = 0 + +if has('nvim') + set viminfo+=n~/.vim/runtime/neoviminfo +else + set viminfo+=n~/.vim/runtime/viminfo +endif diff --git a/vim.d/01-plugins.vim b/vim.d/01-plugins.vim new file mode 100644 index 00000000..5129970b --- /dev/null +++ b/vim.d/01-plugins.vim @@ -0,0 +1,120 @@ +call plug#begin('~/.vim/bundle') +Plug 'junegunn/fzf' +Plug 'junegunn/fzf.vim' +Plug 'itchyny/lightline.vim' +Plug 'scrooloose/nerdcommenter' +Plug 'kovetskiy/vim-hacks' +Plug 'kovetskiy/synta' +Plug 'fatih/vim-go', {'for': ['go', 'yaml', 'template']} +Plug 'vim-scripts/l9' +Plug 'sirver/ultisnips', { 'frozen': 1 } +Plug 'tpope/vim-surround' +Plug 'pangloss/vim-javascript', { 'for': 'js' } +Plug 'danro/rename.vim' +Plug 'plasticboy/vim-markdown', { 'for': 'markdown' } + let g:vim_markdown_folding_disabled=0 +Plug 'AndrewRadev/sideways.vim' +Plug 'octol/vim-cpp-enhanced-highlight', { 'for': ['c', 'cpp'] } +Plug 'justinmk/vim-sneak' +Plug 'reconquest/vim-pythonx' + let g:pythonx_highlight_completion = 0 + let g:pythonx_go_info_mode = 'coc' +Plug 'reconquest/snippets' +Plug 'kovetskiy/vim-empty-lines' +Plug 'kovetskiy/vim-ski' + let g:skeletons_dir=$HOME . '/.vim/bundle/snippets/skeletons/' +Plug 'bronson/vim-trailing-whitespace' +Plug 'sjl/gundo.vim', { 'on': 'GundoShow' } +Plug 'kovetskiy/kb-train', { 'on': 'Train' } +Plug 'yssl/QFEnter' +Plug 'rust-lang/rust.vim', {'for': 'rust' } +Plug 'wellle/targets.vim' +Plug 'kovetskiy/vim-bash' +Plug 'FooSoft/vim-argwrap', {'on': 'ArgWrap'} +Plug 'kovetskiy/sxhkd-vim' +Plug 'PotatoesMaster/i3-vim-syntax', {'for': 'i3'} +Plug 'w0rp/ale' + let g:ale_enabled = 0 + let g:ale_fixers = { + \ 'ruby': [function('ale#fixers#rufo#Fix')], + \ 'java': [function('ale#fixers#google_java_format#Fix')], + \ 'rust': ['rustfmt'], + \ 'sh': ['shfmt'], + \ 'bash': ['shfmt'], + \ 'pug': [function('ale#fixers#prettier#Fix')], + \ 'scss': [function('ale#fixers#prettier#Fix')], + \} + let g:ale_fix_on_save = 1 +Plug 'mg979/vim-visual-multi' +Plug 'tmhedberg/matchit' +Plug 'markonm/traces.vim' +Plug 'tpope/vim-dispatch' +Plug 'fvictorio/vim-extract-variable' +Plug 'kovetskiy/coc.nvim', {'do': { -> coc#util#install()}} +Plug 'majutsushi/tagbar' +Plug 'kovetskiy/sherlock.vim' + cnoremap esherlock#completeBackward() + cnoremap esherlock#completeForward() +Plug 'uiiaoo/java-syntax.vim' +Plug 'lambdalisue/gina.vim' + let g:gina#command#blame#formatter#format="%su%=%au on %ti %ma%in" +Plug 'tpope/vim-fugitive' + nmap ,a :Git add . + nmap ,s :Gstatus + nmap ,c :Gcommit -v + nmap ,t :Gpush origin + nmap ,g :Dispatch lab ci trace +Plug 'junegunn/vim-easy-align' + vmap :EasyAlign* + let g:easy_align_ignore_groups = [] +Plug 'cespare/vim-toml' +Plug 'tpope/vim-abolish' +Plug 'neoclide/coc-tslint-plugin', {'do': 'yarn install --frozen-lockfile'} +Plug 'lfilho/cosco.vim' + "let g:cosco_filetype_whitelist = ['java'] + "let g:auto_comma_or_semicolon = 1 + "let g:auto_comma_or_semicolon_events = ["InsertLeave"] + "let g:cosco_ignore_comment_lines = 1 +Plug 'camspiers/animate.vim' + let g:animate#duration = 100.0 +Plug 'camspiers/lens.vim' + let g:lens#disabled_filenames = ['coc:.*', 'list:.*'] +Plug 'digitaltoad/vim-pug' +Plug 'reedes/vim-lexical' +Plug 'rakr/vim-one' +Plug 'kovetskiy/vim-list-mappings' + nmap :call FzfListMap() +Plug 'ActivityWatch/aw-watcher-vim' +Plug 'hashivim/vim-terraform', {'for': 'terraform'} + let g:terraform_align=1 + let g:terraform_fmt_on_save=1 +Plug 'ddrscott/vim-side-search' +Plug 'matze/vim-move' +Plug 'kovetskiy/neovim-move', { 'do' : ':UpdateRemotePlugins' } + if $BACKGROUND == "dark" + Plug 'reconquest/vim-colorscheme' + func! _setup_colorscheme() + colorscheme reconquest + + hi! CursorLineNr ctermbg=1 + hi! GitDeleted ctermfg=88 + hi! GitAdded ctermfg=22 + hi! GitModified ctermfg=238 + hi! MoreMsg ctermbg=none ctermfg=238 + endfunc! + endif + if $BACKGROUND == "light" + Plug 'NLKNguyen/papercolor-theme' + Plug 'sonph/onehalf', {'rtp': 'vim/'} + + func! _setup_colorscheme() + set background="light" + colorscheme papercolor + + hi! SpecialKey ctermfg=250 + hi! String ctermfg=33 + hi! PreProc ctermfg=19 + hi! CursorLineNr ctermbg=1 + endfunc! + endif +call plug#end() diff --git a/vim.d/10-eclim.vim b/vim.d/10-eclim.vim new file mode 100644 index 00000000..8d0b635d --- /dev/null +++ b/vim.d/10-eclim.vim @@ -0,0 +1,9 @@ +let g:EclimLoggingDisabled = 1 +let g:EclimJavaCompilerAutoDetect = 0 +let g:EclimShowCurrentError = 0 +let g:EclimShowCurrentErrorBalloon = 0 +let g:EclimMakeQfFilter = 0 +let g:EclimSignLevel = 'off' +let g:EclimBuffersTabTracking = 0 +let g:EclimMenus = 0 +let g:EclimJavaCompilerAutoDetect = 0 diff --git a/vim.d/11-fzf.vim b/vim.d/11-fzf.vim new file mode 100644 index 00000000..7135ab64 --- /dev/null +++ b/vim.d/11-fzf.vim @@ -0,0 +1,62 @@ +let g:fzf_prefer_tmux = 1 +let g:fzf_layout = { 'down': '~40%' } + +func! _select_file(...) + let dir = "" + if a:0 > 0 + let dir = a:1 + endif + + call _snippets_stop() + + call fzf#run(fzf#wrap({ + \ 'source': 'prols ' . dir, + \ 'options': '--sort --no-exact --tiebreak=index' + \ })) +endfunc! + +func! _select_file_cwd() + call _select_file(expand('%:h')) +endfunc! + +func! _select_buffer() + call _snippets_stop() + call fzf#vim#buffers({'options': '--sort --no-exact --tiebreak=index'}) +endfunc! + +map :call _select_file() +map :call _select_file_cwd() + +let g:grep_last_query = "" + +func! _grep(query) + let g:grep_last_query = a:query + + let @/ = a:query + call fzf#vim#ag(a:query, {'options': '--delimiter : --nth 4..'}) +endfunc! + +func! _grep_word() + let l:word = expand('') + call _grep(l:word) +endfunc! + +func! _grep_slash() + let l:slash = strpart(@/, 2) + call _grep(l:slash) +endfunc! + +func! _grep_recover() + call _grep(g:grep_last_query) +endfunc! + +command! -nargs=* Grep call _grep() + +nnoremap :Grep +nnoremap :call _grep_word() + +func! _lstags() + call fzf#vim#ag("", {'source': 'lstags', 'options': '--delimiter : --nth 4..'}) +endfunc! + +nnoremap :call _lstags() diff --git a/vim.d/11-nofolding.vim b/vim.d/11-nofolding.vim new file mode 100644 index 00000000..69eaee30 --- /dev/null +++ b/vim.d/11-nofolding.vim @@ -0,0 +1,5 @@ +augroup _no_foldings + au! + au VimEnter,WinEnter,BufRead,BufNewFile * set nofoldenable + au VimEnter,WinEnter,BufRead,BufNewFile * au! matchparen +augroup end diff --git a/vim.d/32-misc-func.vim b/vim.d/32-misc-func.vim new file mode 100644 index 00000000..cce8c92c --- /dev/null +++ b/vim.d/32-misc-func.vim @@ -0,0 +1,158 @@ +let g:_pwd_startup = getcwd() + +func! _cd_root() + let l:root = system("git rev-parse --show-toplevel 2>/dev/null") + if l:root == "" + let l:root = g:_pwd_startup + endif + + execute "cd" l:root +endfunc! + +func! _delete_file() + call system("rm " . expand("%")) + call _close_it() +endfunc! + +" _close_it closes current window, but if current buffer is opened in two +" windows then only current window will be closed, desu +func! _close_it() + py < 1: + break + +if found > 1: + vim.command("wincmd q") +else: + vim.command("bdelete!") +CODE + call lens#run() +endfunc! + +func! _tab_space() + keepjumps %s/\t/ / + normal '' +endfunc! + + +func! _diff_apply_bottom() + let start = line('.') + call search("<<<<<", "bcs") + let end = line('.') + execute start.",".end "delete" + call search(">>>>>", "bcs") + execute "delete" + nohlsearch +endfunc! + +func! _diff_enable() + nmap :Grep '\=\=\=\=\=\=\=' + nmap rr :/=====zz:noh + nmap rk :call DiffApplyTop()rr + nmap rj :call _diff_apply_bottom()rr +endfunc! + +let g:profiling = 0 +func! _profile_toggle() + if g:profiling == 0 + let g:profiling = 1 + profile start /tmp/profile + profile func * + profile file * + echom "Profiling enabled" + else + let g:profiling = 0 + profile stop + echom "Profiling disabled" + endif +endfunc! + +function! _syn_stack() + if !exists("*synstack") + return + endif + echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') +endfunc + +func! _sys_read(cmdline) + let l:result = system(a:cmdline) + execute "normal" "a" . l:result +endfunc! + +func! _dir_up() + let l:cmd = getcmdline() + let l:pos = getcmdpos() - 1 + + let l:before = strpart(l:cmd, 0, l:pos) + let l:after = strpart(l:cmd, l:pos) + + let l:separator = strridx(l:before, "/") + let l:before = strpart(l:before, 0, l:separator) + + let l:separator = strridx(l:before, "/") + let l:before = strpart(l:before, 0, l:separator) + + let l:before = l:before . "/" + + call setcmdpos(len(l:before) + 1) + + let l:cmdline = l:before . l:after + return l:cmdline +endfunc! + +func! _get_github_link() + silent call system("github-link " . expand('%:p') . " " . line('.')) +endfunc! + +func! _split_set_content() + let l:dirname = expand('%:h') + let l:ext = expand('%:e') + return l:dirname . '/.' . l:ext +endfunc! + +func! _split_move_cursor() + let l:ext = expand('%:e') + call setcmdpos(len(getcmdline()) - len(expand(l:ext))) + return "" +endfunc! + +func! _cnext() + try + cnext + catch + try + cfirst + catch + echom "No errors" + endtry + endtry +endfunc! + +func! _cprev() + try + cprev + catch + try + clast + catch + echom "No errors" + endtry + endtry +endfunc! + +func! _sidesearch() + let word = expand('') + if word == "" + let word = input('search: ') + endif + + call SideSearch(word) +endfunc! diff --git a/vim.d/35-misc-command.vim b/vim.d/35-misc-command.vim new file mode 100644 index 00000000..64840409 --- /dev/null +++ b/vim.d/35-misc-command.vim @@ -0,0 +1,3 @@ +command! -nargs=1 SysRead call _sys_read("") +command! Diff call _diff_enable() +command! Profile call _profile_toggle() diff --git a/vim.d/40-coc.vim b/vim.d/40-coc.vim new file mode 100644 index 00000000..c48279e7 --- /dev/null +++ b/vim.d/40-coc.vim @@ -0,0 +1,26 @@ +func! _coc_restart() + redir @x + silent execute "CocRestart" + redir end + echom "[coc] restarted" +endfunc! + +func! _coc_references() + call lens#disable() + call CocAction('jumpReferences') + call lens#enable() +endfunc! +nmap [g (coc-diagnostic-prev) +nmap ]g (coc-diagnostic-next) +nmap (coc-refactor) +nmap (coc-rename) +nmap (coc-codeaction-selected)l +nmap :call _coc_restart() +nmap gi :call CocActionAsync('doHover') +nmap gr :call _coc_references() +nmap gd (coc-definition) +nmap rn (coc-rename) +nmap + +nmap f (coc-format) +vmap f (coc-format-selected) diff --git a/vim.d/41-lexical.vim b/vim.d/41-lexical.vim new file mode 100644 index 00000000..0ac4c5e5 --- /dev/null +++ b/vim.d/41-lexical.vim @@ -0,0 +1,37 @@ +augroup lexical + autocmd! + autocmd FileType markdown,md call _lexical_init() +augroup END + +if empty(glob('~/.vim/thesaurus/mthesaur.txt')) + silent !mkdir -p ~/.vim/thesaurus/ + silent !curl -fLo ~/.vim/thesaurus/mthesaur.txt + \ https://raw.githubusercontent.com/zeke/moby/master/words.txt + autocmd VimEnter * PlugInstall +endif + +func! _lexical_init() + if expand('%:p') =~ 'coc:' + return + endif + + call lexical#init() + let b:_lexical = '1' +endfunc! + +func! _lexical_toggle() + if !exists('b:_lexical') || b:_lexical == '0' + :call _lexical_init() + else + setlocal spelllang= + setlocal spellfile= + setlocal nospell + setlocal thesaurus= + setlocal dictionary= + let b:_lexical = '0' + endif +endfunc! + +let g:lexical#spell_key = 's' + +nmap el :call _lexical_toggle() diff --git a/vim.d/43-whitespace.vim b/vim.d/43-whitespace.vim new file mode 100644 index 00000000..f6dd9255 --- /dev/null +++ b/vim.d/43-whitespace.vim @@ -0,0 +1,17 @@ +let g:extra_whitespace_ignored_filetypes = [ + \ 'diff', 'markdown', 'go' +\ ] + +func! _spaces_fix() + if ShouldMatchWhitespace() + FixWhitespace + if &expandtab + retab! + endif + endif +endfunc! + +augroup _whitespace_auto + au! + au BufWritePre * call _spaces_fix() +augroup end diff --git a/vim.d/44-sneak.vim b/vim.d/44-sneak.vim new file mode 100644 index 00000000..e324ed3b --- /dev/null +++ b/vim.d/44-sneak.vim @@ -0,0 +1,19 @@ +" bullshit +nmap S Sneak_s +vmap s Sneak_s +nmap Sneak_S +vmap Sneak_S + +nmap f Sneak_f +nmap F Sneak_F +xmap f Sneak_f +xmap F Sneak_F +omap f Sneak_f +omap F Sneak_F +"replace 't' with 1-char Sneak +nmap t Sneak_t +nmap T Sneak_T +xmap t Sneak_t +xmap T Sneak_T +omap t Sneak_t +omap T Sneak_T diff --git a/vim.d/45-visual-multi.vim b/vim.d/45-visual-multi.vim new file mode 100644 index 00000000..bbfd0f1c --- /dev/null +++ b/vim.d/45-visual-multi.vim @@ -0,0 +1,25 @@ +let g:VM_custom_remaps = {'': '[', '': 'q'} +let g:VM_no_meta_mappings = 1 +let g:VM_maps = { + \ 'Select All': '', +\ } + +let g:VM_leader = "\\" + +fun! VM_before_auto() + unmap f + unmap F + unmap t + unmap T + unmap , + unmap ; +endfun + +fun! VM_after_auto() + map f Sneak_f + map F Sneak_F + map t Sneak_t + map T Sneak_T + map , Sneak_, + map ; Sneak_; +endfun diff --git a/vim.d/46-lightline.vim b/vim.d/46-lightline.vim new file mode 100644 index 00000000..f49d122a --- /dev/null +++ b/vim.d/46-lightline.vim @@ -0,0 +1,20 @@ +let g:lightline = { + \ 'component_function': { + \ 'filename': '_relative_filename' + \ } +\ } + +function! _relative_filename() + return expand('%') +endfunction + +let g:lightline.enable = { + \ 'statusline': 1, + \ 'tabline': 0 + \ } + +if &background == "light" + let g:lightline.colorscheme = 'one' +else + let g:lightline.colorscheme = 'wombat' +endif diff --git a/vim.d/50-misc-autogroup.vim b/vim.d/50-misc-autogroup.vim new file mode 100644 index 00000000..4f6caf33 --- /dev/null +++ b/vim.d/50-misc-autogroup.vim @@ -0,0 +1,23 @@ +augroup _filetypes + au! + au BufRead,BufNewFile *.service set noet ft=systemd + au BufRead,BufNewFile PKGBUILD set et ft=pkgbuild.sh + au BufRead,BufNewFile *.snippets set noet ft=snippets.python + au BufRead,BufNewFile *.skeleton set noet ft=snippets.python + au BufRead,BufNewFile *.chart set noet ft=mermaid + au BufRead,BufNewFile *.go set noet + au FileType python setlocal et ts=4 sw=4 sts=4 +augroup end + + +augroup _misc + au! + "au FileType go au! vim-go + "au FileType go au! vim-go-buffer + au BufWritePre * if !isdirectory(expand('%:h')) | call mkdir(expand('%:h'),'p') | endif + au FileType help setlocal number + + au VimEnter * call _setup_colorscheme() + + au VimResized,BufNewFile,BufRead * wincmd = +augroup end diff --git a/vim.d/50-snippets.vim b/vim.d/50-snippets.vim new file mode 100644 index 00000000..445b44e8 --- /dev/null +++ b/vim.d/50-snippets.vim @@ -0,0 +1,77 @@ +func! _snippets_stop() + python "UltiSnips_Manager._leave_buffer()" +endfunc! + +func! _snippets_get_filetype() + let l:dot = strridx(&filetype, ".") + if l:dot != -1 + return strpart(&filetype, 0, dot) + endif + + return &filetype +endfunc! + +func! _snippets_open_dotfiles() + split + execute "edit" g:snippets_dotfiles . + \ _snippets_get_filetype() . ".snippets" +endfunc! + +func! _snippets_open_reconquest() + split + execute "edit" g:snippets_reconquest . + \ _snippets_get_filetype() . ".snippets" +endfunc! + +func! _expand_snippet() + let g:_expand_snippet = 1 + call UltiSnips#ExpandSnippet() + let g:_expand_snippet = 0 + + if g:ulti_expand_res == 0 + if pumvisible() + "&& !empty(v:completed_item) + return coc#_select_confirm() + else + call coc#refresh() + let col = col('.') - 1 + if !col || getline('.')[col - 1] =~# '\s' + return "\" + end + end + else + call coc#refresh() + return "" + end + + return "\" +endfunc + +nnoremap :call _snippets_open_dotfiles() +nnoremap :call _snippets_open_reconquest() + +smap a +smap oi + +inoremap =_expand_snippet() +xnoremap :call UltiSnips#SaveLastVisualSelection()gvs + +inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? "\" : "\" + +let g:UltiSnipsJumpForwardTrigger="" +let g:UltiSnipsJumpBackwardTrigger="" + +let g:UltiSnipsUsePythonVersion = 2 + +let g:snippets_dotfiles = $HOME . '/.vim/snippets/' +let g:snippets_reconquest = $HOME . '/.vim/bundle/snippets/' + +let g:UltiSnipsSnippetDirectories = [ +\ g:snippets_reconquest, +\ g:snippets_dotfiles, +\] + +let g:UltiSnipsEnableSnipMate = 0 +let g:UltiSnipsExpandTrigger="" +let g:UltiSnipsEditSplit="horizontal" diff --git a/vim.d/60-langs.vim b/vim.d/60-langs.vim new file mode 100644 index 00000000..cbae5932 --- /dev/null +++ b/vim.d/60-langs.vim @@ -0,0 +1,24 @@ +augroup _sh_filetype + au! + au BufRead,BufNewFile ~/.zshrc set ft=zsh.sh + au BufRead,BufNewFile *.zsh set ft=zsh.sh + au BufRead,BufNewFile */bin/* set ft=sh +augroup end + +augroup _codestyle + au! + au BufRead,BufNewFile *.py setlocal ts=4 sts=4 sw=4 expandtab + au BufEnter *.amber setlocal ft=pug + au FileType pug setlocal ts=2 sts=2 sw=2 et + au BufNewFile,BufRead *.dump set filetype=dump + au BufNewFile,BufRead *.yaml,*.yml setlocal ts=2 sts=2 sw=2 expandtab + + au FileType snippets set textwidth=0 + au FileType dockerfile set textwidth=0 + au FileType vira set textwidth=0 + + au BufRead,BufNewFile *.md set filetype=markdown + au BufRead,BufNewFile *.md set fo-=l + au BufRead,BufNewFile *.md setlocal tw=120 +augroup end + diff --git a/vim.d/61-langs-java.vim b/vim.d/61-langs-java.vim new file mode 100644 index 00000000..027541f7 --- /dev/null +++ b/vim.d/61-langs-java.vim @@ -0,0 +1,76 @@ +augroup _code_java + au! + + au BufRead,BufNewFile *.java setlocal ts=2 sts=2 sw=2 expandtab + + au BufRead,BufNewFile *.java + \ call ale#Set('java_google_java_format_executable', + \ 'palantir-java-format') + au BufRead,BufNewFile *.java + \ call ale#Set('java_google_java_format_options', + \ '--skip-removing-unused-imports --skip-sorting-imports') + au FileType go + \ call ale#Set('go_goimports_executable', + \ 'gofumports') + + au FileType java nmap :ALEFix + au FileType java nmap :call _save_java() + au FileType java inoremap :call _format_java() + au FileType java nmap + au FileType java nmap ;n (coc-diagnostic-next-error) + au FileType java nmap ; (coc-diagnostic-prev-error) + au FileType java nmap ,x :call _atlas_compile() + au FileType java nmap ,s :call _spotbugs() + + au CursorHold *.java call __java_timer_hold() + au CursorHoldI *.java call __java_timer_hold() + au CursorMoved *.java call __java_timer_moved() + au CursorMovedI *.java call __java_timer_moved() +augroup end + +func! __java_timer_hold() + if exists('b:__java_timer_moved') && b:__java_timer_moved == 1 + redir @x + silent call CocAction('showSignatureHelp') + redir end + let b:__java_timer_moved = 0 + endif +endfunc! + +func! __java_timer_moved() + let b:__java_timer_moved = 1 +endfunc! + +func! _spotbugs() + setlocal errorformat=%f:%l:%m + setlocal makeprg=/bin/cat\ target/spotbugs + execute "make" +endfunc! + +func! _atlas_compile() + setlocal errorformat=[ERROR]\ %f:[%l\\,%v]\ %m + setlocal makeprg=atlas-mvn\ compile\ -q + execute "Dispatch" +endfunc! + +func! _format_java() + call coc#rpc#request('runCommand', ['java.action.organizeImports']) + call ale#fix#Fix(bufnr(''), '') +endfunc! + +func! _save_java() + noautocmd w + call _format_java() + call CocAction('diagnosticFirst', 'error') +endfunc! + +func! _expand_braces() + let l:pattern = '\v\{\}' + + call search(l:pattern, 'cs') + + call feedkeys("a") + call feedkeys("\") +endfunc! + +nmap :call _expand_braces() diff --git a/vim.d/62-langs-javascript.vim b/vim.d/62-langs-javascript.vim new file mode 100644 index 00000000..a5dbc321 --- /dev/null +++ b/vim.d/62-langs-javascript.vim @@ -0,0 +1,39 @@ +augroup _code_typescript + au! + + au BufRead,BufNewFile *.ts + \ call ale#Set('typescript_gts_executable', + \ 'npx') + au BufRead,BufNewFile *.ts + \ call ale#Set('typescript_gts_options', + \ 'gts fix') + + au BufNewFile,BufRead *.json set filetype=json + au BufNewFile,BufRead *.ts,*.js setlocal ts=2 sts=2 sw=2 expandtab + + au FileType typescript nnoremap :call coc#rpc#request('runCommand', ['tsserver.organizeImports']) + au FileType typescript nnoremap :w:call _save_typescript() +augroup end + +func! _save_typescript() + call CocAction('diagnosticFirst', 'error') +endfunc! + +function! _ale_gts_fixer(buffer) abort + let l:options = ale#Var(a:buffer, 'typescript_gts_options') + let l:executable = ale#Var(a:buffer, 'typescript_gts_executable') + + + if !executable(l:executable) + return 0 + endif + + return { + \ 'command': ale#Escape(l:executable) + \ . ' ' . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction + +let g:ale_fixers['typescript'] = [function('_ale_gts_fixer')] diff --git a/vim.d/63-langs-go.vim b/vim.d/63-langs-go.vim new file mode 100644 index 00000000..f89c2bf8 --- /dev/null +++ b/vim.d/63-langs-go.vim @@ -0,0 +1,126 @@ +augroup _code_go + au! + + au FileType go nmap :call _goto_prev_func() + + au FileType go let w:go_stack = 'fix that shit' + au FileType go let w:go_stack_level = 'fix that shit' + au FileType go nmap gt :call go#def#Jump('', 1) + au FileType go nmap gd :call go#def#Jump('', 0) + au FileType go nmap gl :call go#def#Jump('vsplit', 0) + au FileType go nmap gk :call go#def#Jump('split', 0) + + au FileType go nmap :w:call synta#go#build() + au FileType go imap :w:call synta#go#build() + + au FileType go nnoremap r :GoRename + au FileType go nnoremap i :!go-install-deps + + au FileType go vmap ctx + + au BufRead,BufNewFile *.go let b:argwrap_tail_comma = 1 + + au BufEnter *.template call _extend_templatego() + au BufEnter *.yaml call _extend_yaml() +augroup end + +func! _goto_prev_func() + call search('^func ', 'b') + nohlsearch + normal zt +endfunc! + +func! _goto_next_func() + call search('^func ', '') + nohlsearch + normal zt +endfunc! + +func! _extend_yaml() + if exists("b:yaml_extended") + return + endif + + runtime! syntax/yaml.vim + if exists("b:current_syntax") + unlet b:current_syntax + endif + runtime! syntax/gotexttmpl.vim + + let b:current_syntax = 'yaml' + + let b:yaml_extended = 1 +endfunc! + +func! _extend_templatego() + if exists("b:templatego_extended") + return + endif + + call plug#load('vim-go') + if exists("b:current_syntax") + unlet b:current_syntax + endif + runtime! syntax/gotexttmpl.vim + + let b:templatego_extended = 1 +endfunc! + +func! _search_wrappable() + let l:bracket = '\([^\)]' + let l:squares = '\[[^\]]' + let l:braces = '\{[^\}]' + let l:pattern = '\v[^ ](' . l:bracket . '|' . l:squares . '|' . l:braces . ')' + + call search(l:pattern, 'cs') +endfunc! +nnoremap @l :call _search_wrappable()ll:ArgWrap + +func! _chain_wrap(first) + let match = search(').', 'cs', line('.')) + if match == 0 + return + endif + call cursor(match, 0) + + let cmd = "lli\r" + if a:first == 1 + let l:cmd = l:cmd . "\t" + endif + + exec "normal" l:cmd + + call _chain_wrap(0) +endfunc! + +let g:ale_fixers['go'] = [function("synta#ale#goimports#Fix"), function("synta#ale#goinstall#Fix")] +let g:ale_linters = {'go': ['gobuild']} + +let g:go_template_autocreate = 0 + +let g:go_fmt_fail_silently = 0 +let g:go_fmt_command = "gofumports" +let g:go_fmt_autosave = 0 +let g:go_bin_path = $GOPATH . "/bin" +let g:go_metalinter_command="golangci-lint run" +let g:go_list_type = "quickfix" +let g:go_auto_type_info = 0 +let g:go_gocode_autobuild = 1 + +let g:go_doc_keywordprg_enabled = 0 +let g:go_def_mapping_enabled = 0 +let g:go_def_mode = 'godef' +let g:go_info_mode = 'gopls' +let g:go_rename_command = 'gopls' + +let g:synta_go_highlight_calls = 0 +let g:synta_go_highlight_calls_funcs = 1 +let g:synta_use_sbuffer = 0 +let g:synta_use_go_fast_build = 0 +let g:synta_go_build_recursive = 1 +let g:synta_go_build_recursive_cwd = 1 + + +hi! link goCall Function + +nnoremap @h :call _chain_wrap(1) diff --git a/vim.d/64-langs-python.vim b/vim.d/64-langs-python.vim new file mode 100644 index 00000000..9f3f25a1 --- /dev/null +++ b/vim.d/64-langs-python.vim @@ -0,0 +1 @@ +vnoremap v :python px.langs.go.transform.to_variable() diff --git a/vim.d/90-map.vim b/vim.d/90-map.vim new file mode 100644 index 00000000..97ab9e04 --- /dev/null +++ b/vim.d/90-map.vim @@ -0,0 +1,141 @@ +map Q +map K + +imap tx +vmap oo + +imap context. + +nnoremap :cd %:p:h +nnoremap :call _cd_root() + +nnoremap o o +nnoremap O O + +nnoremap X S +vnoremap $ g_ + +nnoremap > >> +nnoremap < << + +nnoremap ` :tabedit ~/.vimrc + +vnoremap > >gv +vnoremap < + +nnoremap g< '< +nnoremap g> '> + +nnoremap g. '> +nnoremap g, '< + +nnoremap vs :vsp + +nnoremap e :e! + +nnoremap ,q :q +nnoremap :w! +" +nnoremap n :call _close_it() +nnoremap q :qa! + +nnoremap d V"_d +vnoremap d "_d + +vnoremap s y:%s/"/ + +vnoremap "kyy +vnoremap "kdgvd +vnoremap "kygvx +vnoremap "kp +vnoremap "kP +vnoremap "ks + +nnoremap v"kx +nnoremap "kp +nnoremap "kP + +nnoremap ] :tnext + +imap A + +nmap = +nmap h +nmap j +nmap k +nmap l + +imap +vmap + +imap =strpart(search("[)}\"'`\\]]", "c"), -1, 0) + +inoremap o + +imap ua + +imap + +nnoremap :source ~/.vimrc:echom "vimrc sourced" + +nnoremap Q qq +nnoremap @@ @q + +tnoremap + +nmap K :s///gi + +let @k="^f=i:" +let @j="^t=x" + +nmap @t :call _tab_space() + +imap :call CocActionAsync('showSignatureHelp') +nmap :call CocActionAsync('showSignatureHelp') +cmap + +vmap S + +nmap Y yy + +map y "0y +map p "0p + +nnoremap w :e =_split_set_content()=_split_move_cursor() +nnoremap x :vsp =_split_set_content()=_split_move_cursor() +nnoremap t :sp =_split_set_content()=_split_move_cursor() + +cnoremap e_dir_up() + +nnoremap / :noh + +nnoremap g :call _get_github_link() + +nnoremap r :noautocmd Rename +nnoremap x :call _delete_file() + + +nnoremap M :%s/\C\V=expand('')/ +nnoremap H :%s/\v +vnoremap H :s/\v +nmap L VH + +nmap ,d :call _cprev() +nmap ,f :call _cnext() + +nnoremap sh :SidewaysLeft +nnoremap sl :SidewaysRight +nnoremap h :SidewaysJumpLeft +nnoremap l :SidewaysJumpRight + +nnoremap j :call DelEmptyLineBelow() +nnoremap k :call DelEmptyLineAbove() +nnoremap j :call AddEmptyLineBelow() +nnoremap k :call AddEmptyLineAbove() + +nmap m :Move + +nmap s :call _sidesearch() +nmap a :SideSearch