]>
Commit | Line | Data |
---|---|---|
58a8dbcc | 1 | " use our new vim dir primarily |
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 | |
58a8dbcc | 6 | if !has('nvim') |
7 | " neovim doesn't have defaults to load explicitly | |
8 | source $VIMRUNTIME/defaults.vim | |
9 | ||
10 | " neovim does this stuff already | |
11 | packadd matchit | |
12 | packadd editorconfig | |
13 | ||
14 | set autoindent | |
15 | endif | |
fef7b7c4 | 16 | |
58a8dbcc | 17 | " define and create a centralized dir to keep transient state files in |
afd175d7 | 18 | let x = ($XDG_STATE_HOME??($HOME.'/.local/state')).'/vim' |
4850f4c2 | 19 | if !isdirectory(x) |
afd175d7 | 20 | call mkdir(x, 'p', 0700) |
21 | endif | |
afd175d7 | 22 | |
23 | let y = x.'/backup' | |
24 | if !isdirectory(y) | |
25 | call mkdir(y, 'p', 0700) | |
8d4a98e1 | 26 | endif |
afd175d7 | 27 | execute 'set backupdir='.y.'//' |
58a8dbcc | 28 | set backup backupcopy=yes |
afd175d7 | 29 | |
58a8dbcc | 30 | |
31 | " NOTE: neovim uses ShaDa (SHAred DAta) format for viminfo and swap, and uses a | |
32 | " different version for undo files, so these types of files when created | |
33 | " by vim cannot be used with neovim, and the 'viminfofile', 'directory', | |
34 | " and 'undodir' directories cannot be shared. | |
35 | " NOTE: neovim has a nice default for these directories and files so | |
36 | " customizing them is not necessary for it. | |
37 | if !has('nvim') | |
38 | " NOTE: 'viminfofile' is a deprecated alias for 'shada' in neovim | |
39 | execute 'set viminfofile='.x.'/.viminfo' | |
40 | ||
41 | let y = x.'/swap' | |
42 | if !isdirectory(y) | |
43 | call mkdir(y, 'p', 0700) | |
44 | endif | |
45 | execute 'set directory='.y.'//' | |
46 | ||
47 | let y = x.'/undo' | |
48 | if !isdirectory(y) | |
49 | call mkdir(y, 'p', 0700) | |
50 | endif | |
51 | execute 'set undodir='.y.'//' | |
8d4a98e1 | 52 | endif |
58a8dbcc | 53 | |
54 | autocmd BufNew * set undofile | |
afd175d7 | 55 | |
4850f4c2 | 56 | unlet x |
afd175d7 | 57 | unlet y |
1b8a4102 | 58 | |
58a8dbcc | 59 | " options |
60 | autocmd VimEnter,WinNew * set number | |
61 | autocmd VimEnter,WinNew * set relativenumber | |
62 | autocmd InsertEnter * set norelativenumber | |
63 | autocmd InsertLeave * set relativenumber | |
64 | autocmd FocusLost * set norelativenumber | |
65 | autocmd FocusGained * set relativenumber | |
66 | ||
67 | autocmd VimEnter,WinNew * set colorcolumn=80 | |
68 | autocmd VimEnter,WinNew * set cursorline | |
1b8a4102 | 69 | set hlsearch |
58a8dbcc | 70 | |
71 | autocmd VimEnter,WinNew * set list | |
1b8a4102 | 72 | set listchars=tab:├─,extends:»,precedes:«,space:·,trail:∙,nbsp:■ |
58a8dbcc | 73 | |
74 | " styles | |
75 | highlight ColorColumn term=NONE ctermbg=0 | |
76 | ||
fab483dd | 77 | highlight WhiteSpaceMol ctermfg=Black |
58a8dbcc | 78 | autocmd VimEnter,WinNew * match WhiteSpaceMol / / |
79 | highlight WhiteSpaceBol ctermfg=DarkBlue | |
80 | autocmd VimEnter,WinNew * 2match WhiteSpaceBol /\(^ \+\)\|\( \+$\)/ | |
ddcfe43c | 81 | |
58a8dbcc | 82 | " indent |
83 | autocmd FileType python set softtabstop=4 shiftwidth=4 expandtab | |
84 | autocmd FileType markdown set softtabstop=4 shiftwidth=4 expandtab | |
85 | autocmd FileType javascript set softtabstop=2 shiftwidth=2 expandtab | |
86 | autocmd FileType json set softtabstop=2 shiftwidth=2 expandtab | |
87 | autocmd FileType html set softtabstop=2 shiftwidth=2 expandtab | |
e69caf64 | 88 | let g:EditorConfig_enable_for_new_buf = 1 |
58a8dbcc | 89 | |
90 | " syntax | |
91 | autocmd FileType todo set colorcolumn=0 |