-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
192 lines (167 loc) · 4.18 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
if &compatible
set nocompatible " Be iMproved
endif
source ~/.vim/packages.vim
" {{{ Required:
filetype plugin indent on
syntax on
colorscheme Tomorrow-Night-Eighties
set background=dark
" }}}
let g:airline_powerline_fonts = 1
" {{{ Remap * and # to be smarter
vnoremap <silent> * :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy/<C-R><C-R>=substitute(
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
vnoremap <silent> # :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy?<C-R><C-R>=substitute(
\escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
" }}}
" {{{ Enable UTF-8 if applicable
if has("multi_byte")
if &termencoding == ""
let &termencoding = &encoding
endif
set encoding=utf-8
set termencoding=utf-8
setglobal fileencoding=utf-8
"setglobal bomb
set fileencodings=ucs-bom,utf-8,latin1
endif
" }}}
" {{{ Set up ripgrep
if executable("rg")
set grepprg=rg\ --vimgrep\ --no-heading
set grepformat=%f:%l:%c:%m,%f:%l:%m
let g:ackprg = 'rg --vimgrep --no-heading'
endif
" }}}
" {{{ Common basic options
set laststatus=2
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
set autowrite " Automatically save before commands like :next and :make
set linebreak
set hidden " Hide buffers when they are abandoned
set mouse=a " Enable mouse usage (all modes) in terminals
set modelines=2
set foldmethod=syntax
set foldlevelstart=2
set completeopt=menu
set hlsearch
nnoremap <silent> <Space> :nohlsearch<CR>
set wildignore=*.o,*.pyc,*.pyo,*.class
set ruler
set wildmode=longest,list,full
set wildmenu
set scrolloff=4
set number
set nostartofline
set backspace=indent,eol,start
" }}}
" {{{ Persistent undo
if has('persistent_undo')
set undofile
set undodir=~/.vim/undo
endif
" }}}
" {{{ expand %% to be the currend directory
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
" }}}
" {{{ Switch some mappings to be more to my taste
nnoremap ' `
nnoremap ` '
nnoremap 0 ^
nnoremap ^ 0
nnoremap <C-]> g<C-]>
nnoremap g<C-]> <C-]>
nnoremap Q gq
" }}}
" {{{ Disable help
noremap <F1> <nop>
" }}}
" {{{ junegunn/vim-easy-align
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
" }}}
" {{{ Dispatch configuration
nnoremap <Space>s :Start
nnoremap cm :Make<CR>
nnoremap cd :Dispatch %:p<CR>
nnoremap cD :Dispatch<CR>
" }}}
" {{{ Qa command macro (help my fat fingers)
cnoreabbrev Qa qa
" }}}
" {{{ File navigation hotkeys (C-p)
nnoremap <C-p> :Files<CR>
nnoremap <C-b> :Buffers<CR>
" }}}
" {{{ vim notes
let g:notes_directories = ['~/Sync/vim-notes/']
let g:notes_suffix = '.txt'
let g:notes_word_boundaries = 1
let g:notes_conceal_code = 0
let g:notes_conceal_italic = 0
let g:notes_conceal_bold = 0
" }}}
" {{{ GUndo toggle
function! MyGundoToggle()
let g:gundo_width = &columns / 4
GundoToggle
endfunction
nnoremap <leader>u :call MyGundoToggle()<CR>
let g:gundo_help = 0
" }}}
" {{{ VCS
"let g:VCSCommandCommitOnWrite = 0
"let g:VCSCommandSVNExec="svn.real --username webadmin --password webadmin --non-interactive"
let g:VCSCommandSVNExec="svntr"
" }}}
" {{{ invisible characters
set list
nnoremap <leader>l :set list!<CR>
"set listchars=tab:▸\ ,eol:¬
set listchars=tab:▸\ ,eol:\
highlight NonText ctermfg=darkgreen
highlight SpecialKey ctermfg=darkgreen
" }}}
" {{{ Set tabstop, softtabstop and shiftwidth to the same value
function! Stab(size, ...)
if a:size > 0
let &l:sts = a:size
let &l:ts = a:size
let &l:sw = a:size
endif
call SummarizeTabs()
endfunction
command! -nargs=+ Stab call Stab(<q-args>)
function! SummarizeTabs()
try
echohl ModeMsg
echon 'tabstop='.&l:ts
echon ' shiftwidth='.&l:sw
echon ' softtabstop='.&l:sts
if &l:et
echon ' expandtab'
else
echon ' noexpandtab'
endif
finally
echohl None
endtry
endfunction
" }}}
" {{{ Local overrides
if filereadable(".vimrc_local")
source .vimrc_local
endif
" }}}
" vim: set fdm=marker foldlevel=0: