├── .vimrc ├── Readme.md ├── abbr.vim ├── autocmd.vim ├── command.vim ├── general.vim ├── leadermap.vim ├── neovim.vim ├── plugin.vim ├── remap.vim ├── statusline.vim └── tabline.vim /.vimrc: -------------------------------------------------------------------------------- 1 | let g:local = expand('~/vim-dev') 2 | set runtimepath^=~/vim-dev/plug.nvim 3 | call plug#begin() 4 | Plug 'neoclide/coc.nvim', {'dir': g:local, 'frozen': 1} 5 | Plug 'ryanoasis/vim-devicons' 6 | "Plug 'neoclide/coc-imselect', {'dir': g:local, 'frozen': 1} 7 | Plug 'neoclide/coc-eslint', {'dir': g:local, 'frozen': 1} 8 | Plug 'neoclide/coc-stylelint', {'dir': g:local, 'frozen': 1} 9 | "Plug 'evanleck/vim-svelte' 10 | Plug 'neoclide/mycomment.vim', {'dir': g:local, 'frozen': 1} 11 | "Plug 'neoclide/vim-jsx-improve', {'dir': g:local, 'frozen': 1} 12 | "Plug 'yuezk/vim-js' 13 | Plug 'neoclide/macdown.vim', {'dir': g:local, 'frozen': 1} 14 | Plug 'neoclide/macnote.vim', {'dir': g:local, 'frozen': 2} 15 | "Plug 'voldikss/vim-floaterm' 16 | Plug 'chemzqm/vim-macos', {'dir': g:local, 'frozen': 1} 17 | Plug 'chemzqm/vim-run', {'dir': g:local, 'frozen': 1} 18 | Plug 'chemzqm/wxapp.vim', {'dir': g:local, 'frozen': 1} 19 | Plug 'chemzqm/jsonc.vim', {'dir': g:local, 'frozen': 1} 20 | Plug 'peitalin/vim-jsx-typescript' 21 | Plug 'lambdatoast/elm.vim' 22 | "Plug 'chemzqm/coc-task', {'dir': g:local, 'frozen': 1} 23 | Plug 'tpope/vim-fugitive' 24 | Plug 'tpope/vim-repeat' 25 | Plug 'tpope/vim-surround' 26 | Plug 'tpope/vim-markdown' 27 | Plug 'dhruvasagar/vim-zoom' 28 | Plug 'tpope/vim-rhubarb' 29 | Plug 'romainl/vim-cool' " search improve 30 | Plug 'mbbill/undotree' 31 | Plug 'rizzatti/dash.vim' 32 | Plug 'mattn/emmet-vim' 33 | Plug 'whiteinge/diffconflicts' 34 | Plug 'tommcdo/vim-exchange' 35 | Plug 'dag/vim-fish' 36 | "Plug 'fatih/vim-go' 37 | Plug 'heavenshell/vim-jsdoc' 38 | Plug 'elzr/vim-json' 39 | Plug 'othree/xml.vim' 40 | Plug 'altercation/vim-colors-solarized' 41 | Plug 'tommcdo/vim-lion' 42 | Plug 'keith/swift.vim' 43 | Plug 'leafgarland/typescript-vim' 44 | Plug 'Yggdroot/indentLine' 45 | Plug 'mzlogin/vim-markdown-toc' 46 | Plug 'posva/vim-vue' 47 | Plug 'dart-lang/dart-vim-plugin' 48 | Plug 'tweekmonster/helpful.vim' 49 | Plug 'lervag/vimtex' 50 | Plug 'derekwyatt/vim-scala' 51 | Plug 'simnalamburt/vim-mundo' 52 | Plug 'AndrewRadev/splitjoin.vim' 53 | Plug 'lambdalisue/gina.vim' 54 | "Plug 'mhinz/vim-startify' 55 | "Plug 'w0rp/ale', {'branch': 'me'} 56 | "Plug 'Shougo/neco-vim' 57 | "Plug 'garbas/vim-snipmate' 58 | "Plug 'scrooloose/nerdtree' 59 | "Plug 'jparise/vim-graphql' 60 | "Plug 'neoclide/todoapp.vim', {'dir': g:local, 'frozen': 1} 61 | "Plug 'liuchengxu/vista.vim' 62 | "Plug 'easymotion/vim-easymotion' 63 | "Plug 'SirVer/ultisnips' 64 | "Plug 'honza/vim-snippets' 65 | "Plug 'tpope/vim-rails' 66 | "Plug 'tpope/vim-projectionist' 67 | "Plug 'itchyny/lightline.vim' 68 | "Plug 'machakann/vim-highlightedyank' 69 | "Plug 'neoclide/denite-git', {'dir': g:local, 'frozen': 1} 70 | "Plug 'Shougo/denite.nvim', {'branch': 'me'} 71 | "Plug 'neoclide/denite-extra', {'dir': g:local, 'frozen': 1} 72 | "Plug 'Shougo/echodoc' 73 | "Plug 'Shougo/neosnippet.vim' 74 | "Plug 'Shougo/neosnippet-snippets' 75 | "Plug 'mitsuse/autocomplete-swift' 76 | "Plug 'wellle/targets.vim' 77 | call plug#end() 78 | filetype plugin on 79 | syntax on 80 | 81 | " vimrc files 82 | for s:path in split(glob('~/.vim/vimrc/*.vim'), "\n") 83 | exe 'source ' . s:path 84 | endfor 85 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # Vimrc 2 | 3 | Clean and modularized vimrc files. 4 | 5 | -------------------------------------------------------------------------------- /abbr.vim: -------------------------------------------------------------------------------- 1 | iabbrev mocah mocha 2 | iabbrev thsi this 3 | iabbrev slient silent 4 | iabbrev Licence License 5 | iabbrev accross across 6 | iabbrev cosnt const 7 | 8 | function! SetupCommandAbbrs(from, to) 9 | exec 'cnoreabbrev '.a:from 10 | \ .' ((getcmdtype() ==# ":" && getcmdline() ==# "'.a:from.'")' 11 | \ .'? ("'.a:to.'") : ("'.a:from.'"))' 12 | endfunction 13 | 14 | call SetupCommandAbbrs('C', 'CocConfig') 15 | call SetupCommandAbbrs('J', 'Jest') 16 | call SetupCommandAbbrs('CR', 'CocRestart') 17 | call SetupCommandAbbrs('Co', 'Copy') 18 | call SetupCommandAbbrs('D', 'Dict') 19 | call SetupCommandAbbrs('B', 'BlogNew') 20 | call SetupCommandAbbrs('T', 'tabe') 21 | call SetupCommandAbbrs('Gd', 'Gvdiff') 22 | call SetupCommandAbbrs('Gst', 'Denite gitstatus') 23 | call SetupCommandAbbrs('Gp', 'Gpush') 24 | call SetupCommandAbbrs('Gci', 'Gcommit -v') 25 | call SetupCommandAbbrs('Gca', 'Gcommit -a -v') 26 | call SetupCommandAbbrs('Gcaa', 'Gcommit --amend -a -v') 27 | call SetupCommandAbbrs('Gco', 'Gcheckout') 28 | call SetupCommandAbbrs('Grm', 'Gremove') 29 | call SetupCommandAbbrs('Gmv', 'Gmove') 30 | call SetupCommandAbbrs('L', 'CocList') 31 | call SetupCommandAbbrs('U', 'UltiSnipsEdit') 32 | call SetupCommandAbbrs('P', 'Preview') 33 | call SetupCommandAbbrs('F', 'Format') 34 | call SetupCommandAbbrs('N', 'Note') 35 | call SetupCommandAbbrs('A', 'TodoAdd') 36 | call SetupCommandAbbrs('R', 'NpmRun') 37 | call SetupCommandAbbrs('M', 'Mouse') 38 | call SetupCommandAbbrs('E', 'EditVimrc') 39 | call SetupCommandAbbrs('S', 'CocSearch') 40 | call SetupCommandAbbrs('Ex', 'Execute') 41 | call SetupCommandAbbrs('Ns', 'NoteSearch') 42 | call SetupCommandAbbrs('Done', 'Unite todo:done') 43 | call SetupCommandAbbrs('SL', 'SessionLoad') 44 | call SetupCommandAbbrs('W', 'Webpack') 45 | 46 | " vim: set sw=2 ts=2 sts=2 et tw=78; 47 | -------------------------------------------------------------------------------- /autocmd.vim: -------------------------------------------------------------------------------- 1 | " vim: set sw=2 ts=2 sts=2 et tw=78 foldmarker={{,}} foldmethod=marker foldlevel=0: 2 | " common file autocmd {{ 3 | augroup common 4 | autocmd! 5 | "autocmd BufEnter * call EmptyBuffer() 6 | "autocmd CompleteDone * if pumvisible() == 0 | pclose | endif 7 | autocmd FocusGained * checktime 8 | autocmd BufReadPost *.log normal! G 9 | autocmd BufWinEnter * call s:OnBufEnter() 10 | autocmd ColorScheme * call s:Highlight() 11 | autocmd FileType * call s:OnFileType(expand('')) 12 | "autocmd User CocOpenFloat call s:CloseOthers() 13 | if exists('##DirChanged') 14 | autocmd DirChanged,VimEnter * let &titlestring = pathshorten(substitute(getcwd(), $HOME, '~', '')) 15 | endif 16 | autocmd BufNewFile,BufReadPost *.ejs setf html 17 | autocmd BufNewFile,BufRead *.tsx setlocal filetype=typescript.tsx 18 | "autocmd BufNewFile,BufRead *.jsx setlocal filetype=javascript.jsx 19 | autocmd BufNewFile,BufRead *.re setlocal filetype=reason 20 | autocmd User SmartfEnter :hi Conceal ctermfg=220 guifg=#cc241d 21 | autocmd User SmartfLeave :hi Conceal ctermfg=239 guifg=#504945 22 | autocmd User CocQuickfixChange :CocList --normal quickfix 23 | autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') 24 | autocmd CursorHold * silent! call CocActionAsync('highlight') 25 | "autocmd FileType vim if bufname('%') == '[Command Line]' | let b:coc_suggest_disable = 1 | endif 26 | "autocmd FileType txt call PlainText() 27 | "autocmd CursorMoved * if &previewwindow != 1 | pclose | endif 28 | "autocmd User CocQuickfixChange :call fzf_quickfix#run() 29 | " set up default omnifunc 30 | autocmd FileType * 31 | \ if &omnifunc == "" | 32 | \ setlocal omnifunc=syntaxcomplete#Complete | 33 | \ endif 34 | autocmd BufReadPost * 35 | \ if line("'\"") > 1 && line("'\"") <= line("$") | 36 | \ exe "normal! g`\"" | 37 | \ endif 38 | autocmd FileType json syntax match Comment +\/\/.\+$+ 39 | autocmd FileType typescript,python setl formatexpr=CocAction('formatSelected') 40 | autocmd FileType typescript let b:coc_pairs_disabled = ['<'] 41 | autocmd FileType typescript.tsx setl iskeyword-=58 42 | augroup end 43 | 44 | function! EmptyBuffer() 45 | if @% ==# "" 46 | setfiletype txt 47 | endif 48 | endfunction 49 | 50 | function! s:Highlight() abort 51 | if !has('gui_running') | hi normal guibg=NONE | endif 52 | call matchadd('ColorColumn', '\%81v', 100) 53 | hi ColorColumn ctermbg=magenta ctermfg=0 guibg=#333333 54 | hi HighlightedyankRegion term=bold ctermbg=0 guibg=#13354A 55 | hi CocCursorRange guibg=#b16286 guifg=#ebdbb2 56 | hi CursorLineNr ctermfg=214 ctermbg=NONE guifg=#fabd2f guibg=NONE 57 | hi CocErrorFloat guifg=#fb4934 guibg=#504945 58 | hi CocWarningFloat guifg=#fabd2f guibg=#504945 59 | hi CocInfoFloat guifg=#d3869b guibg=#504945 60 | hi CocHintFloat guifg=#83a598 guibg=#504945 61 | hi CocMenuSel ctermbg=237 guibg=#504945 62 | hi link CocErrorSign GruvboxRedSign 63 | hi link CocWarningSign GruvboxYellowSign 64 | hi link CocInfoSign GruvboxPurpleSign 65 | hi link CocHintSign GruvboxBlueSign 66 | hi link CocFloating Pmenu 67 | hi link MsgSeparator MoreMsg 68 | endfunction 69 | 70 | function! s:OnFileType(filetype) 71 | if index(['xml', 'wxml', 'html', 'wxss', 'css', 'scss', 'less'], a:filetype) >=0 72 | let b:coc_additional_keywords = ['-'] 73 | endif 74 | endfunction 75 | 76 | function! s:OnBufEnter() 77 | let name = bufname(+expand('')) 78 | " quickly leave those temporary buffers 79 | if &previewwindow || name =~# '^term://' || &buftype ==# 'nofile' || &buftype ==# 'help' 80 | if !mapcheck('q', 'n') 81 | nnoremap q :bd! 82 | endif 83 | elseif name =~# '/tmp/' 84 | setl bufhidden=delete 85 | endif 86 | unlet name 87 | endfunction 88 | " }} 89 | 90 | function! s:CloseOthers() abort 91 | if exists('g:coc_last_float_win') 92 | for i in range(1, winnr('$')) 93 | if getwinvar(i, 'float') 94 | let winid = win_getid(i) 95 | if winid != g:coc_last_float_win 96 | call coc#util#close_win(winid) 97 | endif 98 | endif 99 | endfor 100 | endif 101 | endfunction 102 | -------------------------------------------------------------------------------- /command.vim: -------------------------------------------------------------------------------- 1 | " vim: set sw=2 ts=2 sts=2 et tw=78: 2 | command! -nargs=0 Save :call s:Save() 3 | command! -nargs=1 SessionSave :call CocAction('runCommand', 'session.save', ) 4 | command! -nargs=0 Format :call CocAction('format') 5 | command! -nargs=0 PickColor :call CocAction('pickColor') 6 | command! -nargs=0 CP :call CocAction('colorPresentation') 7 | command! -nargs=0 Prettier :call CocAction('runCommand', 'prettier.formatFile') 8 | command! -nargs=0 Tslint :call CocAction('runCommand', 'tslint.lintProject') 9 | command! -nargs=0 Tsc :call CocAction('runCommand', 'tsserver.watchBuild') 10 | command! -nargs=0 Webpack :call CocAction('runCommand', 'webpack.watch') 11 | command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') 12 | command! -nargs=0 Start :call CocAction('runCommand', 'npm.run', 'start') 13 | command! -nargs=0 RestartVim :call CocAction('runCommand', 'session.restart') 14 | command! -nargs=0 V :call s:OpenTerminal() 15 | command! -nargs=0 Cd :call s:Gcd() 16 | command! -nargs=0 Mouse :call s:ToggleMouse() 17 | command! -nargs=0 Jsongen :call s:Jsongen() 18 | command! -nargs=0 Reset :call s:StatusReset() 19 | command! -nargs=? Fold :call CocAction('fold', ) 20 | command! -nargs=* Execute :call s:Execute() 21 | command! -nargs=0 Ctags :execute 'Nrun ctags -R .' 22 | command! -nargs=0 -range=% Prefixer call s:Prefixer(, ) 23 | command! -nargs=+ -complete=custom,s:GrepArgs Rg :exe 'CocList grep '. 24 | command! -nargs=? -complete=custom,s:ListVimrc EditVimrc :call s:EditVimrc() 25 | command! -nargs=? -complete=custom,s:ListDict Dict :call s:ToggleDictionary() 26 | command! -nargs=0 Jest :call CocActionAsync('runCommand', 'jest.fileTest', ['%']) 27 | command! -nargs=0 Debug :call s:DebugCoc() 28 | 29 | let s:cmd_map = { 30 | \'javascript': 'babel-node', 31 | \'python': 'python', 32 | \'ruby': 'ruby' 33 | \} 34 | 35 | function! s:ToggleMouse() 36 | if empty(&mouse) 37 | set mouse=a 38 | else 39 | set mouse= 40 | endif 41 | endfunction 42 | 43 | function! s:Execute(args) 44 | let dir = expand('%:p:h') 45 | let file = expand('%:t') 46 | let command = get(b:, 'command', s:cmd_map[&filetype]) 47 | let cmd = "rewatch ".file." -c '".command." ".shellescape(file)." ".a:args." '" 48 | execute 'Nrun ' . cmd 49 | endfunction 50 | 51 | function! s:FileDir(filename) 52 | let file = findfile(a:filename, '.;') 53 | if empty(file) 54 | echohl Error | echon a:filename . ' not found' | echohl None 55 | return 56 | endif 57 | return fnamemodify(file, ':h') 58 | endfunction 59 | 60 | " lcd to current git root 61 | function! s:Gcd() 62 | if empty(get(b:, 'git_dir', '')) | return | endif 63 | execute 'cd '.fnamemodify(b:git_dir, ':h') 64 | endfunction 65 | 66 | " Open vertical spit terminal with current parent directory 67 | function! s:OpenTerminal() 68 | let bn = bufnr('%') 69 | let dir = expand('%:p:h') 70 | if exists('b:terminal') && !buflisted(get(b:, 'terminal')) 71 | unlet b:terminal 72 | endif 73 | if !exists('b:terminal') 74 | belowright vs +enew 75 | exe 'lcd '.dir 76 | execute 'terminal' 77 | call setbufvar(bn, 'terminal', bufnr('%')) 78 | else 79 | execute 'belowright vertical sb '.get(b:, 'terminal', '') 80 | call feedkeys("\", 'n') 81 | endif 82 | endfunction 83 | 84 | function! s:ListDict(A, L, P) 85 | let output = system('ls ~/.vim/dict/') 86 | return join(map(split(output, "\n"), 'substitute(v:val, ".dict", "", "")'), "\n") 87 | endfunction 88 | 89 | " Toggle dictionary list 90 | function! s:ToggleDictionary(...) 91 | for name in a:000 92 | if stridx(&dictionary, name) != -1 93 | echo 'remove dict '.name 94 | execute 'setl dictionary-=~/.vim/dict/'.name.'.dict' 95 | else 96 | echo 'add dict '.name 97 | execute 'setl dictionary+=~/.vim/dict/'.name.'.dict' 98 | endif 99 | endfor 100 | endfunction 101 | 102 | " Prefix css code with postcss and cssnext 103 | function! s:Prefixer(line1, line2) 104 | let input = join(getline(a:line1, a:line2), "\n") 105 | let g:input = input 106 | let output = system('postcss --use postcss-cssnext', input) 107 | if v:shell_error && output !=# "" 108 | echohl Error | echon output | echohl None 109 | return 110 | endif 111 | let win_view = winsaveview() 112 | execute a:line1.','.a:line2.'d' 113 | call append(a:line1 - 1, split(output, "\n")) 114 | call winrestview(win_view) 115 | endfunction 116 | 117 | function! s:ListVimrc(...) 118 | return join(map(split(globpath('~/.vim/vimrc/', '*.vim'),'\n'), 119 | \ "substitute(v:val, '" . expand('~'). "/.vim/vimrc/', '', '')") 120 | \ , "\n") 121 | endfunction 122 | 123 | function! s:GrepArgs(...) 124 | let list = ['-S', '-smartcase', '-i', '-ignorecase', '-w', '-word', 125 | \ '-e', '-regex', '-u', '-skip-vcs-ignores', '-t', '-extension'] 126 | return join(list, "\n") 127 | endfunction 128 | 129 | function! s:EditVimrc(...) 130 | let p = $HOME.'/.vim/vimrc/'.(a:0 == 0 ? '.vimrc' : a:1) 131 | if getcwd() == $HOME.'/.vim/vimrc' 132 | let p = p[len(getcwd()) + 1 : ] 133 | endif 134 | execute 'edit '.p 135 | endfunction 136 | 137 | " Remove hidden buffers and cd to current dir 138 | function! s:StatusReset() 139 | let gitdir = get(b:, 'git_dir', 0) 140 | if !empty(gitdir) 141 | let dir = fnamemodify(gitdir, ':h') 142 | execute 'cd '.dir 143 | endif 144 | " delete hidden buffers 145 | let tpbl=[] 146 | call map(range(1, tabpagenr('$')), 'extend(tpbl, tabpagebuflist(v:val))') 147 | for buf in filter(range(1, bufnr('$')), 'buflisted(v:val) && index(tpbl, v:val)==-1') 148 | if getbufvar(buf, '&buftype') !=? 'terminal' 149 | silent execute 'bdelete '. buf 150 | endif 151 | endfor 152 | endf 153 | 154 | " Generate json from handlebars template 155 | function! s:Jsongen() 156 | let file = expand('%:p') 157 | if &filetype !~# 'handlebars$' 158 | echoerr 'file type should be handlebars' 159 | return 160 | endif 161 | let out = substitute(file, '\v\.hbs$', '.json', '') 162 | let output = system('Jsongen ' . file . ' > ' . out) 163 | if v:shell_error && output !=# "" 164 | echohl WarningMsg | echon output | echohl None 165 | return 166 | endif 167 | let exist = 0 168 | for i in range(winnr('$')) 169 | let nr = i + 1 170 | let fname = fnamemodify(bufname(winbufnr(nr)), ':p') 171 | if fname ==# out 172 | let exist = 1 173 | exe nr . 'wincmd w' 174 | exec 'e ' . out 175 | break 176 | endif 177 | endfor 178 | if !exist | execute 'keepalt belowright vs ' . out | endif 179 | exe 'wincmd p' 180 | endfunction 181 | 182 | function! s:Save() 183 | let file = $HOME.'/tmp.log' 184 | let content = getline(1, '$') 185 | call writefile(content, file) 186 | endfunction 187 | 188 | function! s:DebugCoc() abort 189 | call s:osascript( 190 | \ 'tell application "iTerm2"', 191 | \ 'tell current window', 192 | \ 'create tab with default profile', 193 | \ 'tell current session', 194 | \ 'write text "cd ' . $HOME . '"', 195 | \ 'write text "clear"', 196 | \ 'write text "tail -f '.$NODE_CLIENT_LOG_FILE.'"', 197 | \ 'activate', 198 | \ 'end tell', 199 | \ 'end tell', 200 | \ 'end tell') 201 | endfunction 202 | 203 | function! s:osascript(...) abort 204 | let args = join(map(copy(a:000), '" -e ".shellescape(v:val)'), '') 205 | call s:system('osascript'. args) 206 | return !v:shell_error 207 | endfunction 208 | 209 | function! s:system(cmd) 210 | let output = system(a:cmd) 211 | if v:shell_error && output !=# "" 212 | echohl Error | echom output | echohl None 213 | return 214 | endif 215 | return output 216 | endfunction 217 | -------------------------------------------------------------------------------- /general.vim: -------------------------------------------------------------------------------- 1 | " General options {{ 2 | if !has('nvim') 3 | set notagbsearch 4 | endif 5 | set termguicolors 6 | "set lazyredraw 7 | set hidden " allow buffer switch without saving 8 | set history=2000 9 | set pumheight=15 10 | set wildmenu 11 | set signcolumn=yes 12 | set wildmode=list:longest,full 13 | set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too 14 | set backspace=2 15 | set autowrite 16 | set autoread 17 | set hlsearch 18 | set incsearch 19 | set regexpengine=2 20 | set fileencodings=utf-8,gbk,ucs-bom,cp936 21 | set mousehide 22 | set mouse=a 23 | set novisualbell 24 | if exists('&tagfunc') 25 | set tagfunc=CocTagFunc 26 | endif 27 | "set splitright 28 | set belloff=all 29 | set nobackup 30 | set nowritebackup 31 | set noimdisable 32 | set noswapfile 33 | set undofile 34 | set undodir=~/.undodir 35 | set fileformats=unix,dos 36 | set display+=lastline 37 | set formatoptions+=j 38 | set formatoptions+=o 39 | set diffopt=vertical 40 | set path+=** 41 | set tags+=gems.tags,stdlib.tags 42 | set showbreak=↪ 43 | set shortmess=aFc 44 | set cmdheight=2 45 | set sessionoptions+=winsize 46 | set sessionoptions+=resize 47 | set sessionoptions-=blank 48 | set sessionoptions+=localoptions 49 | set sessionoptions+=globals 50 | set viewoptions=cursor,folds,slash,unix 51 | set ttimeout 52 | set ttimeoutlen=100 53 | set tabpagemax=10 54 | set scrolloff=3 55 | set list 56 | set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace 57 | set wildignore+=*.so,*~,*/.git/*,*/.svn/*,*/.DS_Store,*/tmp/* 58 | set keywordprg= 59 | set showtabline=2 60 | set laststatus=2 61 | set noshowmode 62 | set updatetime=300 63 | set synmaxcol=300 64 | " Formatting 65 | set smarttab 66 | set smartcase 67 | set shiftwidth=2 68 | set tabstop=2 69 | set expandtab 70 | set shiftround 71 | set autoindent 72 | set wrap 73 | set guioptions-=r 74 | set number 75 | set relativenumber 76 | set grepprg=rg\ --vimgrep\ $* 77 | set grepformat=%f:%l:%c:%m 78 | set title 79 | set wildignorecase 80 | set noruler 81 | "set dictionary+=/usr/share/dict/words 82 | " }} 83 | 84 | " Special options for macvim {{ 85 | if has('gui_running') 86 | colorscheme solarized 87 | set guifont=Source\ Code\ Pro:h14 88 | set background=light 89 | set transparency=10 90 | set macmeta 91 | " better font render on Retina screen 92 | set antialias 93 | else 94 | set background=dark 95 | let g:gruvbox_bold=0 96 | let g:gruvbox_invert_selection=0 97 | colorscheme gruvbox 98 | endif 99 | " }} 100 | 101 | " Complete config {{ 102 | set complete+=k 103 | set complete-=t 104 | "set completeopt=noinsert,noselect,menuone 105 | set completeopt=menu,preview 106 | 107 | if !has('nvim') && !has('macvim') 108 | " cursor shape of vim 109 | "let &t_SI = "\]50;CursorShape=1\x7" 110 | "let &t_SR = "\]50;CursorShape=2\x7" 111 | "let &t_EI = "\]50;CursorShape=0\x7" 112 | " make for saving 113 | execute "set =\es" 114 | execute "set =\ec" 115 | endif 116 | " }} 117 | " vim: set sw=2 ts=2 sts=2 et tw=78 foldmarker={{,}} foldmethod=marker foldlevel=0: 118 | -------------------------------------------------------------------------------- /leadermap.vim: -------------------------------------------------------------------------------- 1 | " vim: set sw=2 ts=2 sts=2 et tw=78 foldmarker={{,}} foldmethod=marker foldlevel=0: 2 | let g:mapleader = ',' 3 | 4 | " basic {{ 5 | " Edit file in current file folder 6 | nnoremap n :Lexplore 7 | nnoremap q :silent! Bdelete! 8 | nnoremap e :e =substitute(expand('%:p:h').'/', getcwd().'/', '', '') 9 | nnoremap v :vs =substitute(expand('%:p:h').'/', getcwd().'/', '', '') 10 | nnoremap t :tabe =substitute(expand('%:p:h').'/', getcwd().'/', '', '') 11 | nnoremap rm :Rm =expand('%:p:h').'/' 12 | nnoremap mk :Mkdir =expand('%:p:h').'/' 13 | " Replace all of current word 14 | nnoremap s :%s/\<\>//g 15 | " Reload vimrc file 16 | nnoremap rl :source ~/.vimrc 17 | " Search with grep 18 | nnoremap / :Rg 19 | " generate doc 20 | nnoremap d :call GenDoc() 21 | " clean some dirty charactors 22 | nnoremap cl :call Clean() 23 | " show vim highlight group under cursor 24 | nnoremap hi :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' 25 | \ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" 26 | \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" 27 | nnoremap pp "0p 28 | nnoremap o :call Open() 29 | " }} 30 | 31 | " setting switch {{ 32 | nnoremap sc :setl spell! 33 | nnoremap pt :set paste! 34 | nnoremap nu :call NumberToggle() 35 | nnoremap bg :call ToggleBackground() 36 | " }} 37 | 38 | " plugin {{ 39 | "session helper 40 | nmap ss :call SessionSave() 41 | nmap sl :SessionLoad 42 | nmap sr :call SessionReload() 43 | " svg.vim not used very often 44 | nmap se SvgEdit 45 | 46 | " coc.nvim 47 | nmap x (coc-cursors-operator) 48 | nmap rn (coc-rename) 49 | nmap rf (coc-refactor) 50 | nmap ca (coc-codelens-action) 51 | xmap x (coc-convert-snippet) 52 | xmap f (coc-format-selected) 53 | nmap f (coc-format-selected) 54 | xmap a (coc-codeaction-selected) 55 | nmap a (coc-codeaction-selected) 56 | nmap ac (coc-codeaction-line) 57 | nmap af (coc-codeaction) 58 | nmap di (coc-diagnostic-info) 59 | nmap qf (coc-fix-current) 60 | nmap te :call CocAction('runCommand', 'jest.singleTest') 61 | nmap dr (coc-diagnostic-related) 62 | nmap ms (coc-menu-show) 63 | 64 | nmap tr (coc-translator-p) 65 | " }} 66 | 67 | " grep by motion {{ 68 | vnoremap g :call GrepFromSelected(visualmode()) 69 | nnoremap g :set operatorfunc=GrepFromSelectedg@ 70 | 71 | function! s:GrepFromSelected(type) 72 | let saved_unnamed_register = @@ 73 | if a:type ==# 'v' 74 | normal! `y 75 | elseif a:type ==# 'char' 76 | normal! `[v`]y 77 | else 78 | return 79 | endif 80 | let word = substitute(@@, '\n$', '', 'g') 81 | let word = escape(word, '| ') 82 | let @@ = saved_unnamed_register 83 | execute 'CocList grep '.word 84 | endfunction 85 | " }} 86 | 87 | " functions {{ 88 | function! s:SessionSave() 89 | if !empty(v:this_session) 90 | execute 'SessionSave' 91 | else 92 | call feedkeys(':SessionSave ') 93 | endif 94 | endfunction 95 | 96 | function! s:ToggleBackground() 97 | if &background ==# 'light' 98 | set background=dark 99 | else 100 | set background=light 101 | endif 102 | call SetStatusLine() 103 | endfunction 104 | 105 | function! s:NumberToggle() 106 | if(&number == 1) | set nu! | set rnu! | else | set rnu | set nu | endif 107 | endfunction 108 | 109 | function! s:SessionReload() 110 | execute 'wa' 111 | execute 'RestartVim' 112 | endfunction 113 | 114 | " Simple clean utility 115 | function! s:Clean() 116 | let view = winsaveview() 117 | let ft = &filetype 118 | " replace tab with 2 space 119 | if index(['javascript', 'html', 'css', 'vim', 'php'], ft) != -1 120 | silent! execute "%s/\/ /g" 121 | endif 122 | " replace tailing comma 123 | if ft ==# 'javascript' || ft ==# 'typescript' 124 | silent! execute '%s/;$//' 125 | endif 126 | " remove tailing white space 127 | silent! execute '%s/\s\+$//' 128 | " remove windows `\r` 129 | call winrestview(view) 130 | endfunction 131 | 132 | function! s:GenDoc() 133 | if &ft ==# 'javascript' || &ft ==# 'typescript' 134 | exe "JsDoc" 135 | elseif &ft ==# 'css' 136 | let lines = ['/*', ' * ', ' */'] 137 | exe "normal! j?{$\:noh\" 138 | let lnum = getpos('.')[1] 139 | call append(lnum - 1, lines) 140 | exe "normal! kk$" 141 | startinsert! 142 | elseif &ft ==# 'html' 143 | let lnum = getpos('.')[1] 144 | let ind = matchstr(getline('.'), '\v\s*') 145 | call append(lnum - 1, ind . '') 146 | exe "normal! k^Ell" 147 | startinsert 148 | elseif &filetype ==# 'vim' 149 | let lnum = getpos('.')[1] 150 | let ind = matchstr(getline('.'), '\v\s*') 151 | call append(lnum - 1, ind . '" ') 152 | exe "normal! k$" 153 | startinsert! 154 | else 155 | let lnum = getpos('.')[1] 156 | let ind = matchstr(getline('.'), '\v\s*') 157 | call append(lnum - 1, ind. '# ') 158 | exe "normal! k$" 159 | startinsert! 160 | endif 161 | endfunction 162 | 163 | function! s:Open() 164 | let res = CocAction('openLink') 165 | if res | return | endif 166 | let line = getline('.') 167 | " match url 168 | let url = matchstr(line, '\vhttps?:\/\/[^)\]''" ]+') 169 | if !empty(url) 170 | let output = system('open '. url) 171 | else 172 | let mail = matchstr(line, '\v([A-Za-z0-9_\.-]+)\@([A-Za-z0-9_\.-]+)\.([a-z\.]+)') 173 | if !empty(mail) 174 | let output = system('open mailto:' . mail) 175 | else 176 | let output = system('open ' . expand('%:p:h')) 177 | endif 178 | endif 179 | if v:shell_error && output !=# "" 180 | echoerr output 181 | endif 182 | endfunction 183 | " }} 184 | -------------------------------------------------------------------------------- /neovim.vim: -------------------------------------------------------------------------------- 1 | if !has('nvim') | finish | endif 2 | set inccommand=nosplit 3 | set fillchars+=msgsep:- 4 | 5 | " speed up 6 | let g:python_host_prog = '/usr/local/bin/python' 7 | let g:python3_host_prog = '/usr/local/bin/python3' 8 | let g:ruby_host_prog = exepath('neovim-ruby-host') 9 | 10 | "tnoremap 11 | tnoremap h 12 | tnoremap j 13 | tnoremap k 14 | tnoremap 1gt 15 | tnoremap 2gt 16 | tnoremap 3gt 17 | tnoremap 4gt 18 | tnoremap 5gt 19 | 20 | " Neovim :terminal colors. 21 | let g:terminal_color_0 = '#282828' 22 | let g:terminal_color_1 = '#cc241d' 23 | let g:terminal_color_2 = '#98971a' 24 | let g:terminal_color_3 = '#d79921' 25 | let g:terminal_color_4 = '#458588' 26 | let g:terminal_color_5 = '#b16286' 27 | let g:terminal_color_6 = '#689d6a' 28 | let g:terminal_color_7 = '#a89984' 29 | let g:terminal_color_8 = '#928374' 30 | let g:terminal_color_9 = '#fb4934' 31 | let g:terminal_color_10 = '#b8bb26' 32 | let g:terminal_color_11 = '#fabd2f' 33 | let g:terminal_color_12 = '#83a598' 34 | let g:terminal_color_13 = '#d3869b' 35 | let g:terminal_color_14 = '#8ec07c' 36 | let g:terminal_color_15 = '#ebdbb2' 37 | 38 | function! s:OnTermOpen(buf) 39 | setl nolist norelativenumber nonumber 40 | if &buftype ==# 'terminal' 41 | nnoremap q :bd! 42 | endif 43 | endfunction 44 | 45 | augroup neovim 46 | autocmd! 47 | autocmd TermOpen * :call s:OnTermOpen(+expand('')) 48 | augroup end 49 | -------------------------------------------------------------------------------- /plugin.vim: -------------------------------------------------------------------------------- 1 | """ vim: set sw=2 ts=2 sts=2 et tw=78 foldmarker={{,}} foldmethod=marker foldlevel=0 nofen: 2 | 3 | " startify {{ 4 | let g:startify_change_to_dir = 0 5 | " }}" 6 | 7 | " vimtex {{ 8 | let g:vimtex_matchparen_enabled = 0 9 | " }} 10 | 11 | " vim-go {{ 12 | let g:go_def_mapping_enabled = 0 13 | let g:go_doc_keywordprg_enabled = 0 14 | " }}" 15 | 16 | " vim-markdown {{ 17 | let g:markdown_fenced_languages = ['css', 'javascript', 'js=javascript', 'typescript', 'rust'] 18 | " }}" 19 | 20 | " vim-run {{ 21 | let g:vim_run_command_map = { 22 | \'typescript': 'ts-node', 23 | \'javascript': 'node', 24 | \'python': 'python3', 25 | \'go': 'go run', 26 | \'swift': 'swift' 27 | \} 28 | " }} 29 | 30 | " echodoc {{ 31 | let g:echodoc_enable_at_startup = 1 32 | " }} 33 | 34 | " plug.nvim {{ 35 | let g:plug_rebase = 1 36 | " }} 37 | 38 | " vim-highlightedyank {{ 39 | let g:highlightedyank_highlight_duration = 100 40 | " }} 41 | 42 | " numdo.vim {{ 43 | let g:mundo_prefer_python3 = 1 44 | " }} 45 | 46 | " vim-jsx-improve {{ 47 | let javascript_plugin_jsdoc = 1 48 | let javascript_plugin_flow = 1 49 | " }} 50 | 51 | " xml.vim {{ 52 | let g:xml_syntax_folding = 1 53 | " }} 54 | 55 | " Netrw {{ 56 | let g:netrw_chgwin = 2 57 | let g:netrw_banner=0 58 | let g:netrw_list_hide = ',\(^\|\s\s\)\zs\.\S\+' 59 | let g:netrw_winsize=20 60 | let g:netrw_liststyle=3 61 | let g:netrw_localrmdir='rmtrash' 62 | let g:netrw_bufsettings = "noma nomod nonu nobl nowrap ro nornu buftype=nofile" 63 | " }} 64 | 65 | " vim-gitgutter {{ 66 | let g:gitgutter_max_signs = 999 67 | " }} 68 | 69 | " emmet {{ 70 | " https://raw.github.com/mattn/emmet-vim/master/TUTORIAL 71 | " a Make anchor from URL 72 | " A Make quoted text from URL 73 | let g:user_emmet_leader_key = '' 74 | let g:user_emmet_expandabbr_key = '' 75 | "内部全选 76 | let g:user_emmet_mode='a' 77 | let g:emmet_html5 = 0 78 | let g:user_emmet_settings = { 79 | \ 'javascript': { 80 | \ 'extends': 'html', 81 | \ 'attribute_name': {'class': 'className', 'for': 'htmlFor'}, 82 | \ 'empty_element_suffix': ' />', 83 | \ }, 84 | \ 'wxss': { 85 | \ 'extends': 'css', 86 | \ }, 87 | \ 'wxml': { 88 | \ 'extends': 'html', 89 | \ 'aliases': { 90 | \ 'div': 'view', 91 | \ 'span': 'text', 92 | \ }, 93 | \ 'default_attributes': { 94 | \ 'block': [{'wx:if': '{{somevalue}}'}], 95 | \ 'navigator': [{'url': '', 'redirect': 'false'}], 96 | \ 'scroll-view': [{'bindscroll': ''}], 97 | \ 'swiper': [{'autoplay': 'false', 'current': '0'}], 98 | \ 'icon': [{'type': 'success', 'size': '23'}], 99 | \ 'progress': [{'precent': '0'}], 100 | \ 'button': [{'size': 'default'}], 101 | \ 'checkbox-group': [{'bindchange': ''}], 102 | \ 'checkbox': [{'value': '', 'checked': ''}], 103 | \ 'form': [{'bindsubmit': ''}], 104 | \ 'input': [{'type': 'text'}], 105 | \ 'label': [{'for': ''}], 106 | \ 'picker': [{'bindchange': ''}], 107 | \ 'radio-group': [{'bindchange': ''}], 108 | \ 'radio': [{'checked': ''}], 109 | \ 'switch': [{'checked': ''}], 110 | \ 'slider': [{'value': ''}], 111 | \ 'action-sheet': [{'bindchange': ''}], 112 | \ 'modal': [{'title': ''}], 113 | \ 'audio': [{'src': ''}], 114 | \ 'video': [{'src': ''}], 115 | \ 'image': [{'src': '', 'mode': 'scaleToFill'}], 116 | \ } 117 | \ }, 118 | \} 119 | " }} 120 | 121 | " jsdoc settings {{ 122 | let g:jsdoc_allow_input_prompt = 0 123 | let g:jsdoc_enable_es6 = 1 124 | let g:jsdoc_access_descriptions = 2 125 | let g:jsdoc_underscore_private = 1 126 | let g:jsdoc_custom_args_regex_only = 1 127 | let g:jsdoc_custom_args_hook = { 128 | \ '^\(callback\|cb\)$': { 129 | \ 'type': ' {Function} ', 130 | \ 'description': 'Callback function' 131 | \ }, 132 | \ '\(err\|error\)$': { 133 | \ 'type': '{Error}' 134 | \ }, 135 | \ '^\(opt\|options\)$': { 136 | \ 'type': '{Object}' 137 | \ }, 138 | \ 'handler$': { 139 | \ 'type': '{Function}' 140 | \ }, 141 | \ '^\(n\|i\)$': { 142 | \ 'type': ' {Number} ' 143 | \ }, 144 | \ '^i$': { 145 | \ 'type': ' {Number} ' 146 | \ }, 147 | \ '^_\?\(is\|has\)': { 148 | \ 'type': ' {Boolean} ' 149 | \ }, 150 | \ '^arr$': { 151 | \ 'type': ' {Array} ' 152 | \ }, 153 | \ '^str$': { 154 | \ 'type': ' {String} ' 155 | \ }, 156 | \ '^e$': { 157 | \ 'type': ' {Event} ' 158 | \ }, 159 | \ 'el$': { 160 | \ 'type': ' {Element} ' 161 | \ }, 162 | \ '^node$': { 163 | \ 'type': ' {Element} ' 164 | \ }, 165 | \ '^o$': { 166 | \ 'type': ' {Object} ' 167 | \ }, 168 | \ '^obj$': { 169 | \ 'type': ' {Object} ' 170 | \ }, 171 | \ '^fn$': { 172 | \ 'type': ' {Function} ' 173 | \ }, 174 | \} 175 | " }} 176 | 177 | " html5.vim {{ 178 | let g:html5_event_handler_attributes_complete = 0 179 | let g:html5_rdfa_attributes_complete = 0 180 | let g:html5_microdata_attributes_complete = 0 181 | let g:html5_aria_attributes_complete = 0 182 | " }} 183 | 184 | " dash.vim {{ 185 | let g:dash_map = { 186 | \ 'javascript': ['javascript', 'NodeJS'], 187 | \ 'html': ['html', 'svg'], 188 | \} 189 | " }} 190 | 191 | " vim-cool {{ 192 | let g:CoolTotalMatches = 1 193 | " }}" 194 | 195 | " macdown.vim {{ 196 | let g:macdown_marked_programme = 'misaka' 197 | " }} 198 | 199 | " macnote.vim {{ 200 | let g:macnote_unite_quickfix = 1 201 | " }} 202 | 203 | " coc.nvim {{ 204 | if has('nvim') && !has('nvim-0.4.3') 205 | let g:coc_disable_startup_warning = 1 206 | endif 207 | "let g:coc_channel_timeout = 5 208 | "let g:coc_data_home = '~/.config/a/b/coc' 209 | "let g:coc_disable_startup_warning = 1 210 | "let g:coc_quickfix_open_command = 'copen|cfirst' 211 | "let g:node_client_debug = 1 212 | let $NVIM_COC_LOG_LEVEL = 'debug' 213 | let g:coc_global_extensions = ['coc-word@1.2.0'] 214 | let g:coc_watch_extensions = [] 215 | "let g:coc_node_args = ['--nolazy', '--inspect-brk=6045'] 216 | "let g:coc_node_path = '/usr/local/bin/node' 217 | let g:coc_filetype_map = { 218 | \ 'html.swig': 'html', 219 | \ 'wxss': 'css', 220 | \ } 221 | "call coc#add_command('mundoToggle', 'MundoToggle', 'toggle mundo window') 222 | "call coc#add_command('tree', 'Vexplore', 'open netrw explorer') 223 | "call coc#add_command('translate', 'TranslateW', 'translate word') 224 | " }}" 225 | 226 | " indentLine {{ 227 | let g:indentLine_fileTypeExclude = ['json', 'markdown'] 228 | let g:indentLine_bufTypeExclude = ['help', 'terminal', 'nofile'] 229 | let g:indentLine_char = '│' 230 | " }}" 231 | 232 | " vim-lion {{ 233 | let g:lion_squeeze_spaces = 1 234 | let g:lion_create_maps = 1 235 | " }}" 236 | 237 | " rename.nvim {{ 238 | let g:rename_hl_guifg = '#ffffff' 239 | let g:rename_hl_guibg = '#b180a4' 240 | let g:rename_search_execute = 'rg' 241 | " }}" 242 | -------------------------------------------------------------------------------- /remap.vim: -------------------------------------------------------------------------------- 1 | " vim: set sw=2 ts=2 sts=2 et tw=78 foldmarker={{,}} foldmethod=marker: 2 | 3 | " basic {{ 4 | xnoremap J :m '>+1gv=gv 5 | xnoremap K :m '<-2gv=gv 6 | nnoremap Q 7 | xnoremap < >gv 9 | inoremap "+]p 10 | xnoremap "+y 11 | nnoremap n 'Nn'[v:searchforward] 12 | nnoremap N 'nN'[v:searchforward] 13 | nnoremap k (v:count > 1 ? "m'" . v:count : '') . 'k' 14 | nnoremap j (v:count > 1 ? "m'" . v:count : '') . 'j' 15 | nnoremap rl :source ~/.vimrc 16 | nnoremap Y y$ 17 | " no overwrite paste 18 | xnoremap p "_dP 19 | " clear highlight update diff 20 | nnoremap :let @/=''=has('diff')?'diffupdate':'' 21 | " some shortcut for git 22 | nnoremap gci :Gcommit -v 23 | nnoremap gca :Gcommit -a -v 24 | nnoremap gcc :Gcommit -v -- =expand('%') 25 | nnoremap gp :CocCommand git.push 26 | " }} 27 | 28 | " insert keymap like emacs {{ 29 | inoremap diwa 30 | inoremap 31 | inoremap 32 | inoremap u 33 | inoremap 34 | inoremap pumvisible() ? "\" : "\" 35 | 36 | " command line alias {{ 37 | cnoremap w!! w !sudo tee % >/dev/null 38 | cnoremap 39 | cnoremap 40 | cnoremap 41 | cnoremap 42 | cnoremap 43 | cnoremap 44 | cnoremap 45 | cnoremap 46 | cnoremap 47 | cnoremap 48 | cnoremap =expand("%:p:h") . "/" 49 | " }} 50 | 51 | " meta keys {{ 52 | vnoremap "+y 53 | inoremap "+]p 54 | nnoremap :qa! 55 | nnoremap :silent! wa 56 | inoremap :w 57 | nnoremap 1gt 58 | nnoremap 2gt 59 | nnoremap 3gt 60 | nnoremap 4gt 61 | nnoremap 5gt 62 | inoremap 1gt 63 | inoremap 2gt 64 | inoremap 3gt 65 | inoremap 4gt 66 | inoremap 5gt 67 | " }} 68 | 69 | " plugins {{ 70 | " buftabline 71 | nnoremap 1 1gt 72 | nnoremap 2 2gt 73 | nnoremap 3 3gt 74 | nnoremap 4 4gt 75 | nnoremap 5 5gt 76 | nnoremap 6 6gt 77 | nnoremap 7 7gt 78 | nnoremap 8 8gt 79 | 80 | " vim-exchange 81 | xmap x (Exchange) 82 | 83 | " coc.nvim 84 | nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" 85 | nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" 86 | inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" 87 | inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" 88 | 89 | nmap :call CocAction('runCommand', 'document.renameCurrentWord') 90 | nmap (coc-cursors-position) 91 | nmap (coc-cursors-word) 92 | xmap (coc-cursors-range) 93 | nmap (coc-range-select) 94 | xmap (coc-range-select) 95 | xmap (coc-range-select-backword) 96 | xmap (coc-repl-sendtext) 97 | nmap s (coc-smartf-forward) 98 | nmap S (coc-smartf-backward) 99 | nmap [g (coc-git-prevchunk) 100 | nmap ]g (coc-git-nextchunk) 101 | nmap gs (coc-git-chunkinfo) 102 | nmap gm (coc-git-commit) 103 | imap (coc-snippets-expand) 104 | xmap (coc-snippets-select) 105 | nmap [c (coc-diagnostic-prev) 106 | nmap ]c (coc-diagnostic-next) 107 | nmap gt :call CocActionAsync('jumpDefinition', 'tabe') 108 | nmap gd (coc-definition) 109 | nmap gy :call CocActionAsync('jumpTypeDefinition', v:false) 110 | nmap gi :call CocActionAsync('jumpImplementation', v:false) 111 | nmap gr :call CocActionAsync('jumpUsed', v:false) 112 | nnoremap K :call CocActionAsync('doHover') 113 | " remap for complete to use tab and 114 | inoremap 115 | \ pumvisible() ? "\" : 116 | \ check_back_space() ? "\" : 117 | \ coc#refresh() 118 | inoremap coc#refresh() 119 | inoremap pumvisible() ? "\" : "\" 120 | inoremap pumvisible() ? coc#_select_confirm() : "\u\\=coc#on_enter()\" 121 | xmap if (coc-funcobj-i) 122 | xmap af (coc-funcobj-a) 123 | omap if (coc-funcobj-i) 124 | omap af (coc-funcobj-a) 125 | omap ig (coc-git-chunk-inner) 126 | xmap ig (coc-git-chunk-inner) 127 | omap ag (coc-git-chunk-outer) 128 | xmap ag (coc-git-chunk-outer) 129 | " }} 130 | 131 | " visual search {{ 132 | " In visual mode when you press * or # to search for the current selection 133 | xnoremap * :call visualSearch('f') 134 | xnoremap # :call visualSearch('b') 135 | " }} 136 | 137 | " functions {{ 138 | function! s:visualSearch(direction) 139 | let l:saved_reg = @" 140 | execute 'normal! vgvy' 141 | let l:pattern = escape(@", '\\/.*$^~[]') 142 | let l:pattern = substitute(l:pattern, "\n$", '', '') 143 | if a:direction ==# 'b' 144 | execute 'normal! ?' . l:pattern . "\" 145 | elseif a:direction ==# 'f' 146 | execute 'normal! /' . l:pattern . '^M' 147 | endif 148 | let @/ = l:pattern 149 | let @" = l:saved_reg 150 | endfunction 151 | 152 | function! s:check_back_space() abort 153 | let col = col('.') - 1 154 | return !col || getline('.')[col - 1] =~# '\s' 155 | endfunction 156 | " }} 157 | 158 | " list {{ 159 | nnoremap \r :CocList -N mru -A 160 | nnoremap h :CocList helptags 161 | nnoremap g :CocList gstatus 162 | nnoremap t :CocList buffers 163 | nnoremap y :CocList yank 164 | nnoremap u :CocList snippets 165 | nnoremap w :exe 'CocList -A -I --normal --input='.expand('').' words -w' 166 | nnoremap l :CocList -I --ignore-case lines 167 | nnoremap q :CocList quickfix 168 | nnoremap a :CocList diagnostics 169 | nnoremap e :CocList extensions 170 | nnoremap c :CocList commands 171 | nnoremap o :CocList outline 172 | nnoremap s :CocList symbols 173 | nnoremap r :CocList mru 174 | nnoremap f :CocList files 175 | nnoremap j :CocNext 176 | nnoremap k :CocPrev 177 | nnoremap p :CocListResume 178 | " }} 179 | -------------------------------------------------------------------------------- /statusline.vim: -------------------------------------------------------------------------------- 1 | function! MyStatusLine() 2 | return s:GetPaste() 3 | \. "%4*%{MyStatusGit()}%*" 4 | \. "%5*%{MyStatusGitChanges()}%* %{MyStatusCoc()} " 5 | \. "%6*%{get(b:, 'coc_current_function', '')}%*" 6 | \. " %f %{MyStatusModifySymbol()}" 7 | \. " %{MyStatusReadonly()}" 8 | \. "%=%-{&ft} %l,%c %P " 9 | "%{&fenc} 10 | endfunction 11 | 12 | function! s:IsTempFile() 13 | if !empty(&buftype) | return 1 | endif 14 | if &previewwindow | return 1 | endif 15 | let filename = expand('%:p') 16 | if filename =~# '^/tmp' | return 1 | endif 17 | if filename =~# '^fugitive:' | return 1 | endif 18 | return 0 19 | endfunction 20 | 21 | function! s:GetPaste() 22 | if !&paste | return '' |endif 23 | return "%#MyStatusPaste# paste %*" 24 | endfunction 25 | 26 | function! MyStatusReadonly() 27 | if !&readonly | return '' |endif 28 | return "  " 29 | endfunction 30 | 31 | function! MyStatusCoc() 32 | if get(g:, 'did_coc_loaded', 0) 33 | return coc#status() 34 | endif 35 | return '' 36 | endfunction 37 | 38 | function! MyStatusModifySymbol() 39 | return &modified ? '⚡' : '' 40 | endfunction 41 | 42 | function! MyStatusGitChanges() abort 43 | if s:IsTempFile() | return '' | endif 44 | return get(b:, 'coc_git_status', '') 45 | endfunction 46 | 47 | function! MyStatusGit(...) abort 48 | let status = get(g:, 'coc_git_status', '') 49 | return empty(status) ? '' : ' '.status.' ' 50 | endfunction 51 | 52 | function! SetStatusLine() 53 | if &previewwindow | return | endif 54 | if s:IsTempFile() | return | endif 55 | setl statusline=%!MyStatusLine() 56 | hi User6 guifg=#fe8019 guibg=#282828 gui=none 57 | hi User3 guifg=#e03131 guibg=#111111 gui=none 58 | hi MyStatusPaste guifg=#F8F8F0 guibg=#FF5F00 gui=none 59 | hi MyStatusPaste ctermfg=202 ctermbg=16 cterm=none 60 | hi User4 guifg=#f8f8ff guibg=#000000 61 | hi User5 guifg=#f8f9fa guibg=#343a40 62 | endfunction 63 | 64 | augroup statusline 65 | autocmd! 66 | autocmd BufEnter,BufNewFile,BufReadPost,ShellCmdPost,BufWritePost * call SetStatusLine() 67 | autocmd FileChangedShellPost,ColorScheme * call SetStatusLine() 68 | augroup end 69 | -------------------------------------------------------------------------------- /tabline.vim: -------------------------------------------------------------------------------- 1 | let s:time = '' 2 | let s:file_node_extensions = { 3 | \ 'rust' : '', 4 | \ 'styl' : '', 5 | \ 'scss' : '', 6 | \ 'htm' : '', 7 | \ 'html' : '', 8 | \ 'erb' : '', 9 | \ 'slim' : '', 10 | \ 'ejs' : '', 11 | \ 'wxml' : '', 12 | \ 'css' : '', 13 | \ 'less' : '', 14 | \ 'wxss' : '', 15 | \ 'md' : '', 16 | \ 'markdown' : '', 17 | \ 'json' : '', 18 | \ 'js' : '', 19 | \ 'jsx' : '', 20 | \ 'rb' : '', 21 | \ 'php' : '', 22 | \ 'py' : '', 23 | \ 'pyc' : '', 24 | \ 'pyo' : '', 25 | \ 'pyd' : '', 26 | \ 'coffee' : '', 27 | \ 'mustache' : '', 28 | \ 'hbs' : '', 29 | \ 'conf' : '', 30 | \ 'ini' : '', 31 | \ 'yml' : '', 32 | \ 'bat' : '', 33 | \ 'jpg' : '', 34 | \ 'jpeg' : '', 35 | \ 'bmp' : '', 36 | \ 'png' : '', 37 | \ 'gif' : '', 38 | \ 'ico' : '', 39 | \ 'twig' : '', 40 | \ 'cpp' : '', 41 | \ 'c++' : '', 42 | \ 'cxx' : '', 43 | \ 'cc' : '', 44 | \ 'cp' : '', 45 | \ 'c' : '', 46 | \ 'hs' : '', 47 | \ 'lhs' : '', 48 | \ 'lua' : '', 49 | \ 'java' : '', 50 | \ 'sh' : '', 51 | \ 'fish' : '', 52 | \ 'ml' : 'λ', 53 | \ 'mli' : 'λ', 54 | \ 'diff' : '', 55 | \ 'db' : '', 56 | \ 'sql' : '', 57 | \ 'dump' : '', 58 | \ 'clj' : '', 59 | \ 'cljc' : '', 60 | \ 'cljs' : '', 61 | \ 'edn' : '', 62 | \ 'scala' : '', 63 | \ 'go' : '', 64 | \ 'dart' : '', 65 | \ 'xul' : '', 66 | \ 'sln' : '', 67 | \ 'suo' : '', 68 | \ 'pl' : '', 69 | \ 'pm' : '', 70 | \ 't' : '', 71 | \ 'rss' : '', 72 | \ 'f#' : '', 73 | \ 'fsscript' : '', 74 | \ 'fsx' : '', 75 | \ 'fs' : '', 76 | \ 'fsi' : '', 77 | \ 'rs' : '', 78 | \ 'rlib' : '', 79 | \ 'd' : '', 80 | \ 'erl' : '', 81 | \ 'hrl' : '', 82 | \ 'vim' : '', 83 | \ 'ai' : '', 84 | \ 'psd' : '', 85 | \ 'psb' : '', 86 | \ 'ts' : '', 87 | \ 'tsx' : '', 88 | \ 'jl' : '' 89 | \} 90 | 91 | let s:file_node_exact_matches = { 92 | \ 'exact-match-case-sensitive-1.txt' : 'X1', 93 | \ 'exact-match-case-sensitive-2' : 'X2', 94 | \ 'gruntfile.coffee' : '', 95 | \ 'gruntfile.js' : '', 96 | \ 'gruntfile.ls' : '', 97 | \ 'gulpfile.coffee' : '', 98 | \ 'gulpfile.js' : '', 99 | \ 'gulpfile.ls' : '', 100 | \ 'dropbox' : '', 101 | \ '.ds_store' : '', 102 | \ '.gitconfig' : '', 103 | \ '.gitignore' : '', 104 | \ '.bashrc' : '', 105 | \ '.bashprofile' : '', 106 | \ 'favicon.ico' : '', 107 | \ 'license' : '', 108 | \ 'node_modules' : '', 109 | \ 'react.jsx' : '', 110 | \ 'Procfile' : '', 111 | \ '.vimrc' : '', 112 | \} 113 | 114 | let s:file_node_pattern_matches = { 115 | \ '.*jquery.*\.js$' : '', 116 | \ '.*angular.*\.js$' : '', 117 | \ '.*backbone.*\.js$' : '', 118 | \ '.*require.*\.js$' : '', 119 | \ '.*materialize.*\.js$' : '', 120 | \ '.*materialize.*\.css$' : '', 121 | \ '.*mootools.*\.js$' : '' 122 | \} 123 | 124 | let s:colors = { 125 | \ 'null': ['black', '#ffffff', '#000000'], 126 | \ 'inactive': ['#ebdbb2', 'lightgray', 'black'], 127 | \ 'active': ['lightgray', 'darkgray', '#000000'], 128 | \ 'inactive_mod': ['#458588', '#d3869d', '#000000'], 129 | \ 'active_mod': ['#d3869d', '#458588', '#000000'], 130 | \ 'inactive_ro': ['darkred', 'lightred', 'black'], 131 | \ 'active_ro': ['lightred', 'darkred', '#000000'], 132 | \ } 133 | 134 | function! s:init_colors() 135 | for l:a in keys(s:colors) 136 | for l:b in keys(s:colors) 137 | if s:colors[l:a][0] == s:colors[l:b][0] 138 | exec 'hi TabLineSep'.l:a.b.' guibg='.s:colors[l:a][0].' guifg='.s:colors[l:a][2] 139 | else 140 | exec 'hi TabLineSep'.l:a.b.' guibg='.s:colors[l:a][0].' guifg='.s:colors[l:b][0] 141 | endif 142 | endfor 143 | exec 'hi TabLine'.l:a.' guibg='.s:colors[l:a][0].' guifg='.s:colors[l:a][1] 144 | endfor 145 | endfunction 146 | 147 | set tabline=%!MyTabLine() 148 | 149 | function! GetFileIcon(path) 150 | let file = fnamemodify(a:path, ':t') 151 | if has_key(s:file_node_exact_matches, file) 152 | return s:file_node_exact_matches[file] 153 | endif 154 | for [k, v] in items(s:file_node_pattern_matches) 155 | if match(file, k) != -1 156 | return v 157 | endif 158 | endfor 159 | let ext = fnamemodify(file, ':e') 160 | if has_key(s:file_node_extensions, ext) 161 | return s:file_node_extensions[ext] 162 | endif 163 | return '' 164 | endfunction 165 | 166 | function! MyTabLabel(n) 167 | let buflist = tabpagebuflist(a:n) 168 | let winnr = tabpagewinnr(a:n) 169 | let name = bufname(buflist[winnr - 1]) 170 | let full_path = fnamemodify(name, ':p') 171 | let icon = GetFileIcon(full_path) 172 | if empty(name) 173 | return '[No Name]' 174 | else 175 | return a:n . ' '. icon.' '.fnamemodify(name, ':t') 176 | endif 177 | endfunction 178 | 179 | function! CurrentTime(...) 180 | call jobstart("date '+%H:%M %m-%d' | tr -d '\n'", { 181 | \ 'stdout_buffered': 1, 182 | \ 'on_stdout': function('s:OnStdout') 183 | \}) 184 | endfunction 185 | 186 | function! s:OnStdout(id, data, event) dict 187 | let s:time = get(a:data, 0, '') 188 | endfunction 189 | 190 | function! s:start_timer() 191 | if !has('nvim') | return | endif 192 | call CurrentTime() 193 | call timer_start(60000, 'CurrentTime', {'repeat': -1}) 194 | endfunction 195 | 196 | function! MyTabLine() 197 | "if &buftype =~# '\v(help|nofile|terminal)' | return '' | endif 198 | let s = '' 199 | for i in range(tabpagenr('$')) 200 | " select the highlighting 201 | if i + 1 == tabpagenr() 202 | let s .= '%#TabLineSel#' 203 | else 204 | let s .= '%#TabLine#' 205 | endif 206 | " set the tab page number (for mouse clicks) 207 | let s .= '%' . (i + 1) . 'T' 208 | 209 | " the label is made by MyTabLabel() 210 | let s .= ' %{MyTabLabel(' . (i + 1) . ')} ' 211 | endfor 212 | " after the last tab fill with TabLineFill and reset tab page nr 213 | let s .= '%#TabLineFill#%T' 214 | let s .= ' %= ' 215 | let s .= '%#TabLineSepnullinactive# ' 216 | let s .= '%#TabLineSepinactiveinactive# ' 217 | let s .= s:time 218 | let s .= '%#TabLineSepinactiveinactive_mod# ' 219 | let s .= '%#TabLineSepinactive_modinactive_mod# ' 220 | let s .= get(g:, 'coc_weather', '') 221 | let s .= ' % ' 222 | return s 223 | endfunction 224 | 225 | call s:init_colors() 226 | call s:start_timer() 227 | --------------------------------------------------------------------------------