" _ _ _____ _______ ______ _______ " \ / | | | | |_____/ | " \/ __|__ | | | | \_ |_____" " Encoding " ---------------------------------------------------------------------------- " {{{ scriptencoding utf-8 set encoding=utf-8 set fileencoding=utf-8 set nobomb "}}} " Install Plugins " ----------------------------------------------------------------------------- " Automatically install Plug.vim {{{ let s:plugCache = expand("~/.cache/plug") if has('vim_starting') if !isdirectory(s:plugCache) call mkdir(s:plugCache, "p") call system("curl -fLo " \.. shellescape(s:plugCache .. "/plug.vim") \.. " https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim") endif execute ":source " .. s:plugCache .. "/plug.vim" endif "}}} " Install plugins {{{ " Todo " [ ] Go周りのプラグイン call plug#begin(s:plugCache) Plug 'cespare/vim-toml' Plug 'ctrlpvim/ctrlp.vim' Plug 'dracula/vim' Plug 'haya14busa/is.vim' Plug 'itchyny/lightline.vim' Plug 'itchyny/vim-parenmatch' Plug 'itchyny/vim-winfix' Plug 'kato-k/cica-support.vim' Plug 'kato-k/hiroyuki.vim' Plug 'kato-k/radiru.vim' Plug 'keith/swift.vim' Plug 'lambdalisue/fern-git-status.vim' Plug 'lambdalisue/fern-hijack.vim' Plug 'lambdalisue/fern-renderer-nerdfont.vim' Plug 'lambdalisue/fern.vim' Plug 'lambdalisue/gina.vim' Plug 'liuchengxu/vista.vim' Plug 'luochen1990/rainbow' Plug 'machakann/vim-sandwich' Plug 'mattn/ctrlp-matchfuzzy' Plug 'mattn/emmet-vim' Plug 'mattn/vim-lexiv' Plug 'mbbill/undotree' Plug 'neoclide/coc.nvim' Plug 'rhysd/clever-f.vim' Plug 'skanehira/translate.vim' Plug 'thinca/vim-localrc' Plug 'thinca/vim-quickrun' Plug 'tokorom/vim-review' Plug 'tyru/caw.vim' Plug 'tyru/eskk.vim' Plug 'vim-denops/denops.vim' Plug 'vim-jp/vimdoc-ja' Plug 'vimwiki/vimwiki' call plug#end() "}}} " Options " ----------------------------------------------------------------------------- " Mapping Table-------------------------------------------------------------{{{ " モード | Norm | Ins | Cmd | Vis | Sel | Opr | Term | Lang | " コマンド +------+-----+-----+-----+-----+-----+------+------+ " [nore]map | yes | - | - | yes | yes | yes | - | - | " n[nore]map | yes | - | - | - | - | - | - | - | " [nore]map! | - | yes | yes | - | - | - | - | - | " i[nore]map | - | yes | - | - | - | - | - | - | " c[nore]map | - | - | yes | - | - | - | - | - | " v[nore]map | - | - | - | yes | yes | - | - | - | " x[nore]map | - | - | - | yes | - | - | - | - | " s[nore]map | - | - | - | - | yes | - | - | - | " o[nore]map | - | - | - | - | - | yes | - | - | " t[nore]map | - | - | - | - | - | - | yes | - | " l[nore]map | - | yes | yes | - | - | - | - | yes | "}}} " Display {{{ set ambiwidth=double set number set signcolumn=number set termguicolors set colorcolumn=80 set t_ZH= set t_ZR= syntax enable "}}} " Complete {{{ set completeopt+=menuone,menu,preview set pumheight=12 "}}} " Indent {{{ set expandtab set shiftround set shiftwidth=2 set smartindent set smarttab set softtabstop=0 set autoindent set tabstop=2 set list listchars=tab:\|\_,trail:→,eol:↲,extends:»,precedes:«,nbsp:% "}}} " Search {{{ set incsearch set ignorecase set smartcase set hlsearch nnoremap N 'nN'[v:searchforward] nnoremap n 'Nn'[v:searchforward] "}}} " CommandLine {{{ set wildmenu set wildmode=longest,list,full cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap "}}} " Mouse {{{ set mouse=a set ttymouse=sgr "}}} " Window {{{ set autoread set backspace=indent,eol,start set hidden set noequalalways "}}} " Shortmess {{{ " Vimの開始時に挨拶メッセージを表示しない set shortmess+=I " ins-completion-menu関連のメッセージを表示しない set shortmess+=c " 検索時に検索件数メッセージを表示しない。例えば "[1/5]" set shortmess-=S "}}} " Backup {{{ set noswapfile set nobackup set nowritebackup "}}} " Fold {{{ set fillchars=fold:\ set foldtext=getline(v:foldstart) augroup VimrcFold autocmd! autocmd ColorScheme * highlight! Folded guifg='#9ba4bf' guibg='#282A36' autocmd FileType * setlocal foldmethod=syntax autocmd FileType vim setlocal foldmethod=marker augroup END "}}} " Others {{{ set helplang=ja,en set whichwrap=b,s,h,l,<,>,[,] cabbr w!! w !sudo tee > /dev/null % " }}} " QuickFix {{{ augroup VimrcQuickFix autocmd! autocmd FileType qf nnoremap q :quit autocmd QuickFixCmdPost *grep* cwindow augroup END "}}} " Terminal {{{ augroup VimrcTerminal autocmd! autocmd WinLeave * if &buftype == "terminal" | silent! execute "normal! i" | endif autocmd TerminalOpen * if &buftype == "terminal" | silent! set nobuflisted | endif augroup END tnoremap "}}} " Create a new directory when the directory does not exist {{{ function! s:auto_mkdir(dir, force) if !isdirectory(a:dir) && (a:force || \ input(printf('"%s" does not exist. Create? [y/N]', a:dir)) =~? '^y\%[es]$') call mkdir(iconv(a:dir, &encoding, &termencoding), 'p') endif endfunction augroup VimrcAutoMakedir autocmd! autocmd BufWritePre * call s:auto_mkdir(expand(':p:h'), v:cmdbang) augroup END "}}} " Mapping {{{ let mapleader = "\" " Emacs Like cursor move {{{ inoremap inoremap "}}} " Useful mappings {{{ nnoremap 0 getline('.')[0 : col('.') - 2] =~# '^\s\+$' ? '0' : '^' nnoremap l :nohlsearch:diffupdate:syntax sync fromstart:call popup_clear() nnoremap j gj nnoremap k gk vnoremap v $h "}}} "}}} " FileType {{{ augroup VimrcFileType autocmd! autocmd FileType vue syntax sync fromstart autocmd BufNewFile,BufRead *.toml setf toml autocmd BufEnter *.re setlocal ft=review augroup END "}}} " User defined commands {{{ command! OpenDot :cd ~/dotfiles command! DirOpen :call job_start("open .") "}}} " Create undo point {{{ inoremap u inoremap u inoremap u "}}} " Change buffer {{{ nnoremap n :bn nnoremap p :bp "}}} " Plugin Options " ----------------------------------------------------------------------------- " coc {{{ " Use to trigger completion. inoremap coc#refresh() " Make auto-select the first completion item and notify coc.nvim to " format on enter, could be remapped by other vim plugin inoremap pumvisible() ? coc#_select_confirm() \: "\u\\=coc#on_enter()\" " Use `[g` and `]g` to navigate diagnostics " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. nmap [g (coc-diagnostic-prev) nmap ]g (coc-diagnostic-next) " GoTo code navigation. nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " Use K to show documentation in preview window. nnoremap K :call show_documentation() function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') elseif (coc#rpc#ready()) call CocActionAsync('doHover') else execute '!' . &keywordprg . " " . expand('') endif endfunction " Highlight the symbol and its references when holding the cursor. autocmd CursorHold * silent call CocActionAsync('highlight') " Symbol renaming. nmap rn (coc-rename) " Formatting selected code. xmap cf (coc-format-selected) nmap cf (coc-format-selected) " Applying codeAction to the selected region. " Example: `aap` for current paragraph xmap a (coc-codeaction-selected) nmap a (coc-codeaction-selected) " Remap keys for applying codeAction to the current buffer. nmap ac (coc-codeaction) " Apply AutoFix to problem on the current line. nmap qf (coc-fix-current) " Map function and class text objects " NOTE: Requires 'textDocument.documentSymbol' support from the language server. xmap if (coc-funcobj-i) omap if (coc-funcobj-i) xmap af (coc-funcobj-a) omap af (coc-funcobj-a) xmap ic (coc-classobj-i) omap ic (coc-classobj-i) xmap ac (coc-classobj-a) omap ac (coc-classobj-a) " Remap and for scroll float windows/popups. nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" " Use CTRL-S for selections ranges. " Requires 'textDocument/selectionRange' support of language server. nmap (coc-range-select) xmap (coc-range-select) " Add `:Format` command to format current buffer. command! -nargs=0 Format :call CocAction('format') " Add `:Fold` command to fold current buffer. command! -nargs=? Fold :call CocAction('fold', ) " Add `:OR` command for organize imports of the current buffer. command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') " Add (Neo)Vim's native statusline support. " NOTE: Please see `:h coc-status` for integrations with external plugins that " provide custom statusline: lightline.vim, vim-airline. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} " Mappings for CoCList " Show all diagnostics. nnoremap a :CocList diagnostics " Manage extensions. nnoremap e :CocList extensions " Show commands. nnoremap c :CocList commands " Find symbol of current document. " nnoremap o :CocList outline " Search workspace symbols. nnoremap s :CocList -I symbols " Do default action for next item. nnoremap j :CocNext " Do default action for previous item. nnoremap k :CocPrev inoremap \ pumvisible() ? "\" : \ check_back_space() ? "\" : \ coc#refresh() inoremap pumvisible() ? "\" : "\" function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction "}}} " LightLine {{{ set laststatus=2 set noshowmode function L_eskk_get_mode() if (mode() == 'i') && eskk#is_enabled() return g:eskk#statusline_mode_strings[eskk#get_mode()] else return '' endif endfunction let g:lightline = { \ 'active': { \ 'left': [['mode', 'paste'], ['readonly', 'filename', 'eskk', 'modified'], ['radiru']], \ 'right': [['lineinfo'], ['percent'], ['fileencoding', 'filetype']] \ }, \ 'component_function': { \ 'radiru': 'radiru#playing_station', \ 'eskk': 'L_eskk_get_mode', \ }, \ 'colorscheme': 'dracula', \ } " }}} " undoTree {{{ nnoremap u :UndotreeToggle "}}} " vista {{{ nnoremap o :Vista!! "}}} " eskk {{{ if !filereadable(expand('~/.config/eskk/SKK-JISYO.L')) call mkdir('~/.config/eskk', 'p') call system('cd ~/.config/eskk/ && wget http://openlab.jp/skk/dic/SKK-JISYO.L.gz && gzip -d SKK-JISYO.L.gz') endif let g:eskk#directory = "~/.config/eskk" let g:eskk#dictionary = { 'path': "~/.config/eskk/my_jisyo", 'sorted': 1, 'encoding': 'utf-8',} let g:eskk#large_dictionary = {'path': "~/.config/eskk/SKK-JISYO.L", 'sorted': 1, 'encoding': 'euc-jp',} let g:eskk#enable_completion = 0 "}}} " ctrlp {{{ let g:ctrlp_match_func = {'match': 'ctrlp_matchfuzzy#matcher'} let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git' "}}} " translate {{{ nnoremap t :Translate vnoremap t :Translate "}}} " clever-f {{{ map ; (clever-f-repeat-forward) map , (clever-f-repeat-back) " }}} " fern {{{ nnoremap f Fern . -drawer -toggle augroup VimrcFern autocmd! autocmd FileType fern setlocal nocursorline augroup END "}}} " Ignore Vim's standard pugin {{{ let g:loaded_2html_plugin = 1 let g:loaded_getscript = 1 let g:loaded_getscriptPlugin = 1 let g:loaded_gzip = 1 let g:loaded_matchparen = 1 let g:loaded_netrw = 1 let g:loaded_netrwFileHandlers = 1 let g:loaded_netrwPlugin = 1 let g:loaded_netrwSettings = 1 let g:loaded_rrhelper = 1 let g:loaded_tar = 1 let g:loaded_tarPlugin = 1 let g:loaded_vimball = 1 let g:loaded_vimballPlugin = 1 let g:loaded_zip = 1 let g:loaded_zipPlugin = 1 "}}} " ColorScheme {{{ colorscheme dracula " }}} " EOF