aboutsummaryrefslogtreecommitdiffhomepage
path: root/.config
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-07-06 02:59:04 +0900
committernsfisis <nsfisis@gmail.com>2025-07-06 02:59:04 +0900
commit0053535ec962262c9a594311502be726a069ddd2 (patch)
tree2ecc01fae3f11a774b5e557695efe38a79a9a36a /.config
parent9bb16b9173250adacd256f6305591f42854c8d67 (diff)
downloaddotfiles-0053535ec962262c9a594311502be726a069ddd2.tar.gz
dotfiles-0053535ec962262c9a594311502be726a069ddd2.tar.zst
dotfiles-0053535ec962262c9a594311502be726a069ddd2.zip
vim: move .vimrc to $XDG_CONFIG_HOME/vim/vimrc
Diffstat (limited to '.config')
-rw-r--r--.config/vim/vimrc427
1 files changed, 427 insertions, 0 deletions
diff --git a/.config/vim/vimrc b/.config/vim/vimrc
new file mode 100644
index 0000000..d48e1db
--- /dev/null
+++ b/.config/vim/vimrc
@@ -0,0 +1,427 @@
+" NOTE: This vimrc is minimal and not well-maintained because I have migrated
+" from Vim to Neovim.
+
+set encoding=utf-8
+scriptencoding utf-8
+
+
+if empty($XDG_DATA_HOME)
+ let s:data_home = $HOME . '/.local/share'
+else
+ let s:data_home = $XDG_DATA_HOME
+endif
+
+let s:my_env = {
+ \ 'backup_dir': s:data_home . '/vim/backup',
+ \ 'swap_dir': s:data_home . '/vim/swap',
+ \ 'undo_dir': s:data_home . '/vim/undo',
+ \ 'viminfo': s:data_home . '/vim/viminfo',
+ \ }
+
+for [s:k, s:v] in items(s:my_env)
+ if s:k =~# '_dir$' && !isdirectory(s:v)
+ call mkdir(s:v, 'p')
+ endif
+endfor
+unlet s:k s:v s:data_home
+
+
+language messages C
+language time C
+
+
+syntax on
+filetype plugin indent on
+
+
+set nowrapscan
+set incsearch
+set ignorecase
+set smartcase
+
+set scrolloff=7
+set wrap
+set linebreak
+set breakindent
+set breakindentopt+=sbr
+let &showbreak = '> '
+set sidescrolloff=20
+set display=lastline
+let &fillchars = 'vert: ,fold: ,diff: '
+set list
+let &listchars = "eol: ,tab:> ,trail:^,extends:>,precedes:<"
+set concealcursor=cnv
+
+set synmaxcol=500
+set hlsearch
+set t_Co=256
+set colorcolumn=+1
+if has('patch-8.2.0953')
+ set spelloptions+=camel
+endif
+
+set laststatus=2
+set winminheight=0
+set hidden
+set switchbuf=usetab
+
+set showtabline=1
+
+set notitle
+
+set mouse=
+
+set shortmess+=a
+set shortmess+=s
+set shortmess+=I
+set shortmess+=c
+set showcmd
+set noshowmode
+set report=999
+set confirm
+set belloff=all
+
+set clipboard=unnamed
+
+set undofile
+let &undodir = s:my_env.undo_dir
+set textwidth=0
+set backspace=indent,eol,start
+set completeopt-=preview
+set pumheight=10
+set noshowmatch
+set matchpairs+=<:>
+set nojoinspaces
+set nrformats-=octal
+if has('patch-8.2.0860')
+ set nrformats+=unsigned
+endif
+
+set tabstop=4
+set shiftwidth=4
+set smarttab
+set softtabstop=4
+set expandtab
+set autoindent
+set smartindent
+set copyindent
+set preserveindent
+
+set foldlevelstart=0
+set foldopen+=insert
+set foldmethod=marker
+
+set diffopt+=vertical
+set diffopt+=foldcolumn:3
+
+set maxmapdepth=10
+set notimeout
+set ttimeout
+set ttimeoutlen=100
+
+set nofixendofline
+set fileformats=unix,dos
+set backup
+let &backupdir = s:my_env.backup_dir
+set autowrite
+set autoread
+
+let &directory = s:my_env.swap_dir . '//'
+
+set history=2000
+set wildignore+=*.o,*.obj,*.lib
+set wildignorecase
+set wildmenu
+
+set shell=fish
+set keywordprg=
+
+set fileencodings=utf-8,cp932,euc-jp
+
+set sessionoptions+=localoptions
+set sessionoptions+=resize
+set sessionoptions+=winpos
+let &viminfofile = s:my_env.viminfo
+
+
+augroup Vimrc
+ autocmd!
+augroup END
+
+autocmd Vimrc VimResized * wincmd =
+
+autocmd Vimrc BufRead *
+ \ if 0 < line("'\"") && line("'\"") <= line('$') &&
+ \ &filetype !~# 'commit' && &filetype !~# 'rebase' |
+ \ execute "normal g`\"" |
+ \ endif
+
+if has('patch-9.0.1799')
+ packadd editorconfig
+
+ function! SetIsEditorConfigApplied(config)
+ let b:__editorconfig__ = {}
+ if has_key(a:config, 'indent_style')
+ let b:__editorconfig__.expandtab = 1
+ endif
+ if has_key(a:config, 'tab_width')
+ let b:__editorconfig__.tabstop = 1
+ endif
+ if has_key(a:config, 'indent_size')
+ let b:__editorconfig__.shiftwidth = 1
+ let b:__editorconfig__.softtabstop = 1
+ endif
+ return 0
+ endfunction
+
+ call editorconfig#AddNewHook(function('SetIsEditorConfigApplied'))
+endif
+
+function! SetIndentStyle(prefer_spaces, indent_size)
+ let editorconfig = get(b:, '__editorconfig__', {})
+ if !has_key(editorconfig, 'expandtab')
+ let &expandtab = a:prefer_spaces
+ endif
+ if !has_key(editorconfig, 'tabstop')
+ let &tabstop = a:indent_size
+ endif
+ if !has_key(editorconfig, 'shiftwidth')
+ let &shiftwidth = a:indent_size
+ endif
+ if !has_key(editorconfig, 'softtabstop')
+ let &softtabstop = a:indent_size
+ endif
+endfunction
+
+autocmd Vimrc FileType c call SetIndentStyle(1, 4)
+autocmd Vimrc FileType cmake call SetIndentStyle(1, 2)
+autocmd Vimrc FileType cpp call SetIndentStyle(1, 4)
+autocmd Vimrc FileType css call SetIndentStyle(1, 2)
+autocmd Vimrc FileType docbk call SetIndentStyle(1, 2)
+autocmd Vimrc FileType go call SetIndentStyle(1, 4)
+autocmd Vimrc FileType haskell call SetIndentStyle(1, 4)
+autocmd Vimrc FileType html call SetIndentStyle(1, 2)
+autocmd Vimrc FileType javascript call SetIndentStyle(1, 2)
+autocmd Vimrc FileType javascriptreact call SetIndentStyle(1, 2)
+autocmd Vimrc FileType json call SetIndentStyle(1, 2)
+autocmd Vimrc FileType leaf call SetIndentStyle(1, 4)
+autocmd Vimrc FileType lisp call SetIndentStyle(1, 2)
+autocmd Vimrc FileType lua call SetIndentStyle(1, 3)
+autocmd Vimrc FileType markdown call SetIndentStyle(1, 4)
+autocmd Vimrc FileType nix call SetIndentStyle(1, 2)
+autocmd Vimrc FileType php call SetIndentStyle(1, 2)
+autocmd Vimrc FileType python call SetIndentStyle(1, 4)
+autocmd Vimrc FileType ruby call SetIndentStyle(1, 2)
+autocmd Vimrc FileType satysfi call SetIndentStyle(1, 2)
+autocmd Vimrc FileType sbt call SetIndentStyle(1, 2)
+autocmd Vimrc FileType scala call SetIndentStyle(1, 2)
+autocmd Vimrc FileType toml call SetIndentStyle(1, 2)
+autocmd Vimrc FileType typescript call SetIndentStyle(1, 2)
+autocmd Vimrc FileType typescriptreact call SetIndentStyle(1, 2)
+autocmd Vimrc FileType vim call SetIndentStyle(1, 4)
+autocmd Vimrc FileType xml call SetIndentStyle(1, 2)
+autocmd Vimrc FileType yaml call SetIndentStyle(1, 2)
+
+noremap <expr> gn v:searchforward ? 'gn' : 'gN'
+noremap <expr> gN v:searchforward ? 'gN' : 'gn'
+noremap <expr> n v:searchforward ? 'n' : 'N'
+noremap <expr> N v:searchforward ? 'N' : 'n'
+
+nnoremap <silent> & :%&&<CR>
+xnoremap <silent> & :%&&<CR>
+
+nnoremap <C-r> "
+xnoremap <C-r> "
+
+let @j = 'j.'
+let @k = 'k.'
+let @n = 'n.'
+let @m = 'N.'
+nnoremap @N @m
+nnoremap @a 9999@@
+nnoremap ` @@
+
+inoremap <C-d> <Del>
+
+inoremap <C-b> <C-g>U<Left>
+inoremap <C-f> <C-g>U<Right>
+
+inoremap <C-u> <C-g>u<C-u>
+inoremap <C-w> <C-g>u<C-w>
+
+cnoremap <C-a> <Home>
+cnoremap <C-e> <End>
+cnoremap <C-f> <Right>
+cnoremap <C-b> <Left>
+cnoremap <C-n> <Down>
+cnoremap <C-p> <Up>
+cnoremap <C-d> <Del>
+
+cnoremap <Left> <Nop>
+inoremap <Left> <Nop>
+cnoremap <Right> <Nop>
+inoremap <Right> <Nop>
+
+nnoremap c "_c
+xnoremap c "_c
+nnoremap C "_C
+xnoremap C "_C
+
+noremap g= =
+
+noremap ml gu
+noremap mu gU
+
+noremap gu <Nop>
+noremap gU <Nop>
+xnoremap u <Nop>
+xnoremap U <Nop>
+
+xnoremap x "_x
+
+nnoremap Y y$
+xnoremap <expr> Y mode() ==# 'V' ? 'y' : 'Vy'
+
+nnoremap R gR
+nnoremap gR R
+nnoremap r gr
+nnoremap gr r
+
+nnoremap U <C-r>
+
+noremap H ^
+noremap L $
+noremap M %
+
+noremap gw b
+noremap gW B
+
+noremap k gk
+noremap j gj
+noremap gk k
+noremap gj j
+
+nnoremap gff gF
+
+nnoremap <silent> tt :<C-u>tabnew<CR>
+
+nnoremap <silent> tn :<C-u><C-r>=(tabpagenr() + v:count1 - 1) % tabpagenr('$') + 1<CR>tabnext<CR>
+nnoremap <silent> tp :<C-u><C-r>=(tabpagenr('$') * 10 + tabpagenr() - v:count1 - 1) % tabpagenr('$') + 1<CR>tabnext<CR>
+
+nnoremap <silent> tN :<C-u>tabmove +<CR>
+nnoremap <silent> tP :<C-u>tabmove -<CR>
+
+nnoremap <silent> tsh :<C-u>leftabove vsplit<CR>
+nnoremap <silent> tsj :<C-u>rightbelow split<CR>
+nnoremap <silent> tsk :<C-u>leftabove split<CR>
+nnoremap <silent> tsl :<C-u>rightbelow vsplit<CR>
+
+nnoremap <silent> tsH :<C-u>topleft vsplit<CR>
+nnoremap <silent> tsJ :<C-u>botright split<CR>
+nnoremap <silent> tsK :<C-u>topleft split<CR>
+nnoremap <silent> tsL :<C-u>botright vsplit<CR>
+
+nnoremap <silent> twh :<C-u>leftabove vnew<CR>
+nnoremap <silent> twj :<C-u>rightbelow new<CR>
+nnoremap <silent> twk :<C-u>leftabove new<CR>
+nnoremap <silent> twl :<C-u>rightbelow vnew<CR>
+
+nnoremap <silent> twH :<C-u>topleft vnew<CR>
+nnoremap <silent> twJ :<C-u>botright new<CR>
+nnoremap <silent> twK :<C-u>topleft new<CR>
+nnoremap <silent> twL :<C-u>botright vnew<CR>
+
+nnoremap th <C-w>h
+nnoremap tj <C-w>j
+nnoremap tk <C-w>k
+nnoremap tl <C-w>l
+
+nnoremap tH <C-w>H
+nnoremap tJ <C-w>J
+nnoremap tK <C-w>K
+nnoremap tL <C-w>L
+
+nnoremap tx <C-w>x
+
+nnoremap tRH <C-w>_
+nnoremap tRW <C-w><Bar>
+nnoremap tRR <C-w>_<C-w><Bar>
+
+nnoremap t= <C-w>=
+
+nnoremap <silent> tq :<C-u>bdelete<CR>
+
+nnoremap tc <C-w>c
+
+nnoremap to <C-w>o
+nnoremap <silent> tO :<C-u>tabonly<CR>
+
+nnoremap T <Nop>
+
+nnoremap <silent> Tb :<C-u>if &background == 'dark' <Bar>set background=light <Bar>else <Bar>set background=dark <Bar>endif<CR>
+nnoremap <silent> Tc :<C-u>set cursorcolumn! <Bar>set cursorline!<CR>
+nnoremap <silent> Td :<C-u>if &diff <Bar>diffoff <Bar>else <Bar>diffthis <Bar>endif<CR>
+nnoremap <silent> Te :<C-u>set expandtab!<CR>
+nnoremap <silent> Th :<C-u>set hlsearch!<CR>
+nnoremap <silent> Tn :<C-u>set number!<CR>
+nnoremap <silent> Ts :<C-u>set spell!<CR>
+nnoremap <silent> T8 :<C-u>if &textwidth ==# 80 <Bar>set textwidth=0 <Bar>else <Bar>set textwidth=80 <Bar>endif<CR>
+nnoremap <silent> T0 :<C-u>if &textwidth ==# 100 <Bar>set textwidth=0 <Bar>else <Bar>set textwidth=100 <Bar>endif<CR>
+nnoremap <silent> T2 :<C-u>if &textwidth ==# 120 <Bar>set textwidth=0 <Bar>else <Bar>set textwidth=120 <Bar>endif<CR>
+nnoremap <silent> Tw :<C-u>set wrap!<CR>
+
+nmap TB Tb
+nmap TC Tc
+nmap TD Td
+nmap TE Te
+nmap TH Th
+nmap TN Tn
+nmap TS Ts
+nmap TW Tw
+
+nnoremap gh <Nop>
+nnoremap gH <Nop>
+nnoremap g<C-h> <Nop>
+
+nnoremap Q <Nop>
+nnoremap gQ <Nop>
+
+nnoremap ZZ <Nop>
+nnoremap ZQ <Nop>
+
+nnoremap <C-h> :<C-u>help<Space>
+
+onoremap <silent> gv :<C-u>normal! gv<CR>
+
+nnoremap ; :
+nnoremap : ;
+xnoremap ; :
+xnoremap : ;
+nnoremap @; @:
+xnoremap @; @:
+cnoremap <C-r>; <C-r>:
+inoremap <C-r>; <C-r>:
+
+imap jk <ESC>
+cmap jk <ESC>
+
+nnoremap <silent> <C-c> :<C-u>nohlsearch<CR>
+
+nnoremap <silent> <Space>w :<C-u>update<CR>
+nnoremap <silent> <nowait> Z :<C-u>wqall<CR>
+
+
+inoreabbrev TOOD TODO
+inoreabbrev retrun return
+inoreabbrev reutrn return
+inoreabbrev tihs this
+
+
+cnoreabbrev S %s
+
+
+set background=dark
+colorscheme desert
+
+
+let &statusline = ' %f %r %m %= %l/%L %{&fileencoding} %{&fileformat} %y '