]>
Commit | Line | Data |
---|---|---|
b3b23234 | 1 | """ vim dir in xdg config |
afd175d7 | 2 | let x = ($XDG_CONFIG_HOME??($HOME.'/.config')).'/vim' |
8d4a98e1 | 3 | execute 'set runtimepath='.x.','.&runtimepath.','.x.'/after' |
4 | execute 'set packpath='.x.','.&packpath.','.x.'/after' | |
1b8a4102 | 5 | |
b3b23234 | 6 | """ vim-only defaults |
58a8dbcc | 7 | if !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 |
18 | endif | |
fef7b7c4 | 19 | |
b3b23234 | 20 | """ dir for state files in xdg state |
afd175d7 | 21 | let x = ($XDG_STATE_HOME??($HOME.'/.local/state')).'/vim' |
4850f4c2 | 22 | if !isdirectory(x) |
afd175d7 | 23 | call mkdir(x, 'p', 0700) |
24 | endif | |
afd175d7 | 25 | |
b3b23234 | 26 | " NOTE: backup files in vim state dir for both vim and neovim |
afd175d7 | 27 | let y = x.'/backup' |
28 | if !isdirectory(y) | |
29 | call mkdir(y, 'p', 0700) | |
8d4a98e1 | 30 | endif |
afd175d7 | 31 | execute 'set backupdir='.y.'//' |
58a8dbcc | 32 | set 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. | |
40 | if !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 | 55 | endif |
58a8dbcc | 56 | |
57 | autocmd BufNew * set undofile | |
afd175d7 | 58 | |
4850f4c2 | 59 | unlet x |
afd175d7 | 60 | unlet y |
1b8a4102 | 61 | |
b3b23234 | 62 | |
63 | """ options | |
58a8dbcc | 64 | autocmd VimEnter,WinNew * set number |
65 | autocmd VimEnter,WinNew * set relativenumber | |
66 | autocmd InsertEnter * set norelativenumber | |
67 | autocmd InsertLeave * set relativenumber | |
68 | autocmd FocusLost * set norelativenumber | |
69 | autocmd FocusGained * set relativenumber | |
70 | ||
71 | autocmd VimEnter,WinNew * set colorcolumn=80 | |
72 | autocmd VimEnter,WinNew * set cursorline | |
58a8dbcc | 73 | |
74 | autocmd VimEnter,WinNew * set list | |
1b8a4102 | 75 | set listchars=tab:├─,extends:»,precedes:«,space:·,trail:∙,nbsp:■ |
58a8dbcc | 76 | |
b3b23234 | 77 | """ styles |
58a8dbcc | 78 | highlight ColorColumn term=NONE ctermbg=0 |
79 | ||
fab483dd | 80 | highlight WhiteSpaceMol ctermfg=Black |
58a8dbcc | 81 | autocmd VimEnter,WinNew * match WhiteSpaceMol / / |
82 | highlight WhiteSpaceBol ctermfg=DarkBlue | |
83 | autocmd VimEnter,WinNew * 2match WhiteSpaceBol /\(^ \+\)\|\( \+$\)/ | |
ddcfe43c | 84 | |
b3b23234 | 85 | """ indent |
58a8dbcc | 86 | autocmd FileType python set softtabstop=4 shiftwidth=4 expandtab |
87 | autocmd FileType markdown set softtabstop=4 shiftwidth=4 expandtab | |
88 | autocmd FileType javascript set softtabstop=2 shiftwidth=2 expandtab | |
89 | autocmd FileType json set softtabstop=2 shiftwidth=2 expandtab | |
90 | autocmd FileType html set softtabstop=2 shiftwidth=2 expandtab | |
e69caf64 | 91 | let g:EditorConfig_enable_for_new_buf = 1 |
58a8dbcc | 92 | |
b3b23234 | 93 | """ syntax |
58a8dbcc | 94 | autocmd 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 | |
98 | if has('nvim') | |
99 | tnoremap <C-\>n <C-\><C-N> | |
100 | tnoremap <C-\>o <C-\><C-O> | |
101 | endif | |
102 | ||
103 | "" move windows any time | |
104 | if 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 | |
110 | endif | |
111 | " insert | |
112 | inoremap <A-h> <C-\><C-N><C-w>h | |
113 | inoremap <A-j> <C-\><C-N><C-w>j | |
114 | inoremap <A-k> <C-\><C-N><C-w>k | |
115 | inoremap <A-l> <C-\><C-N><C-w>l | |
116 | " normal | |
117 | nnoremap <A-h> <C-w>h | |
118 | nnoremap <A-j> <C-w>j | |
119 | nnoremap <A-k> <C-w>k | |
120 | nnoremap <A-l> <C-w>l |