" user settings syntax on filetype plugin indent on set autoindent set autoread set completeopt=menuone,noselect,preview set expandtab set hlsearch set ignorecase set incsearch set infercase set laststatus=2 set nobackup set noswapfile set noshowcmd " Use screenkey to show them set nowrap set nowritebackup set nonumber set shiftwidth=4 set signcolumn=yes set showmatch set smartindent set softtabstop=4 set tabstop=4 set virtualedit=onemore set wildmenu if has('nvim') set wildmode=full set wildoptions+=pum else set wildmode=longest,full if has('patch-8.2.4325') set wildoptions+=pum endif endif if has('termguicolors') set termguicolors let &t_8f = "\[38;2;%lu;%lu;%lum" " TODO: " If delete below on Vim, Background of terminal will be transparency " but lightline will be transparency too. let &t_8b = "\[48;2;%lu;%lu;%lum" endif if has('nvim') let $NVIM_TUI_ENABLE_TRUE_COLOR = v:true else set iminsert=2 let &t_ti ..= "\e[1 q" let &t_SI ..= "\e[5 q" let &t_SR ..= "\e[3 q" let &t_EI ..= "\e[1 q" let &t_te ..= "\e[0 q" endif if has('win32') || has('mac') set clipboard=unnamed else set clipboard=unnamed,unnamedplus endif " move f/b in insert mode like commandline inoremap inoremap " move UP/DOWN at fold context as same as displayed nnoremap j gj nnoremap k gk xnoremap j gj xnoremap k gk nnoremap Q copen " easy force write/quit cnoreabbrev qq quit! cnoreabbrev QQ qall! cnoreabbrev ww update! cnoreabbrev w update " TODO " cnoreabbrev w:q wq " dont use clipboard nnoremap x "_x nnoremap s "_s nnoremap c "_c "" DONT USE ARROW TO MOVE noremap noremap noremap noremap noremap! noremap! noremap! noremap! " to use indent/dedent inoremap inoremap nnoremap J gj nnoremap gj J xnoremap J gj xnoremap K gk "" move visual block in visual mode " vnoremap "zx"zP`[V`] " vnoremap "zx"zp`[V`] " " tmux win move " nnoremap h :wincmd h " nnoremap j :wincmd j " nnoremap k :wincmd k " nnoremap l :wincmd l " from other resource, vim.jp etc.. nnoremap nohlsearch nnoremap 0 getline('.')[0 : col('.') - 2] =~# '^\s\+$' ? '0' : '^' nnoremap Y y$ nnoremap :%substitute@\v@@g vnoremap :substitute@\v@@g cnoremap cnoremap cnoremap cnoremap inoremap getline('.')[0 : col('.') - 2] =~# '^\s\+$' ? '0' : '^' noremap! " nnoremap + " nnoremap - " Automatically indent with i and A nnoremap i len(getline('.')) ? 'i' : '"_cc' nnoremap A len(getline('.')) ? 'A' : '"_cc' augroup vimrc#terminal autocmd! augroup END if has('nvim') " neovim terminal settings " tnoremap tnoremap " feed insert mode when move terminal window autocmd vimrc#terminal TermOpen * startinsert autocmd vimrc#terminal TermOpen * setlocal nonumber autocmd vimrc#terminal WinEnter * if &buftype ==# 'terminal' | startinsert | endif " auto close autocmd vimrc#terminal TermClose * call feedkeys('\') " helper commands command! Vterm vertical botright vnew term://${SHELL} command! Hterm botright new term://${SHELL} command! Tterm tabnew term://${SHELL} else " Vim terminal settings tnoremap N autocmd vimrc#terminal TerminalOpen * setlocal nonumber " helper commands command! Vterm vertical botright vnew | terminal ++curwin command! Hterm botright new | terminal ++curwin command! Tterm tabnew | terminal ++curwin endif if has('gui_running') set guifont=Firge35\ Console\ 18 set guioptions-=r set guioptions-=R set guioptions-=l set guioptions-=L set guioptions-=b set guioptions-=m set guioptions-=T else set t_Co=256 augroup term_vim_c_space autocmd! autocmd VimEnter * map autocmd VimEnter * map! augroup END endif " use ripgrep if executable('rg') set grepprg=rg\ --vimgrep\ --no-heading set grepformat=%f:%l:%c:%m,%f:%l:%m endif function! s:grep_in_file() abort let l:query = input('grep: ') if empty(l:query) echohl WarningText echomsg 'vimgrep is canceled' echohl None return endif try silent execute 'lvimgrep ' . l:query . ' % | lw' " conceal has bug about wrapping setlocal conceallevel=3 concealcursor=nvc nowrap syntax match grep_internal '^.\{-}|\@=' conceal catch /.*/ " if quickfix open already, close it. silent execute 'lclose' echoerr v:exception endtry endfunction nnoremap F call grep_in_file() " copy buffer command command! CopyBuffer %y " yank here with line number nnoremap yh let @+ = expand('%') . '#L' . line('.') " Disable message that show when start without args (I) set shortmess=asTIcF " filetype settings if has('nvim') " not work if v:true/false let g:did_load_filetypes = 0 let g:do_filetype = 1 endif let g:filetype_m = 'mma' augroup vimrc#filetype autocmd! " FIXME: 読み込み順の問題か/ftdetect/objcだとうまくいかない autocmd BufRead,BufNewFile *.m set filetype=objc " FIXME: BufReadだと2回発火する? " FIXME: ファイラ経由で発火すると無限に呼び出されている? " reproduce: " $ mkdir /tmp/sample && touch /tmp/sample/a.js /tmp/sample/a.ts " $ vim /tmp/sample " :Fern . " and open a.js autocmd FileType javascript call s:open_it_really() augroup END function! s:open_it_really() abort let l:current_bufnr = bufnr() let l:tsfile = expand('%:p:r') . '.ts' if filewritable(l:tsfile) if confirm("Exists " . fnamemodify(l:tsfile, ':t') . ". Open it?", "&Yes\n&No\n", 1) ==# 1 execute 'edit' l:tsfile execute 'bwipeout' l:current_bufnr endif endif endfunction