" _ " __ _(_)_ __ ___ _ __ ___ " \ \ / / | '_ ` _ \| '__/ __| " \ V /| | | | | | | | | (__ " (_)_/ |_|_| |_| |_|_| \___| " " @kawarimidoll " https://twitter.com/kawarimidoll " https://github.com/kawarimidoll if has('nvim') lua if vim.loader then vim.loader.enable() end else set nocompatible set encoding=utf-8 scriptencoding utf-8 filetype plugin indent on packadd matchit " syntax enable autocmd FileType * ++once ++nested syntax enable let g:qf_disable_statusline = 1 endif " language ja_JP.UTF-8 " let g:did_install_default_menus = 1 " let g:did_install_syntax_menu = 1 " let g:did_indent_on = 1 " " load ftplugin to set commentstring " " let g:did_load_ftplugin = 1 " let g:loaded_2html_plugin = 1 " let g:loaded_getscript = 1 " let g:loaded_getscriptPlugin = 1 " let g:loaded_gzip = 1 " let g:loaded_logiPat = 1 " let g:loaded_logipat = 1 " let g:loaded_man = 1 " let g:loaded_matchit = 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_remote_plugins = 1 " let g:loaded_rrhelper = 1 " let g:loaded_shada_plugin = 1 " let g:loaded_spellfile_plugin = 1 " let g:loaded_sql_completion = 1 " let g:loaded_tar = 1 " let g:loaded_tarPlugin = 1 " let g:loaded_tutor_mode_plugin = 1 " let g:loaded_vimball = 1 " let g:loaded_vimballPlugin = 1 " let g:loaded_zip = 1 " let g:loaded_zipPlugin = 1 " let g:skip_defaults_vim = 1 " let g:skip_loading_mswin = 1 " let g:vimsyn_embed = 1 " avoid to set expandtab in default ftplugin let g:markdown_recommended_style = 0 " {{{ Keymap " https://zenn.dev/kawarimidoll/articles/513d603681ece9 function! s:keymap(force_map, modes, ...) abort let arg = join(a:000, ' ') let cmd = a:force_map ? 'map' : 'noremap' for mode in split(a:modes, '.\zs') if stridx('nvsxoilct', mode) < 0 echoerr '[keymap] invalid mode is detected: ' mode arg continue endif execute mode .. cmd arg endfor endfunction command! -nargs=+ -bang Keymap call s:keymap(0, ) " }}} " perl -e 'print sort { length($a) <=> length($b) } <>' /usr/share/dict/words > ~/.cache/vim/sorted_words set dictionary+=~/.cache/vim/sorted_words let s:word_1000_dict_path = expand('~/.cache/vim/google-10000-english-no-swears.txt') let s:word_1000_dict_url = 'https://raw.githubusercontent.com/first20hours/' \ .. 'google-10000-english/master/google-10000-english-no-swears.txt' execute 'set dictionary+=' .. s:word_1000_dict_path command! -bang DownloadDictFile call mi#utils#download(s:word_1000_dict_url, s:word_1000_dict_path, 0) command! -nargs=+ -bang -complete=expression NotifyShow call mi#notify#show([], 0 ? 3 : 2) command! -bang NotifyHistory call mi#notify#history(0) command! NotifyForget call mi#notify#forget() " function! s:look_completefunc() abort " let col = col('.') " if col < 2 " return '' " endif " let line = getline('.')[0:col-2] " let start_idx = matchend(line, '.*\A') " if start_idx < 0 " let start_idx = 0 " endif " let word = line[start_idx:] " let results = systemlist($"look {word}") " call sort(results, {a,b -> strlen(a) - strlen(b)}) " call complete(start_idx + 1, results) " return '' " endfunction " inoremap =look_completefunc() " alc represents auto look completeion let s:alc_enable = v:false function! s:toggle_alc() abort let s:alc_enable = !s:alc_enable augroup vimrc_alc autocmd! if s:alc_enable autocmd TextChangedI * echomsg getline('.')[col('.')-1] " autocmd TextChangedI * " \ if !pumvisible() && getline('.')[col('.')-1] =~ '\a' " \ | call feedkeys("\\", 'm') " \ | else " \ | echo 'not fit' " \ | endif endif augroup END echo 'look auto completion:' (s:alc_enable ? 'enabled' : 'disabled') endfunction command! ToggleAutoLookCompletion call s:toggle_alc() let s:dotfiles_dict_path = expand('~/dotfiles/.config/cspell/dotfiles.txt') execute 'set dictionary+=' .. s:dotfiles_dict_path set ambiwidth=single set breakindent set breakindentopt=min:50,shift:4,sbr,list:-1 set cedit=\ " set clipboard& " set clipboard^=unnamed " set clipboard^=unnamedplus set complete=.,w,k,b,u set completeopt=menuone,noselect,fuzzy set expandtab set fileencodings=ucs-bom,utf-8,iso-2022-jp-3,euc-jp,cp932 set fillchars+=vert:│,eob:\\x20 set foldcolumn=0 set formatoptions+=jmM1 set history=2000 set ignorecase set infercase set laststatus=2 set lazyredraw set linebreak set list set listchars=tab:^-,trail:~,extends:»,precedes:«,nbsp:% set nobackup set nofixeol set nomodeline set nonumber set noshowmode set noswapfile set nowritebackup set runtimepath+=~/dotfiles/.vim set runtimepath+=~/dotfiles/.vim/after set scrolloff=5 set shiftround set shiftwidth=2 set shortmess+=scCI set showbreak=↪ set showtabline=0 set signcolumn=number set smartcase set smartindent set softtabstop=2 set spelllang+=cjk set spelloptions=camel set splitbelow set splitright set switchbuf+=usetab set tabstop=2 set termguicolors set title set updatetime=300 set whichwrap=b,s,h,l,<,>,[,],~ set wildmode=longest,full set wrap set wrapscan if executable('rg') set grepprg=rg\ --vimgrep\ --trim\ --hidden\ --glob=!.git set grepformat=%f:%l:%c:%m endif if has('nvim') set inccommand=split set scrollback=2000 else " :h vim-differences " :h nvim-defaults set autoindent set autoread set background=dark set backspace=indent,eol,start set belloff=all set completeopt+=popuphidden set display=lastline set hidden set hlsearch set incsearch set nojoinspaces set noruler set nostartofline set showcmd set smartcase set smarttab set ttimeout set ttimeoutlen=50 set ttyfast set viminfo='20,<50,s10,h set viminfofile=~/.vim/viminfo set wildmenu set wildoptions=pum,tagfile nnoremap Y y$ nnoremap nohlsearchdiffupdatenormal! inoremap u inoremap u nnoremap & :&& nnoremap call mi#dial#increment(v:count1) nnoremap call mi#dial#decrement(v:count1) command! LazyGit tab terminal ++close ++norestore lazygit Keymap nx gc mi#comment#operator_toggle() nnoremap gcc mi#comment#operator_toggle() .. '_' " Keymap nx sa mi#surround#add() Keymap nx sa mi#surround#operator('add') nnoremap sd mi#surround#operator('delete') .. ' ' nnoremap sr mi#surround#operator('replace') .. ' ' let g:mi#ft#multiline = 1 Keymap nx f call mi#ft#smart('f') Keymap nx F call mi#ft#smart('F') Keymap nx t call mi#ft#smart('t') Keymap nx T call mi#ft#smart('T') Keymap nx ; call mi#ft#repeat(';') Keymap nx , call mi#ft#repeat(',') onoremap f mi#ft#smart_expr('f') onoremap F mi#ft#smart_expr('F') onoremap t mi#ft#smart_expr('t') onoremap T mi#ft#smart_expr('T') onoremap ; mi#ft#repeat_expr(';') onoremap , mi#ft#repeat_expr(',') noremap sf f noremap sF F noremap st t noremap sT T noremap s; ; noremap s, , nnoremap . call mi#common#dot_repeat() nnoremap call mi#window#resize() " let s:help_dir = expand('~/.vim/vimdoc-ja') " execute 'set runtimepath+=' .. s:help_dir " function! s:ja_doc_update() abort " if isdirectory(s:help_dir) " echo '[ja_doc] pull latest version...' " echo system(printf('git -C %s reset --hard', s:help_dir)) " echo system(printf('git -C %s pull --rebase', s:help_dir)) " echo system(printf('git -C %s gc --prune=now', s:help_dir)) " else " echo '[ja_doc] clone latest version...' " echo system(printf('git clone --depth 1 https://github.com/vim-jp/vimdoc-ja.git %s', s:help_dir)) " endif " execute 'helptags' s:help_dir .. '/doc' " echo '[ja_doc] successfully updated.' " endfunction " command! JaDocUpdate call s:ja_doc_update() " prev/next use nnoremap [u *2Nzznohlsearch nnoremap ]u *zznohlsearch " word search with keep positions " https://twitter.com/Bakudankun/status/1207057884581900289 " `doautocmd CursorMoved` is required to show searchprop nnoremap * v:count ? '*' : \ 'silent execute "keepjump normal! *" call winrestview(' \ .. string(winsaveview()) .. ')doautocmd CursorMoved' nnoremap # v:count ? '#' : \ 'silent execute "keepjump normal! #" call winrestview(' \ .. string(winsaveview()) .. ')doautocmd CursorMoved' " :h termcap-cursor-shape@en " https://vim.fandom.com/wiki/Change_cursor_shape_in_different_modes if &term =~ 'xterm' || &term == 'win32' " Use DECSCUSR escape sequences " vertical bar in insert mode let &t_SI = "\e[5 q" " underline in replace mode let &t_SR = "\e[3 q" " block in normal mode let &t_EI = "\e[1 q" " change shape enter / escape termcap let &t_ti ..= "\e[1 q" let &t_te ..= "\e[0 q" " 0 -> default (depends on terminal, normally blinking block) " 1 -> blinking block " 2 -> solid block " 3 -> blinking underscore " 4 -> solid underscore " 5 -> blinking vertical bar " 6 -> solid vertical bar endif endif let g:my_vimrc = $MYVIMRC let g:vimrc_snr = expand('') command! RcEdit execute 'edit' g:my_vimrc command! RcReload write | execute 'source' g:my_vimrc | nohlsearch | redraw | echo g:my_vimrc .. ' is reloaded.' function! s:copy_path(target, with_lnum) abort let expr = '%' if a:target == 'full path' let expr ..= ':p' elseif a:target == 'dir name' let expr ..= ':h' elseif a:target == 'file name' let expr ..= ':t' endif let @*=expand(expr) .. (a:with_lnum ? ':' .. line('.') : '') echo 'copy ' .. a:target .. (a:with_lnum ? ' with line num' : '') endfunction command! -bang CopyFullPath call s:copy_path('full path', 0) command! -bang CopyDirName call s:copy_path('dir name', 0) command! -bang CopyFileName call s:copy_path('file name', 0) command! -bang CopyRelativePath call s:copy_path('relative path', 0) command! CopyLastCmd let @* = @: command! -nargs=+ -bang Grep call mi#qf#async_grep(, {'add': 0}) command! -nargs=+ -bang GrepF call mi#qf#async_grep(, {'add': 0, 'fixed': 1}) command! -nargs=+ -bang LGrep call mi#qf#async_grep(, {'add': 0, 'loc': 1}) command! -nargs=+ -bang LGrepF call mi#qf#async_grep(, {'add': 0, 'loc': 1, 'fixed': 1}) command! -nargs=1 -complete=file VDiff vertical diffsplit command! VDiffAlt vertical diffsplit # command! SudoWrite write !sudo tee > /dev/null % nnoremap mm call mi#mark#auto_set() nnoremap m, call mi#mark#jump_to_last() nnoremap RR R nnoremap R mi#operator#replace() nnoremap J mi#operator#join() nnoremap JJ mi#operator#join() .. 'j' xnoremap J mi#operator#join() " like helix nnoremap U " kensaku let g:kensaku#args = '--dict ~/.local/share/jsmigemo/no-abbrev-compact-dict' nnoremap J/ call mi#kensaku#start() nnoremap J? call mi#kensaku#start({ 'init': mi#kensaku#last_query() }) nnoremap n call mi#kensaku#next(0) nnoremap N call mi#kensaku#next(1) " https://zenn.dev/yahomi_dev/articles/216231f2902f32 function! s:split_line() abort normal! mz call execute('s/\v\{\zs\s?|,\zs\s|\s?\ze\}/\r/g', 'silent!') normal! =`z nohlsearch endfunction nnoremap Jp call split_line() " https://zenn.dev/mattn/articles/83c2d4c7645faa nmap gj gjg nmap gk gkg nnoremap