]> git.sev.monster Git - dotfiles.git/blame - etc/vim/.vimrc
vimrc: update comments, add mappings
[dotfiles.git] / etc / vim / .vimrc
CommitLineData
b3b23234 1""" vim dir in xdg config
afd175d7 2let x = ($XDG_CONFIG_HOME??($HOME.'/.config')).'/vim'
8d4a98e1 3execute 'set runtimepath='.x.','.&runtimepath.','.x.'/after'
4execute 'set packpath='.x.','.&packpath.','.x.'/after'
1b8a4102 5
b3b23234 6""" vim-only defaults
58a8dbcc 7if !has('nvim')
b3b23234 8 " neovim defaults are already set
58a8dbcc 9 source $VIMRUNTIME/defaults.vim
10
b3b23234 11 " packages
58a8dbcc 12 packadd matchit
13 packadd editorconfig
14
b3b23234 15 " options
16 set hlsearch
58a8dbcc 17 set autoindent
18endif
fef7b7c4 19
b3b23234 20""" dir for state files in xdg state
afd175d7 21let x = ($XDG_STATE_HOME??($HOME.'/.local/state')).'/vim'
4850f4c2 22if !isdirectory(x)
afd175d7 23 call mkdir(x, 'p', 0700)
24endif
afd175d7 25
b3b23234 26" NOTE: backup files in vim state dir for both vim and neovim
afd175d7 27let y = x.'/backup'
28if !isdirectory(y)
29 call mkdir(y, 'p', 0700)
8d4a98e1 30endif
afd175d7 31execute 'set backupdir='.y.'//'
58a8dbcc 32set backup backupcopy=yes
afd175d7 33
58a8dbcc 34" NOTE: neovim uses ShaDa (SHAred DAta) format for viminfo and swap, and uses a
35" different version for undo files, so these types of files when created
36" by vim cannot be used with neovim, and the 'viminfofile', 'directory',
37" and 'undodir' directories cannot be shared.
38" NOTE: neovim has a nice default for these directories and files so
39" customizing them is not necessary for it.
40if !has('nvim')
41 " NOTE: 'viminfofile' is a deprecated alias for 'shada' in neovim
42 execute 'set viminfofile='.x.'/.viminfo'
43
44 let y = x.'/swap'
45 if !isdirectory(y)
46 call mkdir(y, 'p', 0700)
47 endif
48 execute 'set directory='.y.'//'
49
50 let y = x.'/undo'
51 if !isdirectory(y)
52 call mkdir(y, 'p', 0700)
53 endif
54 execute 'set undodir='.y.'//'
8d4a98e1 55endif
58a8dbcc 56
57autocmd BufNew * set undofile
afd175d7 58
4850f4c2 59unlet x
afd175d7 60unlet y
1b8a4102 61
b3b23234 62
63""" options
58a8dbcc 64autocmd VimEnter,WinNew * set number
65autocmd VimEnter,WinNew * set relativenumber
66autocmd InsertEnter * set norelativenumber
67autocmd InsertLeave * set relativenumber
68autocmd FocusLost * set norelativenumber
69autocmd FocusGained * set relativenumber
70
71autocmd VimEnter,WinNew * set colorcolumn=80
72autocmd VimEnter,WinNew * set cursorline
58a8dbcc 73
74autocmd VimEnter,WinNew * set list
1b8a4102 75set listchars=tab:├─,extends:»,precedes:«,space:·,trail:∙,nbsp:■
58a8dbcc 76
b3b23234 77""" styles
58a8dbcc 78highlight ColorColumn term=NONE ctermbg=0
79
fab483dd 80highlight WhiteSpaceMol ctermfg=Black
58a8dbcc 81autocmd VimEnter,WinNew * match WhiteSpaceMol / /
82highlight WhiteSpaceBol ctermfg=DarkBlue
83autocmd VimEnter,WinNew * 2match WhiteSpaceBol /\(^ \+\)\|\( \+$\)/
ddcfe43c 84
b3b23234 85""" indent
58a8dbcc 86autocmd FileType python set softtabstop=4 shiftwidth=4 expandtab
87autocmd FileType markdown set softtabstop=4 shiftwidth=4 expandtab
88autocmd FileType javascript set softtabstop=2 shiftwidth=2 expandtab
89autocmd FileType json set softtabstop=2 shiftwidth=2 expandtab
90autocmd FileType html set softtabstop=2 shiftwidth=2 expandtab
e69caf64 91let g:EditorConfig_enable_for_new_buf = 1
58a8dbcc 92
b3b23234 93""" syntax
58a8dbcc 94autocmd FileType todo set colorcolumn=0
b3b23234 95
96""" mappings
97"" use more accessible escapes, as C-n and C-o are shadowed by some terminals
98if has('nvim')
99 tnoremap <C-\>n <C-\><C-N>
100 tnoremap <C-\>o <C-\><C-O>
101endif
102
103"" move windows any time
104if has('nvim')
105 " terminal
106 tnoremap <A-h> <C-\><C-N><C-w>h
107 tnoremap <A-j> <C-\><C-N><C-w>j
108 tnoremap <A-k> <C-\><C-N><C-w>k
109 tnoremap <A-l> <C-\><C-N><C-w>l
110endif
111" insert
112inoremap <A-h> <C-\><C-N><C-w>h
113inoremap <A-j> <C-\><C-N><C-w>j
114inoremap <A-k> <C-\><C-N><C-w>k
115inoremap <A-l> <C-\><C-N><C-w>l
116" normal
117nnoremap <A-h> <C-w>h
118nnoremap <A-j> <C-w>j
119nnoremap <A-k> <C-w>k
120nnoremap <A-l> <C-w>l
This page took 0.098863 seconds and 4 git commands to generate.