-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
239 lines (205 loc) · 5.67 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
"exec" ~/.config/nvim/init.vim "$@"
" This .vimrc sets NeoVim's defaults for Vim
" then it loads NeoVim's init.vim
if has('nvim') || exists('g:loaded_nvim_defaults')
" Put this function in your init.vim,
" in case you stop using this plugin, but still need it
function! Stdpath(id)
return stdpath(a:id)
endfunction
finish
endif
let g:loaded_nvim_defaults = 1
" OPTIONS
" :help nvim-defaults
" Vim 7 options that differ
set nocompatible
if has('autocmd')
filetype plugin indent on
endif
set backspace=indent,eol,start
set encoding=utf-8
set incsearch
set nolangremap
let &nrformats="bin,hex"
set showcmd
set ruler
set wildmenu
" Vim 7, 8 options that differ
set autoindent
set autoread
set background=dark
set belloff=all
set cdpath=,.,~/src,~/
set clipboard=unnamed,unnamedplus
set cmdheight=1
set complete=.,w,b,u,t
set cscopeverbose
set diffopt=internal,filler
set display=lastline
" TODO: 'fillchars' defaults (in effect) to "vert:│,fold:·,sep:│"
set fillchars=
set formatoptions=tcqj
let &keywordprg=":Man"
set nofsync
set guicursor=n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20
set hidden
set history=10000
set hlsearch
set nojoinspaces
set laststatus=2
set listchars=tab:>\ ,trail:-,nbsp:+
set maxcombine=6
set mouse=a
set scroll=13
set scrolloff=0
set sessionoptions-=options
set shortmess=filnxtToOF
set sidescroll=1
set smarttab
set nostartofline
set tabpagemax=50
set tags=./tags;,tags
set notitle
set switchbuf=uselast
set titleold=
set ttimeout
set ttimeoutlen=50
set ttyfast
"TODO: set viewoptions+=unix,slash
set viewoptions-=options
let &viminfo='!,'.&viminfo
let &wildoptions="pum,tagfile"
let g:vimsyn_embed='l'
if exists('$TMUX')
set ttymouse=xterm2
" https://vimhelp.org/term.txt.html#xterm-true-color
" https://gist.github.com/andersevenrud/015e61af2fd264371032763d4ed965b6
" if tmux and not(gVim) and termguicolors
autocmd VimEnter * if !has('gui_running') && has('termguicolors') && &termguicolors
\| let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
\| let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
\| endif
endif
" DIRECTORIES
" These don't always necessarily exist in neovim,
" but are convenient to have for Stdpath()
if ! exists('$XDG_CACHE_HOME')
if has('win32')
let $XDG_CACHE_HOME=$TEMP
else
let $XDG_CACHE_HOME=$HOME . '/.cache'
endif
endif
if ! exists('$XDG_CONFIG_HOME')
if has('win32')
let $XDG_CONFIG_HOME=$LOCALAPPDATA
else
let $XDG_CONFIG_HOME=$HOME . '/.config'
endif
endif
if ! exists('$XDG_DATA_HOME')
if has('win32')
let $XDG_DATA_HOME=$LOCALAPPDATA
else
let $XDG_DATA_HOME=$HOME . '/.local/share'
endif
endif
" Similar to nvim's stdpath(id)
" Unfortunately, user functions can't use lowercase
function! Stdpath(id)
if a:id == 'data'
if has('win32')
return $XDG_DATA_HOME . '/nvim-data'
else
return $XDG_DATA_HOME . '/nvim'
endif
elseif a:id == 'data_dirs'
return []
elseif a:id == 'config'
return $XDG_CONFIG_HOME . '/nvim'
elseif a:id == 'config_dirs'
return []
elseif a:id == 'cache'
return $XDG_CACHE_HOME . '/nvim'
else
throw '"' . a:id . '" is not a valid stdpath'
endif
endfunction
let s:datadir = Stdpath('data')
let &backupdir = s:datadir . '/backup//'
let &viewdir = s:datadir . '/view//'
if ! executable('nvim')
let &directory = s:datadir . '/swap//'
let &undodir = s:datadir . '/undo//'
else
" Vim/NeoVim have different file formats
let &directory = s:datadir . '/vimswap//'
let &undodir = s:datadir . '/vimundo//'
endif
let &viminfofile.=s:datadir . '/viminfo'
" NeoVim creates directories if they don't exist
function! s:MakeDirs()
for dir in [&backupdir, &directory, &undodir, &viewdir]
call mkdir(dir, "p")
endfor
endfunction
autocmd VimEnter * call s:MakeDirs()
" Add user config dirs to search paths
let s:configdir = Stdpath('config')
let s:pathprefix = s:configdir . ',' . s:datadir . '/site,'
let s:pathpostfix = ',' . s:configdir . '/after,' . s:datadir . '/site/after'
let &packpath = s:pathprefix . &packpath . s:pathpostfix
let &runtimepath = s:pathprefix . &runtimepath . s:pathpostfix
" DEFAULT-MAPPINGS
" :help default-mappings
nnoremap Y y$
nnoremap <C-L> <Cmd>nohlsearch<Bar>diffupdate<CR><C-L>
inoremap <C-U> <C-G>u<C-U>
inoremap <C-W> <C-G>u<C-W>
" Implement Q
let g:qreg='@'
function! RecordAndStop()
if reg_recording() == ''
echo 'Enter register to record to: '
let g:qreg=getcharstr()
if g:qreg != "\e"
execute 'normal! q'.g:qreg
endif
else
normal! q
call setreg(g:qreg, substitute(getreg(g:qreg), "q$", "", ""))
endif
endfunction
command! MapQ noremap q :call RecordAndStop()<cr>
noremap Q <Cmd>execute 'normal! @'.g:qreg<cr>
" DEFAULT PLUGINS
if has('syntax') && !exists('g:syntax_on')
syntax enable
endif
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
runtime! macros/matchit.vim
endif
if exists(":Man") != 2
runtime! ftplugin/man.vim
endif
command! UpdateDefaults !curl -LO https://raw.githubusercontent.com/mikeslattery/nvim-defaults.vim/master/.vimrc
" LOAD init.vim
" If this is the .vimrc, not a plugin, then load init.vim
if $MYVIMRC == expand('<sfile>:p')
let $MYVIMRC = s:configdir . '/init.vim'
source $MYVIMRC
endif
if &exrc && filereadable('.nvimrc')
source .nvimrc
endif
" See also:
" https://github.com/noahfrederick/vim-neovim-defaults/blob/master/plugin/neovim_defaults.vim
" https://neovim.io/doc/user/starting.html#startup
" https://neovim.io/doc/user/vim_diff.html
" https://github.com/vim/vim/blob/master/runtime/defaults.vim
" https://github.com/neovim/neovim/blob/master/src/nvim/os/stdpaths.c
" Options were partially determined by running ~/.config/dotfiles/nvim-diff.sh
" TODO:
" default-autocmds
" partial lua support (hard)