" vim: foldmethod=marker " __ ___ __ __ __ " \ \ / (_)_ __ _ _ __ / _|___ _ _ | \/ |___ _ __ _ __ " \ V /| | ' \| '_/ _| | _/ _ \ '_| | |\/| / _ \ '_ \ '_ \ " \_/ |_|_|_|_|_| \__| |_| \___/_| |_| |_\___/ .__/ .__/ " |_| |_| set nocompatible " Encoding. {{{ if has('vim_starting') " Changing encoding in Vim at runtime is undefined behavior. set encoding=utf-8 set fileencodings=utf-8,sjis,cp932,euc-jp set fileformats=unix,mac,dos endif " This command has to be after `set encoding`. scriptencoding utf-8 " }}} " Indent. {{{ set autoindent set backspace=2 set breakindent set expandtab set shiftwidth=4 set smartindent set tabstop=4 " }}} " Appearance. {{{ set ambiwidth=double set cmdheight=2 set conceallevel=2 set cursorline set display=lastline set laststatus=2 set list set listchars=tab:>\ ,trail:\ ,extends:<,precedes:< set noarabicshape set nowrap set number set relativenumber set scrolloff=3 set showcmd set showmatch set showtabline=2 set signcolumn=yes set statusline=%<%F\ %m%r%h%w%y%{'['.(&fenc!=''?&fenc:&enc).']['.&fileformat.']'}%=%l/%L,%c%V%8P set synmaxcol=512 " }}} " Folding. {{{ set foldenable set foldcolumn=1 set foldmethod=indent set foldtext=Mopp_fold_text() set foldmarker=\ {{{,\ }}} " }}} " Safety. {{{ set backup set backupdir=~/.vim/backup set directory=~/.vim/swap set swapfile set writebackup " }}} " History {{{ set history=2048 set undodir=~/.vim/undo set undofile set viewoptions=cursor,folds " }}} " Search. {{{ set hlsearch set ignorecase set incsearch set path=.,/usr/local/include,/usr/include,./include set smartcase " }}} " Others. {{{ set splitright set belloff=all set completeopt=menu set dictionary=/usr/share/dict/words set formatoptions+=tjrol set helplang=ja set langnoremap set lazyredraw set matchpairs+=<:> set mouse= set regexpengine=2 set updatetime=500 set virtualedit=block set whichwrap=b,s,h,l,<,>,[,] set wildignorecase set wildmenu set virtualedit=all " Turn off default plugins. {{{ let g:loaded_2html_plugin = 1 let g:loaded_gzip = 1 let g:loaded_rrhelper = 1 let g:loaded_tar = 1 let g:loaded_tarPlugin = 1 let g:loaded_vimballPlugin = 1 let g:loaded_zip = 1 let g:loaded_zipPlugin = 1 let g:loaded_matchparen = 1 " }}} " Configs for default scripts. {{{ let g:lisp_rainbow = 1 let g:lisp_instring = 1 let g:lispsyntax_clisp = 1 let g:c_syntax_for_h = 1 let g:tex_conceal = '' let g:tex_flavor = 'latex' " }}} " }}} " Mappings. {{{ "---------------------------------------------------------------------------" " Commands \ Modes | Normal | Insert | Command | Visual | Select | Operator | "------------------|--------|--------|---------|--------|--------|----------| " map / noremap | @ | - | - | @ | @ | @ | " nmap / nnoremap | @ | - | - | - | - | - | " vmap / vnoremap | - | - | - | @ | @ | - | " omap / onoremap | - | - | - | - | - | @ | " xmap / xnoremap | - | - | - | @ | - | - | " smap / snoremap | - | - | - | - | @ | - | " map! / noremap! | - | @ | @ | - | - | - | " imap / inoremap | - | @ | - | - | - | - | " cmap / cnoremap | - | - | @ | - | - | - | "---------------------------------------------------------------------------" " Set and . let g:mapleader = ' ' let g:maplocalleader = '\' noremap j gj noremap k gk noremap ; : noremap : ; " Avoiding getting from . map map! " Movings. noremap! noremap! noremap! noremap! noremap! noremap! noremap! cnoremap cnoremap noremap G noremap gg noremap ^ noremap ^ noremap $ " Switching buffer. nnoremap [B :bfirst nnoremap ]B :blast nnoremap [b :bprevious nnoremap ]b :bnext " Managing tab. nnoremap to :tabnew nnoremap tc :tabclose nnoremap j gT nnoremap k gt " Spliting window. nnoremap sp :split nnoremap vsp :vsplit " Changing window size. noremap :wincmd < noremap :wincmd > noremap :wincmd - noremap :wincmd + " Yank & Paste {{{ function! s:paste_with_register(register, paste_type, paste_cmd) abort " {{{ let l:reg_type = getregtype(a:register) let l:store = getreg(a:register) call setreg(a:register, l:store, a:paste_type) exe 'normal! "' . a:register . a:paste_cmd call setreg(a:register, l:store, l:reg_type) endfunction " }}} function! s:copy_to_clipboard() abort " {{{ let l:store = @@ silent normal! gvy let l:selected = @@ let @@ = l:store let @+ = l:selected let @* = l:selected endfunction " }}} nnoremap Y y$ nnoremap pp :set paste! xnoremap mY :call copy_to_clipboard() nnoremap mlp :call paste_with_register('+', 'l', 'p') nnoremap mlP :call paste_with_register('+', 'l', 'P') nnoremap mcp :call paste_with_register('+', 'c', 'p') nnoremap mcP :call paste_with_register('+', 'c', 'P') nnoremap mp :call paste_with_register('+', 'l', 'p') " }}} " Open help of a word under the cursor. nnoremap hh :help nnoremap ht :tab help " Adding blank lines. nnoremap :for i in range(1, v:count1) \| call append(line('.'), '') \| endfor nnoremap O :for i in range(1, v:count1) \| call append(line('.')-1, '') \| endfor " Change current directory of current window. nnoremap cd :lcd %:p:h " Open list if there are multiple tags. nnoremap gzz " Tab version ``. nnoremap T " Repeat the previous macro. nnoremap Q @@ " Search something in the current visual range only. vnoremap /\%V " Replace the all selected areas. vnoremap "hy:%s/\Vh//g " Turn off highlight of the current search words. nnoremap :nohlsearch " Save the current buffer. nnoremap w :write " Open vimrc at newtab. if has('nvim') nnoremap ev :tab drop $MYVIMRC else " The `drop` is available on gvim or neovim. nnoremap ev :tabnew $MYVIMRC endif " Tab version `gf`. nnoremap gtf :execute 'tabnew' printf('%s/%s', expand('%:h'), expand('')) " Keep indent nnoremap i empty(getline('.')) ? 'S' : 'i' " }}} " Functions {{{ function! Mopp_fold_text() abort " {{{ let l:head = getline(v:foldstart) if &foldmethod !=# 'marker' let l:head = '+' . repeat('-', &shiftwidth * v:foldlevel - 2) . ' ' . substitute(l:head, '^\s*', '', '') endif let l:tail = printf('[ %2d Lines Lv%02d ]', (v:foldend - v:foldstart + 1), v:foldlevel) let l:count_columns = &foldcolumn + (&number ? max([&numberwidth, strdisplaywidth(line('$'))]) : 0) + (&signcolumn ==# 'no' ? 0 : 2) let l:spaces = repeat(' ', winwidth(0) - l:count_columns - strdisplaywidth(l:head) - strdisplaywidth(l:tail)- 1) return l:head . l:spaces . l:tail endfunction " }}} function! s:remove_tail_spaces() abort " {{{ if &filetype ==# 'markdown' return endif let l:c = getpos('.') g/.*\s$/normal $gelD call setpos('.', l:c) endfunction " }}} " }}} " Commands. {{{ " Reload .vimrc command! ReloadVimrc :source $MYVIMRC command! -nargs=1 -complete=buffer TabBuffer :tab sbuffer command! SpellCheckToggle :setlocal spell! " Echo highlight name of an object under the cursor. command! EchoHiID echomsg synIDattr(synID(line('.'), col('.'), 1), 'name') " Convert number expression. {{{ let s:format = { 2: '0b%b', 8: '0o%o', 10: '%d', 16: '0x%x' } function! s:eval_as_base_number(base, exp) abort " {{{ let result = eval(a:exp) if type(0) != type(result) throw 'The result of the given expression have to be Number' endif return printf(s:format[a:base], result) endfunction " }}} command! -nargs=1 EvalAsBin echomsg eval_as_base_number(2, ) command! -nargs=1 EvalAsOct echomsg eval_as_base_number(8, ) command! -nargs=1 EvalAsDec echomsg eval_as_base_number(10, ) command! -nargs=1 EvalAsHex echomsg eval_as_base_number(16, ) inoremap b eval_as_base_number(2, input('= ')) inoremap o eval_as_base_number(8, input('= ')) inoremap d eval_as_base_number(10, input('= ')) inoremap h eval_as_base_number(16, input('= ')) imap b imap o imap d imap h " }}} " Keep last session. {{{ let s:session_directory = '~/.vim/sessions/' let s:last_session_filepath = s:session_directory . 'last_session.vim' function! s:save_session(...) abort execute 'mksession!' (a:0 == 0) ? (s:last_session_filepath) : (s:session_directory . a:1) endfunction function! s:get_session_list(arguments, cmd_line, cursor_pos) abort let l:filepaths = split(glob(s:session_directory . '*.vim'), '\n') return map(l:filepaths, {i, v -> fnamemodify(v, ':t')}) endfunction command! -nargs=0 LoadLastSession execute 'source' s:last_session_filepath command! -nargs=? -complete=customlist,get_session_list SaveSession call save_session() " }}} " Create Vim directories if not found. {{{ command! -nargs=0 CreateVimDirectories call s:create_vim_directories() function! s:create_vim_directories() abort let base_dir = fnamemodify($MYVIMRC, ':h') . '/' call s:mkdir_if_not_exist(base_dir . 'sessions') call s:mkdir_if_not_exist(base_dir . 'undo') call s:mkdir_if_not_exist(base_dir . 'backup') call s:mkdir_if_not_exist(base_dir . 'swap') endfunction function! s:mkdir_if_not_exist(path) abort if !isdirectory(a:path) call mkdir(a:path) endif endfunction " }}} command! -nargs=0 StoreTargetWin let t:target_window = win_getid() command! -nargs=0 JumpTargetWin call win_gotoid(t:target_window) nnoremap ' :JumpTargetWin " }}} " GUI. {{{ if has('gui_running') let g:no_buffers_menu = 1 set guioptions-=emTrlL set mousehide set visualbell set t_vb= if has('mac') set macmeta set guifont=Ricty-Regular:h13 else set guifont=Ricty\ 12 set lines=40 set columns=120 endif endif " }}} " Autocommands. {{{ augroup mopp autocmd! " Save session automatically. autocmd VimLeave * execute 'mksession!' s:last_session_filepath " Turning off paste when escape insert mode. autocmd InsertLeave * setlocal nopaste " Store and load view. autocmd BufWinLeave * if (bufname('%') != '') | mkview! | endif autocmd BufWinEnter * if (bufname('%') != '') | silent! loadview | endif " Remove spaces at tail. autocmd BufWritePre * silent call s:remove_tail_spaces() " Detecting filetypes. autocmd BufWinEnter *.nas nested setlocal filetype=nasm autocmd BufWinEnter *.plt nested setlocal filetype=gnuplot autocmd BufWinEnter *.sh nested setlocal filetype=sh autocmd BufWinEnter *.toml nested setlocal filetype=toml autocmd BufWinEnter *.{md,mdwn,mkd,mkdn} nested setlocal filetype=markdown autocmd BufWinEnter *.{pde,ino} nested setlocal filetype=arduino autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu | set relativenumber | endif autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set norelativenumber | endif if executable('fcitx-remote') autocmd InsertLeave,CmdLineLeave * call system('fcitx-remote -c') endif augroup END " }}} " Neovim. {{{ if has('nvim') set inccommand=split tnoremap nnoremap tm :terminal nnoremap vst :vsplit term://zsh nnoremap vtt :tabnew term://zsh autocmd TermOpen * setlocal nonumber norelativenumber nowrap if has('mac') let g:python_host_prog = '/usr/local/bin/python2' let g:python3_host_prog = '/usr/local/bin/python3' endif endif " }}} " Plugins. {{{ " dein.vim {{{ let s:dein_base_path = expand('~/.vim/bundle/') let s:dein_path = s:dein_base_path . 'repos/github.com/Shougo/dein.vim' let s:has_dein = isdirectory(s:dein_path) let &runtimepath .= ',' . s:dein_path if s:has_dein && dein#load_state(s:dein_base_path) " {{{ call dein#begin(s:dein_base_path) call dein#add('Shougo/dein.vim') call dein#add('haya14busa/dein-command.vim') " Completions {{{ call dein#add('Shougo/deoplete.nvim', {'lazy': 1, 'on_event': 'InsertEnter'}) if !has('nvim') call dein#add('roxma/nvim-yarp') call dein#add('roxma/vim-hug-neovim-rpc') endif let s:lazy_plete = {'lazy': 1, 'on_source': ['deoplete.nvim']} call dein#add('Shougo/neco-syntax', s:lazy_plete) call dein#add('Shougo/neco-vim', s:lazy_plete) call dein#add('Shougo/neoinclude.vim', s:lazy_plete) call dein#add('Shougo/neosnippet-snippets') call dein#add('Shougo/neosnippet.vim', s:lazy_plete) call dein#add('carlitux/deoplete-ternjs', s:lazy_plete) call dein#add('fishbullet/deoplete-ruby') call dein#add('honza/vim-snippets', s:lazy_plete) call dein#add('racer-rust/vim-racer') call dein#add('sebastianmarkow/deoplete-rust') call dein#add('ujihisa/neco-look') call dein#add('zchee/deoplete-clang') " }}} " Denite {{{ call dein#add('Shougo/denite.nvim') call dein#add('Shougo/neomru.vim') call dein#add('neoclide/denite-git') call dein#add('rafi/vim-denite-session') " }}} " Operators and textobjs {{{ call dein#add('haya14busa/vim-operator-flashy', {'lazy': 1, 'on_map': ''}) call dein#add('kana/vim-operator-replace', {'lazy': 1, 'on_map': ''}) call dein#add('kana/vim-operator-user') call dein#add('mopp/vim-operator-convert-case', {'lazy': 1, 'on_map': ''}) call dein#add('kana/vim-textobj-indent', {'lazy': 1, 'on_map': [['ox', 'ai' , 'ii' , 'aI', 'iI']]}) call dein#add('kana/vim-textobj-line', {'lazy': 1, 'on_map': [['ox', 'al', 'il']]}) call dein#add('kana/vim-textobj-user') call dein#add('rhysd/vim-textobj-word-column', {'lazy': 1, 'on_map': [['ox', 'av', 'iv']]}) call dein#add('sgur/vim-textobj-parameter', {'lazy': 1, 'on_map': [['ox', 'a,', 'i,', 'i2,']]}) call dein#add('machakann/vim-sandwich') " }}} " Utils {{{ call dein#add('Chiel92/vim-autoformat', {'lazy': 1, 'on_cmd': 'Autoformat'}) call dein#add('FooSoft/vim-argwrap', {'lazy': 1, 'on_cmd': 'ArgWrap'}) call dein#add('Konfekt/FastFold') call dein#add('LeafCage/yankround.vim', {'lazy': 1, 'on_map': ''}) call dein#add('Shougo/deol.nvim', {'lazy': 1, 'on_cmd': ['Deol', 'DeolCd', 'DeolEdit']}) call dein#add('Shougo/echodoc.vim', {'lazy': 1, 'on_event': 'InsertEnter'}) call dein#add('Shougo/junkfile.vim', {'lazy': 1, 'on_cmd': 'JunkfileOpen', 'on_func': 'junkfile'}) call dein#add('Shougo/vinarise.vim', {'lazy':1, 'on_cmd': 'Vinarise'}) call dein#add('Yggdroot/indentLine') call dein#add('airblade/vim-gitgutter') call dein#add('bronson/vim-trailing-whitespace') call dein#add('chrisbra/Colorizer', {'lazy': 1, 'on_cmd': 'ColorToggle'}) call dein#add('cocopon/vaffle.vim', {'lazy': 1, 'on_cmd': 'Vaffle'}) call dein#add('cohama/agit.vim', {'lazy': 1, 'on_cmd': 'Agit'}) call dein#add('cohama/lexima.vim',{'lazy': 1, 'on_event': 'InsertEnter', 'hook_post_source': 'call Hook_on_post_source_lexima()'}) call dein#add('easymotion/vim-easymotion', {'lazy': 1, 'on_map': ''}) call dein#add('editorconfig/editorconfig-vim', {'lazy': 1, 'on_cmd': 'EditorConfigReload'}) call dein#add('idanarye/vim-casetrate', {'lazy': 1, 'on_cmd': 'Casetrate'}) call dein#add('inside/vim-search-pulse') call dein#add('itchyny/lightline.vim') call dein#add('itchyny/vim-parenmatch') call dein#add('jsfaint/gen_tags.vim', {'lazy': 1, 'on_cmd': ['GenGTAGS', 'GenCtags']}) call dein#add('junegunn/vim-easy-align', {'lazy': 1, 'on_cmd': 'EasyAlign', 'on_map': ['(LiveEasyAlign)', '(EasyAlign)']}) call dein#add('kana/vim-niceblock', {'lazy': 1, 'on_map': [['x', 'I', 'A']]}) call dein#add('kana/vim-tabpagecd') call dein#add('kannokanno/previm', {'lazy': 1, 'on_cmd': 'PrevimOpen', 'on_ft': 'markdown'}) call dein#add('lambdalisue/gina.vim', {'lazy': 1, 'on_cmd': 'Gina', 'on_event': 'BufWritePost', 'hook_post_source': 'call Hook_on_post_source_gina()'}) call dein#add('luochen1990/rainbow') call dein#add('majutsushi/tagbar', {'lazy': 1, 'on_cmd': 'TagbarToggle'}) call dein#add('mattn/gist-vim', {'lazy': 1, 'on_cmd': 'Gist'}) call dein#add('mattn/learn-vimscript') call dein#add('mopp/autodirmake.vim', {'lazy': 1, 'on_event': 'InsertEnter'}) call dein#add('mopp/layoutplugin.vim', {'lazy': 1, 'on_cmd': 'LayoutPlugin'}) call dein#add('mopp/mopkai.vim') call dein#add('osyo-manga/vim-anzu') call dein#add('osyo-manga/vim-stargate', {'lazy': 1, 'on_cmd': 'StargateInclude'}) call dein#add('prakashdanish/vim-githubinator') call dein#add('rhysd/accelerated-jk', {'lazy': 1, 'on_map': ''}) call dein#add('rickhowe/diffchar.vim', {'lazy': &diff == 0, 'on_if': '&diff'}) call dein#add('szw/vim-maximizer', {'lazy': 1, 'on_cmd': 'MaximizerToggle'}) call dein#add('t9md/vim-choosewin', {'lazy': 1, 'on_map': {'n': ''}}) call dein#add('t9md/vim-quickhl', {'lazy': 1, 'on_map' : {'nx': ''}}) call dein#add('thinca/vim-visualstar') call dein#add('tpope/vim-repeat') call dein#add('tyru/capture.vim', {'lazy': 1, 'on_cmd': 'Capture'}) call dein#add('tyru/caw.vim', {'lazy': 1, 'on_map': '(caw:', 'hook_post_source': 'doautocmd plugin FileType'}) call dein#add('tyru/open-browser.vim', {'lazy': 1, 'on_map': [['n', '(openbrowser-open)']], 'on_func': ['openbrowser#load', 'openbrowser#open']}) call dein#add('w0rp/ale', {'lazy': 1, 'on_event': 'BufWritePost'}) " }}} " Languages {{{ call dein#add('Shirk/vim-gas') call dein#add('cespare/vim-toml') call dein#add('derekwyatt/vim-scala', {'lazy': 1, 'on_ft': 'scala'}) call dein#add('digitaltoad/vim-pug') call dein#add('ekalinin/Dockerfile.vim') call dein#add('elzr/vim-json') call dein#add('hail2u/vim-css3-syntax') call dein#add('leafgarland/typescript-vim') call dein#add('othree/html5.vim') call dein#add('pangloss/vim-javascript') call dein#add('plasticboy/vim-markdown') call dein#add('rust-lang/rust.vim', {'lazy': 1, 'on_ft': 'rust'}) call dein#add('shima-529/C-prototype.vim', {'lazy': 1, 'on_ft': 'c'}) call dein#add('stephpy/vim-yaml') call dein#add('vim-erlang/vim-erlang-omnicomplete', {'lazy': 1, 'on_ft': 'erlang'}) call dein#add('vim-erlang/vim-erlang-runtime') call dein#add('vim-jp/cpp-vim') call dein#add('vim-jp/vimdoc-ja') call dein#add('vim-ruby/vim-ruby') call dein#add('vim-scripts/sh.vim--Cla') " }}} call dein#end() call dein#save_state() endif " }}} filetype plugin indent on " ftplugins are loaded when 'filetype on'. " The autocmds to override filetype local settings have to be executed after 'filetype on'. augroup mopp_filetype_overwrite " {{{ autocmd! autocmd FileType git setlocal nofoldenable autocmd FileType lisp setlocal nocindent nosmartindent lisp lispwords=define autocmd FileType text,man setlocal wrap autocmd FileType help setlocal foldcolumn=0 autocmd FileType ruby,javascript,typescript,html,css setlocal shiftwidth=2 augroup END " }}} if !s:has_dein " {{{ " Install all plugins. command! SetupPlugins call s:setup_plugins() function! s:setup_plugins() abort " {{{ if !executable('git') echoerr 'git is not found.' return endif call s:create_vim_directories() execute '!git clone --depth=1 https://github.com/Shougo/dein.vim' s:dein_path let &runtimepath .= ',' . s:dein_path let g:is_setup = 1 source $MYVIMRC call dein#install() unlet g:is_setup endfunction " }}} " Minimum settings. syntax enable colorscheme desert finish elseif exists('g:is_setup') finish endif " }}} " }}} " Command to stop some features which affect performance. command! Accelerate call s:accelerate() function! s:accelerate() abort " {{{ IndentLinesDisable RainbowToggleOff ALEDisable set nocursorline endfunction " }}} " deoplete.nvim {{{ let g:deoplete#enable_at_startup = 1 " If the default sources are defined, some completions are not work. " let g:deoplete#sources = {} " let g:deoplete#sources._ = ['buffer'] " }}} " neosnippet.vim {{{ imap (neosnippet_expand_or_jump) smap (neosnippet_expand_or_jump) xmap (neosnippet_expand_target) let g:neosnippet#enable_snipmate_compatibility = 1 let g:neosnippet#scope_aliases = { \ 'stylus': 'stylus,css,scss', \ 'pug': 'jade', \ 'handlebars': 'handlebars,html' \ } " }}} " neomru.vim let g:neomru#file_mru_ignore_pattern = '^gina:\/\/.*$' " denite.nvim if dein#tap('denite.nvim') " {{{ nnoremap fb :Denite buffer nnoremap fe :Denite file/rec nnoremap ff :Denite file_mru nnoremap fd :Denite -default-action=tab_open directory_mru nnoremap fgg :Denite grep nnoremap fgw :DeniteCursorWord grep nnoremap fl :Denite line nnoremap fo :Denite outline nnoremap fre :Denite -resume call denite#custom#map('insert', '', '') call denite#custom#map('insert', '', '') call denite#custom#map('insert', '', '') call denite#custom#map('insert', '', '') call denite#custom#map('insert', '', '') call denite#custom#map('insert', '', '', 'noremap') call denite#custom#map('insert', '', '', 'noremap') call denite#custom#map('insert', '', '', 'noremap') call denite#custom#map('insert', '', '', 'noremap') call denite#custom#map('insert', '', '', 'noremap') call denite#custom#map('insert', '', '', 'noremap') call denite#custom#map('normal', 'v', '', 'noremap') call denite#custom#map('normal', 's', '', 'noremap') call denite#custom#option('default', { \ 'highlight_matched_char': 'Keyword', \ 'highlight_matched_range': 'None', \ 'statusline': v:false, \ }) call denite#custom#source('file_mru', 'matchers', ['matcher_fuzzy', 'sorter_rank', 'matcher_project_files']) if executable('rg') " {{{ " For ripgrep. call denite#custom#var('file/rec', 'command', ['rg', '--files', '--glob', '!.git', '']) call denite#custom#var('grep', 'command', ['rg']) call denite#custom#var('grep', 'default_opts', ['--vimgrep', '--no-heading']) call denite#custom#var('grep', 'recursive_opts', []) call denite#custom#var('grep', 'pattern_opt', ['--regexp']) call denite#custom#var('grep', 'separator', ['--']) call denite#custom#var('grep', 'final_opts', []) endif " }}} endif " }}} " vim-operator-flashy map y (operator-flashy) map Y (operator-flashy)$ let g:operator#flashy#group = 'Error' " operator-replace map _ (operator-replace) " operator-convert-case.vim {{{ nmap ,cl (operator-convert-case-lower-camel) nmap ,cu (operator-convert-case-upper-camel) nmap ,sl (operator-convert-case-lower-snake) nmap ,su (operator-convert-case-upper-snake) nmap ,tt (operator-convert-case-toggle-upper-lower) nmap ,ll (operator-convert-case-loop) nmap ,cc (operator-convert-case-convert) " }}} " yankround.vim {{{ let g:yankround_use_region_hl = 1 let g:yankround_region_hl_groupname = 'Error' nmap p (yankround-p) xmap p (yankround-p) nmap P (yankround-P) nmap gp (yankround-gp) xmap gp (yankround-gp) nmap gP (yankround-gP) nmap (yankround-prev) nmap (yankround-next) " }}} " echodoc.vim let g:echodoc_enable_at_startup = 1 " vim-gitgutter {{{ let g:gitgutter_map_keys = 0 nmap hs GitGutterStageHunk nmap hu GitGutterUndoHunk nmap hp GitGutterPrevHunk nmap hn GitGutterNextHunk " }}} " vim-trailing-whitespace let g:extra_whitespace_ignored_filetypes = [ 'denite', 'help', 'vaffle' ] " vim-easymotion map e (easymotion-prefix) " lightline.vim {{{ let g:lightline = { \ 'colorscheme': 'mopkai', \ 'active': { \ 'left': [['mode', 'denite', 'paste'], ['filename', 'modified'], ['readonly', 'spell'], ['git_status'], ['anzu']], \ 'right': [['fileencoding', 'fileformat', 'lineinfo'], ['filetype'], ['ale_status']], \ }, \ 'inactive': { \ 'left': [['filename', 'modified']], \ 'right': [['filetype']] \ }, \ 'tabline': { \ 'left': [['tabs']], \ 'right': [] \ }, \ 'tab': { \ 'active': ['tabnum', 'filename', 'modified'], \ 'inactive': ['tabnum', 'filename', 'modified'] \ }, \ 'tabline_separator': { 'left': '', 'right': '' }, \ 'tabline_subseparator': { 'left': '', 'right': '' }, \ 'component': { \ 'mode': '%{ get(g:lightline_plugin_modes, &filetype, lightline#mode()) }', \ 'denite': "%{ (&filetype !=# 'denite') ? '' : denite#get_status('raw_mode') }", \ 'modified': "%{ (LightlineIsVisible() && &modifiable) ? (&modified ? '[+]' : '[-]') : '' }", \ 'readonly': "%{ (LightlineIsVisible() && &readonly) ? 'RO' : '' }", \ 'git_status': "%{ (LightlineIsVisible() && dein#is_sourced('gina.vim')) ? printf('%s: [%s]', gina#component#repo#branch(), gina#component#status#preset()) : '' }", \ 'filetype': "%{ LightlineIsVisible() ? &filetype : '' }", \ 'fileencoding': "%{ LightlineIsVisible() ? (strlen(&fenc) ? &fenc : &enc) : '' }", \ 'fileformat': "%{ LightlineIsVisible() ? &fileformat : '' }", \ 'lineinfo': '%03l:%03v:%03p%%', \ }, \ 'component_visible_condition': { \ 'denite': "&filetype==# 'denite'", \ 'modified': 'LightlineIsVisible() && &modifiable', \ 'fileencoding': 'LightlineIsVisible()', \ 'fileformat': 'LightlineIsVisible()', \ }, \ 'component_function': { \ 'filename': 'LightlineFilename', \ 'anzu': 'anzu#search_status', \ 'ale_status': 'LightlineAleStatus', \ }, \ } let g:lightline_plugin_modes = {'denite': 'Denite', 'vaffle': 'Vaffle', 'tagbar': 'TagBar'} function! LightlineIsVisible() abort return (60 <= winwidth(0)) && (&filetype !~? 'vaffle\|tagbar\|denite\|help') endfunction function! LightlineFilename() abort " {{{ if &filetype ==# 'denite' return denite#get_status('sources') . ' [' . denite#get_status('linenr') . ']' elseif &filetype ==# 'tagbar' return g:lightline.fname else let l:t = expand('%:t') return l:t ==# '' ? '[No Name]' : l:t endif endfunction " }}} function! LightlineAleStatus() abort " {{{ if !dein#is_sourced('ale') || !LightlineIsVisible() return '' endif let l:cnt = ale#statusline#Count(bufnr('')) return printf('E:%d W:%d I:%d', l:cnt.error + l:cnt.style_error, l:cnt.warning + l:cnt.style_warning, l:cnt.info) endfunction " }}} " Colors {{{ let s:cp_fname_modi = ['#ffffff', '#080808', 231, 232] let s:cp_read_spell = ['#d70000', '#121212', 160, 233] let s:cp_git_status = ['#87afff', '#1c1c1c', 111, 234] let s:cp_anzu = ['#ff87af', '#303030', 211, 236] let s:cp_middle = ['#9e9e9e', '#444444', 247, 238] let s:cp_ale = ['#ff5f87', '#1c1c1c', 204, 234] let g:lightline#colorscheme#mopkai#palette = { \ 'normal': { \ 'left': [['#080808', '#00afff', 232, 39], s:cp_fname_modi, s:cp_read_spell, s:cp_git_status, s:cp_anzu], \ 'middle': [s:cp_middle], \ 'right': [['#ffffd7', '#1c1c1c', 230, 234], ['#875fd7', '#080808', 98, 232], s:cp_ale], \ 'warning': [['#9e9e9e', '#ffdf5f', 247, 221]], \ 'error': [['#eeeeee', '#d70000', 255, 160]] \ }, \ 'insert': { \ 'left': [['#080808', '#87ff00', 232, 118], s:cp_fname_modi, s:cp_read_spell, s:cp_git_status, s:cp_anzu], \ }, \ 'replace': { \ 'left': [['#080808', '#ff0087', 232, 198], s:cp_fname_modi, s:cp_read_spell, s:cp_git_status, s:cp_anzu], \ }, \ 'visual': { \ 'left': [['#080808', '#d7ff5f', 232, 191], s:cp_fname_modi, s:cp_read_spell, s:cp_git_status, s:cp_anzu], \ }, \ 'inactive': { \ 'left': [['#9e9e9e', '#080808', 247, 232]], \ 'middle': [s:cp_middle], \ 'right': [['#875fd7', '#080808', 98, 232]] \ }, \ 'tabline': { \ 'tabsel': [['#080808', '#ff0087', 232, 198]], \ 'left': [['#080808', '#c6c6c6', 232, 251]], \ 'middle': [['#080808', '#c6c6c6', 232, 251]], \ 'right': [['#080808', '#c6c6c6', 232, 251]], \ } \ } " }}} " }}} " vim-parenmatch let g:parenmatch_highlight = 0 hi link ParenMatch MatchParen " vim-easy-align xmap ga (EasyAlign) nmap ga (EasyAlign) " previm let g:previm_show_header = 0 " rainbow {{{ let g:rainbow_active = 1 let g:rainbow_conf = { \ 'guifgs' : [ '#666666', '#0087ff', '#ff005f', '#875fd7', '#d78700', '#00af87' ], \ 'ctermfgs': [ '242', '33', '197', '98', '172', '36' ], \ 'separately' : { \ '*': {}, 'vim': {}, \ 'css': 0, 'perl': 0, 'html': 0, 'handlebars': 0, 'xml': 0 \ }, \ } " }}} " tagbar {{{ let g:tagbar_autoshowtag = 1 let g:tagbar_autofocus = 1 let g:tagbar_sort = 0 let g:tagbar_compact = 1 nnoremap tb :TagbarToggle function! Tagbar_status_func(current, sort, fname, ...) abort let g:lightline.fname = a:fname return lightline#statusline(0) endfunction let g:tagbar_status_func = 'Tagbar_status_func' " }}} " gist-vim let g:gist_detect_filetype = 1 let g:gist_open_browser_after_post = 1 " layoutplugin.vim let g:layoutplugin#is_append_vimrc = 1 " mopkai.vim let g:mopkai_is_not_set_normal_ctermbg = or(!has('mac'), ($USER !=# 'mopp')) " vim-search-pulse let g:vim_search_pulse_disable_auto_mappings = 1 " vim-anzu {{{ nmap n (anzu-n)Pulse nmap N (anzu-N)Pulse nmap * (anzu-star)Pulse nmap # (anzu-sharp)Pulse nnoremap :nohlsearch :AnzuClearSearchStatus " }}} " open-browser.vim map op (openbrowser-open) " vim-markdown let g:vim_markdown_conceal = 0 " c-prototype let g:c_prototype_no_default_keymappings = 1 let g:c_prototype_remove_var_name = 1 let g:c_prototype_insert_point = 2 " vim-ruby let g:ruby_indent_access_modifier_style = 'indent' let g:ruby_operators = 1 let g:ruby_space_errors = 1 " vim-autoformat let g:formatdef_rustfmt = '"rustfmt"' let g:formatters_rust = ['rustfmt'] " vim-maximizer {{{ let g:maximizer_restore_on_winleave = 1 nnoremap :MaximizerToggle vnoremap :MaximizerTogglegv inoremap :MaximizerToggle " }}} " accelerated-jk {{{ if dein#tap('accelerated-jk') nmap j (accelerated_jk_gj) nmap k (accelerated_jk_gk) endif " }}} " ale {{{ let g:ale_sign_column_always = 1 let g:ale_lint_on_text_changed = 'never' let g:ale_lint_on_insert_leave = 0 function! s:define_erlang_option() abort let paths = [] for p in ['_build/default/lib/*/include', 'apps*/', 'apps*/*/include'] let paths += glob(p, 0, 1) endfor let g:ale_erlang_erlc_options = '-o /tmp/ -I src -I include -I _build/default/lib/ ' . join(map(paths, '"-I" . v:val'), ' ') endfunction " }}} " junkfile.vim {{{ command! -nargs=1 JunkfileNote call junkfile#open(strftime('%Y-%m-%d_') . , '.md') command! JunkfileDaily call junkfile#open_immediately(strftime('%Y-%m-%d.md')) nnoremap xx :0tabnew +JunkfileDaily let g:junkfile#directory = $HOME . '/workspace/notes' " }}} " gina.vim {{{ function! Hook_on_post_source_gina() abort let l:cmd_opt = {'noremap': 1, 'silent': 1} call gina#custom#mapping#nmap('branch', 'n', '(gina-branch-new)') call gina#custom#mapping#nmap('branch', 'r', '(gina-branch-move)') call gina#custom#mapping#nmap('status', '', ':Gina commit', l:cmd_opt) call gina#custom#mapping#nmap('/.*', 'q', ':quit', l:cmd_opt) call gina#custom#mapping#nmap('/.*', '', '(gina-edit-tab)') call gina#custom#mapping#nmap('/.*', '', ':call gina#action#call(''edit:left'')', l:cmd_opt) call gina#custom#mapping#nmap('/.*', '', ':call gina#action#call(''edit:bottom'')', l:cmd_opt) call gina#custom#mapping#nmap('/.*', '', ':call gina#action#call(''edit:above'')', l:cmd_opt) call gina#custom#mapping#nmap('/.*', '', ':call gina#action#call(''edit:right'')', l:cmd_opt) call gina#custom#command#option('/\%(commit\|status\|branch\|changes\|grep\|log\)', '--opener', 'split') endfunction nnoremap gis :Gina status nnoremap gic :Gina commit " }}} " lexima.vim {{{ imap cmap function! Hook_on_post_source_lexima() abort let l:rules = [] for l:char in ['+', '-', '*', '/', '%', '<', '>', '&', '=', ''] let l:rules += [{'char': l:char, 'at': '\S\+\%#', 'except': '''.*\%#.*''', 'input': ' ' . l:char . ' '}] endfor let l:rules += [{'char': '', 'at': '\w\+\s\(+\|-\|\*\|%\|<\|>\|&\|=\||\)\s\%#', 'input': ''}] for l:char in ['*', '<', '>', '&', '=', '', '/'] let l:rules += [{'char': l:char, 'at': l:char . '\s\%#', 'input': '' . l:char . ' '}] endfor let l:rules += [{'char': '', 'at': '\s\(++\|\*\*\|<<\|>>\|&&\|||\)\s\%#', 'input': ''}] let l:rules += \ [ \ {'char': '','at': '([()]*\%#[)]*)', 'input': ''}, \ \ {'char': '=', 'at': '!\%#', 'input': ' != ', 'priority': 10}, \ {'char': '', 'at': ' != !\%#', 'input': ''}, \ \ {'char': '/', 'at': '^\s*\%#', 'input': '// '}, \ \ {'filetype': ['erlang'], 'char': ':', 'at': ':\%#', 'input': ' :: '}, \ {'filetype': ['erlang'], 'char': '=', 'at': ':\%#', 'input': ' := '}, \ {'filetype': ['erlang'], 'char': '=', 'at': '= \%#', 'input': ':= '}, \ {'filetype': ['erlang'], 'char': '=', 'at': '!\%#', 'input': ' =/= ', 'priority': 20}, \ {'filetype': ['erlang'], 'char': '', 'at': '`\%#''', 'input': ''}, \ {'filetype': ['erlang'], 'char': '%', 'at': '^\s*%\%#', 'input': '% '}, \ {'filetype': ['erlang'], 'char': '', 'at': ':= \%#', 'input': ''}, \ {'filetype': ['erlang'], 'char': '`', 'input': '`''', 'syntax': 'Comment', }, \ \ {'char': '', 'at': '\s|\s\%#', 'input': '| '}, \ \ {'char': '>', 'at': '<\%#', 'input': '>', 'filetype': ['vim', 'rust']}, \ {'char': '>', 'at': '\s<\s\%#', 'input': '<>', 'filetype': ['vim', 'rust']}, \ {'char': '', 'at': '<\%#>', 'input': ''}, \ \ {'char': '=', 'at': '\(+\|-\|*\|%\|<\|>\) \%#', 'input': '= '}, \ \ {'char': '+', 'at': '\s+\s\%#', 'input': '++'}, \ {'char': '-', 'at': '\s-\s\%#', 'input': '--'}, \ {'char': '', 'at': '\(++\|--\)\%#', 'input': ''}, \ \ {'char': ',', 'at': '\%#', 'input': ', '}, \ {'char': ',', 'at': ',\%#', 'input': '->'}, \ {'char': ',', 'at': ',\s\%#', 'input': '->'}, \ {'char': '', 'at': '\S->\%#', 'input': ' -> '}, \ {'char': ',', 'at': '->\%#', 'input': '=>'}, \ {'char': '', 'at': '\S=>\%#', 'input': ' => '}, \ {'char': ',', 'at': '\s->\s\%#', 'input': '=> '}, \ {'char': ',', 'at': '\s=>\s\%#', 'input': ', '}, \ {'char': ',', 'at': '=>\s\%#', 'input': ', '}, \ {'char': ',', 'at': '=>\%#', 'input': ', '}, \ {'char': '', 'at': '\(,\s\|->\), \%#', 'input': ''}, \ {'char': '', 'at': '\s\(-\|=\)>\s\%#', 'input': ''}, \ \ {'filetype': ['markdown'], 'char': '/', 'input': '/'}, \ {'filetype': ['markdown'], 'char': '#', 'at': '^\%#\%(#\)\@!', 'input': '# '}, \ {'filetype': ['markdown'], 'char': '#', 'at': '#\s\%#', 'input': '# '}, \ {'filetype': ['markdown'], 'char': '', 'at': '^#\s\%#', 'input': ''}, \ {'filetype': ['markdown'], 'char': '', 'at': '##\s\%#', 'input': ' '}, \ {'filetype': ['markdown'], 'char': '+', 'at': '^\s*\%#', 'input': '+ '}, \ {'filetype': ['markdown'], 'char': '-', 'at': '^\s*\%#', 'input': '- '}, \ {'filetype': ['markdown'], 'char': '*', 'at': '^\s*\%#', 'input': '* '}, \ {'filetype': ['markdown'], 'char': '>', 'at': '^\s*\%#', 'input': '> '}, \ {'filetype': ['markdown'], 'char': '', 'at': '^\s*- \%#', 'input': '-'}, \ {'filetype': ['markdown'], 'char': '', 'at': '^\s*+ \%#', 'input': '+'}, \ {'filetype': ['markdown'], 'char': '', 'at': '^\s*\* \%#', 'input': '*'}, \ {'filetype': ['markdown'], 'char': '', 'at': '^\s*- \%#', 'input': '- '}, \ {'filetype': ['markdown'], 'char': '', 'at': '^\s*+ \%#', 'input': '+ '}, \ {'filetype': ['markdown'], 'char': '', 'at': '^\s*\* \%#', 'input': '* '}, \ {'filetype': ['markdown'], 'char': '', 'at': '^\(-\|+\|*\) \%#', 'input': ''}, \ ] for l:rule in l:rules call lexima#add_rule(l:rule) endfor endfunction " }}} " vim-denite-session let g:session_directory = s:session_directory " vaffle.vim {{{ command! VaffleTab tabnew +Vaffle command! VaffleSplit split +Vaffle command! VaffleVsplit vsplit +Vaffle command! VaffleBottomExpplorer botright split +Vaffle | resize 12 | setlocal winfixheight command! VaffleExplorer vertical topleft vsplit +Vaffle | vertical resize 35 | setlocal winfixwidth nnoremap vv :Vaffle nnoremap vl :Vaffle nnoremap ve :VaffleExplorer nnoremap vh :Vaffle %:h function! s:on_filetype_vaffle() abort nmap , (vaffle-toggle-current) nmap s (vaffle-open-selected-split) nmap v (vaffle-open-selected-vsplit) endfunction function! s:on_load_vaffle(is_directory) abort if a:is_directory && !dein#is_sourced('vaffle.vim') call dein#source('vaffle.vim') call vaffle#event#on_bufenter() endif endfunction " }}} " caw.vim nmap gcg (caw:hatpos:toggle:operator) nmap (caw:hatpos:toggle) vmap (caw:hatpos:toggle) " Capture.vim command! -nargs=1 -bang GrepBuffer :execute printf(':Capture! global%s/%s/print', expand(''), ) command! -nargs=0 -bang GrepBufferCursorWord :execute printf(':GrepBuffer%s %s', expand(''), expand('')) command! -nargs=0 -bang GrepBufferYank :execute printf(':GrepBuffer%s %s', expand(''), @0) " vim-quickhl {{{ nmap hl (quickhl-manual-this) xmap hl (quickhl-manual-this) nmap hc (quickhl-manual-reset) xmap hc (quickhl-manual-reset) " }}} " vim-choosewin nmap - (choosewin) let g:choosewin_overlay_enable = 1 let g:choosewin_overlay_clear_multibyte = 1 " deol.nvim command! DeolTabEdit tabnew +DeolEdit " vim-sandwich {{{ let g:sandwich#recipes = \ g:sandwich#default_recipes + \ [ \ { \ '__filetype__': 'erlang', \ 'buns': ['#{', '}'], \ 'input': ['#'], \ 'filetype': ['erlang'], \ } \ ] " }}} " vim-json let g:vim_json_syntax_conceal = 0 " Autocommands for plugins. {{{ augroup plugin autocmd! autocmd FileType gina-commit setlocal spell autocmd Filetype vaffle call s:on_filetype_vaffle() autocmd FileType erlang let b:caw_oneline_comment = '%%' autocmd FileType erlang call s:define_erlang_option() autocmd BufEnter * call s:on_load_vaffle(isdirectory(expand(''))) augroup END " }}} " }}} syntax enable colorscheme mopkai " It should be after syntax command.