if &encoding !=? 'utf-8' let &termencoding = &encoding set encoding=utf-8 endif scriptencoding utf-8 if has('guess_encode') set fileencodings=ucs-bom,utf-8,iso-2022-jp,guess,euc-jp,cp932,latin1 else set fileencodings=ucs-bom,utf-8,iso-2022-jp,euc-jp,cp932,latin1 endif set fileformats=unix,dos " dein.vim let s:dein_dir = expand('$XDG_DATA_HOME/dein') let s:dein_repo_dir = s:dein_dir .. '/repos/github.com/Shougo/dein.vim' " clone dein.vim when not having installed dein.vim if &runtimepath !~# '/dein.vim' if !isdirectory(s:dein_repo_dir) execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_dir endif execute 'set runtimepath^=' .. fnamemodify(s:dein_repo_dir, ':p') endif if dein#load_state(s:dein_dir) call dein#begin(s:dein_dir) " Set directories for dein.toml and dein_lazy.toml let s:toml_dir = expand('$XDG_CONFIG_HOME/vim/rc') call dein#load_toml(s:toml_dir .. '/dein.toml', {'lazy': 0}) call dein#load_toml(s:toml_dir .. '/dein_lazy.toml', {'lazy': 1}) call dein#end() call dein#save_state() endif filetype plugin indent on syntax enable " If you want to install not installed plugins on startup. if dein#check_install() call dein#install() endif " ddc.vim call ddc#custom#patch_global('ui', 'native') call ddc#custom#patch_global('sources', [ \ 'around', 'buffer', 'file', 'skkeleton', 'vim-lsp' \ ]) call ddc#custom#patch_global('sourceOptions', { \ 'around': {'mark': 'arnd'}, \ 'buffer': {'mark': 'buf'}, \ 'file': { \ 'mark': 'file', \ 'isVolatile': v:true, \ 'forceCompletionPattern': '\S/\S*', \ }, \ 'skkeleton': { \ 'mark': 'skk', \ 'matchers': ['skkeleton'], \ 'sorters': [], \ 'minAutoCompleteLength': 2, \ }, \ 'vim-lsp': {'mark': 'lsp'}, \ '_': { \ 'matchers': ['matcher_fuzzy', 'matcher_head'], \ 'sorters': ['sorter_fuzzy'], \ 'converters': ['converter_fuzzy'], \ }, \ }) call ddc#custom#patch_global('sourceParams', { \ 'around': {'maxSize': 500}, \ 'buffer': { \ 'requireSameFiletype': v:false, \ 'limitBytes': 5000000, \ 'fromAltBuf': v:true, \ 'forceCollect': v:true, \ }, \ }) call ddc#custom#patch_filetype(['ps1', 'dosbatch', 'autohotkey', 'registry'], { \ 'sourceOptions': { \ 'file': { \ 'forceCompletionPattern': '\S\\\S*', \ }, \ }, \ 'sourceParams': { \ 'file': { \ 'mode': 'win32', \ }, \ }, \ }) call ddc#enable() " ddu.vim call ddu#custom#patch_global({ \ 'ui': 'filer', \ 'sources': [{'name': 'file', 'params': {}}], \ 'actionOptions': { \ 'narrow': { \ 'quit': v:false, \ }, \ }, \ 'sourceOptions': { \ '_': { \ 'columns': ['filename'], \ }, \ }, \ 'kindOptions': { \ 'file': { \ 'defaultAction': 'open', \ }, \ }, \ }) autocmd FileType ddu-filer call s:ddu_my_settings() function! s:ddu_my_settings() abort nnoremap \ :call ddu#ui#filer#do_action('itemAction') nnoremap \ :call ddu#ui#filer#do_action('toggleSelectItem') nnoremap o \ :call ddu#ui#filer#do_action('expandItem', {'mode': 'toggle'}) nnoremap q \ :call ddu#ui#filer#do_action('quit') endfunction let mapleader = "\" colorscheme desert set ruler set showcmd set shortmess=filmnxtToOc set smartindent set display=lastline set backspace=indent,eol,start set nofixeol set ignorecase set smartcase set tabpagemax=255 set whichwrap=b,s,h,l,<,>,[,] set number set list set listchars=tab:>-,extends:<,trail:- set hlsearch set incsearch set expandtab set shiftwidth=2 set matchpairs+=<:>,「:」,(:),『:』,【:】,《:》,〈:〉,{:},[:],【:】,‘:’,“:” set autochdir set spell set spelllang& spelllang+=cjk set spelloptions& spelloptions+=camel set formatoptions+=M set nrformats+=unsigned set scrolloff=5 set viminfofile=$XDG_CACHE_HOME/vim/viminfo set viminfo='1000,f1,<500,s10,h set updatetime=1500 nnoremap s :setlocal spell! spell? nnoremap h nnoremap F :call ddu#start({}) nnoremap D :call dein#update() nnoremap R :call dein#recache_runtimepath() " nnoremap U :call dein#update('skkeleton') nnoremap f :Files nnoremap w :ShakyoClue nnoremap q (socrates-greed) nnoremap m (MatchitNormalForward) vnoremap m (MatchitVisualForward) " vim-sandwich let g:sandwich_no_default_key_mappings = 1 nmap a (sandwich-add) xmap a (sandwich-add) omap a (sandwich-add) nmap d (sandwich-delete) xmap d (sandwich-delete) nmap db (sandwich-delete-auto) nmap r (sandwich-replace) xmap r (sandwich-replace) nmap rb (sandwich-replace-auto) runtime ftplugin/man.vim inoremap jj cnoremap jj vnoremap < >gv " For CSI u mode inoremap cnoremap noremap noremap :tabnext noremap :tabprevious let g:most_recently_closed = [] augroup MostRecentlyClosedTabs autocmd! autocmd BufWinLeave * call insert(g:most_recently_closed, expand('')) augroup END noremap :tabnext noremap :tabprevious noremap :if len(g:most_recently_closed) > 0 \| \ exec ':tabnew ' .. remove(g:most_recently_closed, 0) \| \ endif noremap :q noremap ':tabmove -' .. v:count1 .. '' noremap > ':tabmove +' .. v:count1 .. '' nnoremap gr :tabnext nnoremap gR :tabprevious " nnoremap q: :q tnoremap tabnext tnoremap tabprevious tnoremap q nnoremap :noh nnoremap * *``zz nnoremap # #``zz noremap j v:count == 0 ? 'gj' : 'm`' .. v:count .. 'gj' noremap k v:count == 0 ? 'gk' : 'm`' .. v:count .. 'gk' noremap gj j noremap gk k noremap gk noremap gj inoremap gk inoremap gj nnoremap gf T nnoremap gf inoremap inoremap nnoremap n (v:searchforward ? 'n' : 'N') nnoremap N (v:searchforward ? 'N' : 'n') " Change the size of windows nnoremap < nnoremap > nnoremap - nnoremap + nnoremap x "_x nnoremap X "_X nnoremap s "_s nnoremap Y y$ nnoremap / /\v nnoremap 2 nnoremap 2 nnoremap mm mQ nnoremap mk `Q " Change cursors according with mode let &t_ti .= "\e[1 q" let &t_SI .= "\e[5 q" let &t_EI .= "\e[1 q" let &t_te .= "\e[0 q" " Enable bracketed-paste if &term =~ 'screen' let &t_BE = "\e[?2004h" let &t_BD = "\e[?2004l" exec "set t_PS=\e[200~" exec "set t_PE=\e[201~" endif " Set the indent inside the p tags let g:html_indent_inctags = 'p' " Auto completion to close XML tags augroup CloseTags autocmd! autocmd Filetype html,xml inoremap ==o augroup END command -nargs=0 ClearUndo call ClearUndo() function! s:ClearUndo() let old_undolevels = &undolevels set undolevels=-1 execute "normal! a \\" let &undolevels = old_undolevels unlet old_undolevels endfunction function! s:on_lsp_buffer_enabled() abort setlocal omnifunc=lsp#complete setlocal signcolumn=yes nmap gd (lsp-definition) nmap (lsp-rename) " inoremap pumvisible() ? "\\" : "\" endfunction augroup lsp_install autocmd! autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() augroup END command! LspDebug let lsp_log_verbose=1 | let lsp_log_file = expand('$HOME/lsp.log') let g:lsp_diagnostics_enabled = 1 let g:lsp_diagnostics_virtual_text_enabled = v:false let g:lsp_diagnostics_echo_cursor = 1 let g:asyncomplete_auto_popup = 1 let g:asyncomplete_auto_completeopt = 1 let g:asyncomplete_popup_delay = 200 let g:lsp_text_edit_enabled = 1 let g:lsp_settings_filetype_ruby = 'solargraph' " Display results on the upper side with denite let g:fzf_layout = { 'up': '~40%' } " Search tags with nnoremap :call fzf#vim#tags(expand('')) " Make it possible to jump from fzf to the file let g:fzf_buffers_jump = 1 " Specify a user snippet directory let g:vsnip_snippet_dir = expand('$XDG_CONFIG_HOME/vsnip') " Define a skk dictionary call skkeleton#azik#add_table('us') call skkeleton#config({ \ 'globalDictionaries': [ \ [expand('$XDG_DATA_HOME/skk/SKK-JISYO.L'), 'euc-jp'], \ [expand('$XDG_DATA_HOME/skk/SKK-JISYO.geo'), 'euc-jp'], \ [expand('$XDG_DATA_HOME/skk/SKK-JISYO.jinmei'), 'euc-jp'], \ [expand('$XDG_DATA_HOME/skk/SKK-JISYO.propernoun'), 'euc-jp'], \ [expand('$XDG_DATA_HOME/skk/SKK-JISYO.station'), 'euc-jp'], \ [expand('$XDG_DATA_HOME/skk/SKK-JISYO.emoji.utf8'), 'utf-8'], \ [expand('$XDG_DATA_HOME/skk/zipcode/SKK-JISYO.zipcode'), 'euc-jp'], \ ], \ 'kanaTable': 'azik', \ 'eggLikeNewline': v:true, \ 'keepState': v:true, \ 'markerHenkan': 'γ', \ 'markerHenkanSelect': 'Γ', \ 'registerConvertResult': v:true, \ 'showCandidatesCount': 1, \ 'selectCandidateKeys': '12345qw', \ 'userJisyo': expand('$XDG_DATA_HOME/skk/skkeleton'), \ }) call skkeleton#register_keymap('input', ';', 'henkanPoint') call skkeleton#register_keymap('henkan', '<', 'purgeCandidate') call skkeleton#register_keymap('henkan', 'X', v:false) let g:skkeleton_state_id = v:null function! s:skkeleton_state_popup() if g:skkeleton_state_id != v:null call popup_close(g:skkeleton_state_id) endif if g:skkeleton#mode != '' let g:skkeleton_state_id = popup_create(g:skkeleton#mode, #{pos: 'botleft', line: 'cursor+1', col: 'cursor', moved: 'any', highlight: 'WildMenu'}) endif endfunction function s:mapAzikOkuri(input, feed) abort for mode in ['i', 'c'] exec 'autocmd User skkeleton-enable-post ' .. mode .. 'map ' .. \ a:input .. " call azikOkuri('" .. a:input .. "', '" .. \ a:feed .. "')" exec 'autocmd User skkeleton-disable-post silent! ' .. mode .. \ 'unmap ' .. a:input endfor endfunction function s:azikOkuri(input, feed) abort if g:skkeleton#state.phase ==# 'input:okurinasi' && g:skkeleton#mode !=# 'abbrev' \ && g:skkeleton#vim_status().prevInput =~# '\a$' call skkeleton#handle('handleKey', {'key': split(a:feed, '\zs')}) else call skkeleton#handle('handleKey', {'key': a:input}) endif endfunction augroup Skkeleton autocmd! autocmd User skkeleton-handled call skkeleton_state_popup() let s:azikOkuriList = [ \ ['Q', 'aI'], \ ['Z', 'aNn'], \ ['K', 'iNn'], \ ['H', 'uU'], \ ['J', 'uNn'], \ ['W', 'eI'], \ ['D', 'eNn'], \ ['P', 'oU'], \ ['L', 'oNn'], \ ] for item in s:azikOkuriList call s:mapAzikOkuri(item[0], item[1]) endfor autocmd InsertLeave * if g:skkeleton#state.phase ==# 'henkan' && getline('.') !~ '^\s*$' | \ call job_start(['wl-copy', '--', getline('.')]) | \ endif autocmd InsertEnter * ++once call skkeleton#register_kanatable('azik', { \ '': ['じゅん', ''], \ 'jj': 'escape', \ '''': 'disable', \ '@': 'zenkaku', \ 'q': 'katakana', \ '': 'hankatakana', \ 'z~': ['~', ''], \ 'z ': [' ', ''], \ ':': ['ー', ''], \ 'z:': [':', ''], \ 'l': ['っ', ''], \ 'n': ['ん', ''], \ 'n''': ['ん', ''], \ 'kyi': ['きぃ', ''], \ 'kyk': ['きん', ''], \ 'kgi': ['きぃ', ''], \ 'kgk': ['きん', ''], \ 'gyi': ['ぎぃ', ''], \ 'gyk': ['ぎん', ''], \ 'xi': ['し', ''], \ 'xy': ['しぃ', ''], \ 'xk': ['しん', ''], \ 'ci': ['ち', ''], \ 'cy': ['ちぃ', ''], \ 'ck': ['ちん', ''], \ 'jk': ['じん', ''], \ 'syi': ['しぃ', ''], \ 'syk': ['しん', ''], \ 'zyi': ['じぃ', ''], \ 'zyk': ['じん', ''], \ 'tyi': ['ちぃ', ''], \ 'tyk': ['ちん', ''], \ 'dyi': ['ぢぃ', ''], \ 'dyk': ['ぢん', ''], \ 'nyi': ['にぃ', ''], \ 'nyk': ['にん', ''], \ 'ngi': ['にぃ', ''], \ 'ngk': ['にん', ''], \ 'hyi': ['ひぃ', ''], \ 'hyk': ['ひん', ''], \ 'hgi': ['ひぃ', ''], \ 'hgk': ['ひん', ''], \ 'byi': ['びぃ', ''], \ 'byk': ['びん', ''], \ 'bgi': ['びぃ', ''], \ 'bgk': ['びん', ''], \ 'pyi': ['ぴぃ', ''], \ 'pyk': ['ぴん', ''], \ 'pgi': ['ぴぃ', ''], \ 'pgk': ['ぴん', ''], \ 'myi': ['みぃ', ''], \ 'myk': ['みん', ''], \ 'mgi': ['みぃ', ''], \ 'mgk': ['みん', ''], \ 'ryi': ['りぃ', ''], \ 'ryk': ['りん', ''], \ 'xxa': ['ぁ', ''], \ 'xxi': ['ぃ', ''], \ 'xxu': ['ぅ', ''], \ 'xxe': ['ぇ', ''], \ 'xxo': ['ぉ', ''], \ 'xxya': ['ゃ', ''], \ 'xxyu': ['ゅ', ''], \ 'xxyo': ['ょ', ''], \ 'xxwa': ['ゎ', ''], \ 'tsa': ['つぁ', ''], \ 'tsi': ['つぃ', ''], \ 'tsu': ['つ', ''], \ 'tse': ['つぇ', ''], \ 'tso': ['つぉ', ''], \ 'tsq': ['つぁい', ''], \ 'tsz': ['つぁん', ''], \ 'tsk': ['つぃん', ''], \ 'tsh': ['つう', ''], \ 'tsj': ['つん', ''], \ 'tsw': ['つぇい', ''], \ 'tsd': ['つぇん', ''], \ 'tsp': ['つぉう', ''], \ 'tsl': ['つぉん', ''], \ 'dya': ['ぢゃ', ''], \ 'dyu': ['ぢゅ', ''], \ 'dye': ['ぢぇ', ''], \ 'dyo': ['ぢょ', ''], \ 'dyq': ['ぢゃい', ''], \ 'dyz': ['ぢゃん', ''], \ 'dyh': ['ぢゅう', ''], \ 'dyj': ['ぢゅん', ''], \ 'ww': ['うぇい', ''], \ 'sm': ['さま', ''], \ 'dx': ['でした', ''], \ 'mx': ['ました', ''], \ 'kf': ['かい', ''], \ 'gf': ['がい', ''], \ 'gyf': ['ぎゃい', ''], \ 'sf': ['さい', ''], \ 'zf': ['ざい', ''], \ 'xf': ['しゃい', ''], \ 'syf': ['しゃい', ''], \ 'jf': ['じゃい', ''], \ 'zyf': ['じゃい', ''], \ 'tf': ['たい', ''], \ 'df': ['だい', ''], \ 'cf': ['ちゃい', ''], \ 'tyf': ['ちゃい', ''], \ 'dyf': ['ぢゃい', ''], \ 'nf': ['ない', ''], \ 'nyf': ['にゃい', ''], \ 'ngf': ['にゃい', ''], \ 'hf': ['はい', ''], \ 'hgf': ['ひゃい', ''], \ 'bf': ['ばい', ''], \ 'byf': ['びゃい', ''], \ 'bgf': ['びゃい', ''], \ 'pf': ['ぱい', ''], \ 'pyf': ['ぴゃい', ''], \ 'pgf': ['ぴゃい', ''], \ 'mf': ['まい', ''], \ 'myf': ['みゃい', ''], \ 'mgf': ['みゃい', ''], \ 'yf': ['やい', ''], \ 'rf': ['らい', ''], \ 'ryf': ['りゃい', ''], \ 'wf': ['わい', ''], \ 'vf': ['ゔぁい', ''], \ }) augroup END imap (skkeleton-toggle) cmap (skkeleton-toggle) " tmap (skkeleton-toggle) " dps-dial.vim " Define original sequences for dps_dial let g:dps_dial#augends = [ \ 'decimal', \ 'date-hyphen', \ 'date-slash', \ {'kind': 'constant', 'opts': {'elements': ['true', 'false']}}, \ {'kind': 'constant', 'opts': { \ 'elements': ['月', '火', '水', '木', '金', '土', '日'], \ 'cyclic': v:true, \ 'word': v:false, \ }}, \ {'kind': 'constant', 'opts': { \ 'elements': ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], \ 'cyclic': v:true, \ 'word': v:true, \ }}, \ {'kind': 'case', 'opts': { \ 'cases': ['camelCase', 'snake_case', 'SCREAMING_SNAKE_CASE'], \ 'cyclic': v:true, \ }}, \ {'kind': 'date', 'opts': { 'format': 'yyyy-MM-dd', 'only_valid': v:false }}, \ ] nnoremap (dps-dial-increment) nmap (dps-dial-decrement) xnoremap (dps-dial-increment) xmap (dps-dial-decrement) xnoremap g g(dps-dial-increment) xmap g g(dps-dial-decrement) " kensaku.vim/kensaku-search.vim cnoremap JJ (kensaku-search-replace) " capture.vim cnoremap Capture " Open automatically quickfix-window after excuting grep like commands autocmd QuickFixCmdPost *grep* cwindow command! RC :tabnew $XDG_CONFIG_HOME/vim/vimrc | \ :tabnew $XDG_CONFIG_HOME/vim/rc/dein.toml | \ :tabnew $XDG_CONFIG_HOME/vim/rc/dein_lazy.toml command! SR :source $XDG_CONFIG_HOME/vim/vimrc cabbr w!! w !sudo tee > /dev/null % cabbr h tab :help cabbr encto edit ++encoding= cabbr qa tabdo windo if !&modified \| close \| endif " Yank " set clipboard=exclude:.* nnoremap p :call setreg('"', system('wl-paste -n'))""p nnoremap P :call setreg('"', system('wl-paste -n'))""P xnoremap p call setreg('"', system('wl-paste -n'))""P xnoremap P call setreg('"', system('wl-paste -n'))""p cnoremap " call setreg('"', system('wl-paste -n'))" inoremap " call setreg('"', system('wl-paste -n'))" nnoremap R (operator-replace) xnoremap R (operator-replace) nnoremap RR R " Avoid being triggered when leaving from visual mode set clipboard-=autoselect set clipboard^=unnamed augroup LazyClipboardSetup autocmd! autocmd TextYankPost * silent call job_start(['wl-copy', '--', getreg('*')]) " autocmd CursorHold,CursorMoved * ++once call serverlist() | set clipboard^=unnamed augroup END " Yank for WSL2 function! IsWSL() if has('unix') let lines = readfile('/proc/version') if lines[0] =~ 'Microsoft' return 1 endif endif return 0 endfunction if IsWSL() augroup Yank autocmd! autocmd TextYankPost * silent call job_start(['win32yank.exe', '-i', ' --crlf', getreg('"')]) augroup END nnoremap p :call setreg('"',system('win32yank.exe -o --lf'))""p nnoremap P :call setreg('"',system('win32yank.exe -o --lf'))""P let g:previm_open_cmd = '/mnt/c/PROGRA~2/Google/Chrome/Application/chrome.exe' let g:previm_wsl_mode = 1 endif " DeepL let g:deepl#endpoint = "https://api-free.deepl.com/v2/translate" let g:deepl#auth_key = "" " replace a visual selection " vmap tle call deepl#v("EN") vmap tlj call deepl#v("JA") " translate a current line and display on a new line " nmap tle yypVcall deepl#v("EN") nmap tlj yypVcall deepl#v("JA") if filereadable(expand('$XDG_CONFIG_HOME/vim/vimrc.local')) source $XDG_CONFIG_HOME/vim/vimrc.local endif