blob: 0955b907c5245bc666e74bffe3a1017a00a707a0 (
plain)
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
|
""""""""""""
" VUNDLE "
""""""""""""
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
"FILETYPES
Plugin 'kchmck/vim-coffee-script'
Plugin 'plasticboy/vim-markdown'
Plugin 'zah/nim.vim'
Plugin 'wlangstroth/vim-racket'
Plugin 'rust-lang/rust.vim'
Plugin 'cespare/vim-toml'
"FUNCTIONALITY
Plugin 'junegunn/vim-easy-align'
Plugin 'xolox/vim-misc'
Plugin 'xolox/vim-easytags'
Plugin 'lilydjwg/fcitx.vim'
Plugin 'airblade/vim-gitgutter'
Plugin 'itchyny/lightline.vim'
Plugin 'tomtom/tcomment_vim'
Plugin 'SirVer/ultisnips'
Plugin 'kiith-sa/DSnips'
call vundle#end()
"""""""""""""""""""""
" PLUGIN SETTINGS "
"""""""""""""""""""""
"Start interactive EasyAlign in visual mode (e.g. vip<Enter>)
vmap <Enter> <Plug>(EasyAlign)
"Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
"timeout on keycodes to prevent fcitx-switcher from lagging
set ttimeoutlen=100
"vertical split ultisnips edit
let g:UltiSnipsEditSplit="vertical"
let g:UltiSnipsJumpForwardTrigger="<c-f>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
""""""""""""""""""""""
" GENERAL SETTINGS "
""""""""""""""""""""""
syntax on
filetype plugin indent on
set autoindent
colorscheme shmibs
"enable status-line
set laststatus=2
"hide mode in cmd
set noshowmode
"allow edited background buffers
set hidden
"spelling
set spelllang=en_gb
"gvim-specific settings
set guifont=Tamsyn\ 11
set guioptions=aegimt
"visual marker for overflowing the 80th column
highlight Column80 ctermbg=black
call matchadd('Column80', '\%81v', 100)
"highlight space before tab
highlight SpaceBeforeTab ctermbg=black
call matchadd('SpaceBeforeTab', '^\ \+\t')
"""""""""""""
" ALIASES "
"""""""""""""
"i keep accidentally typing these over and over
command W w
command Wq wq
command WQ wq
command Q q
command E e
""""""""""""""
" MAPPINGS "
""""""""""""""
"insert lines below
nnoremap <silent>= :set paste<CR>m`O<Esc>``:set nopaste<CR>
"folds!
nnoremap fo zO
nnoremap fc zC
nnoremap fm zM
nnoremap fr zR
"buffer-handling
nnoremap <C-j> :bn<CR>
nnoremap <C-k> :bp<CR>
nnoremap <C-g> :buffers<CR>:b<Space>
"copy words from above and below the cursor
inoremap <expr> <C-y> pumvisible() ? "\<C-y>" : matchstr(getline(line('.')-1), '\%' . virtcol('.') . 'v\%(\k\+\\|.\)')
inoremap <expr> <C-e> pumvisible() ? "\<C-e>" : matchstr(getline(line('.')+1), '\%' . virtcol('.') . 'v\%(\k\+\\|.\)')
"use the X clipboard for things when running in a virtual terminal, because yes
if &term != "linux" && has('clipboard')
nnoremap <expr> y (v:register ==# '"' ? '"+' : '') . 'y'
nnoremap <expr> Y (v:register ==# '"' ? '"+' : '') . 'Y'
xnoremap <expr> y (v:register ==# '"' ? '"+' : '') . 'y'
xnoremap <expr> Y (v:register ==# '"' ? '"+' : '') . 'Y'
nnoremap <expr> d (v:register ==# '"' ? '"+' : '') . 'd'
nnoremap <expr> D (v:register ==# '"' ? '"+' : '') . 'D'
xnoremap <expr> d (v:register ==# '"' ? '"+' : '') . 'd'
xnoremap <expr> D (v:register ==# '"' ? '"+' : '') . 'D'
nnoremap <expr> p (v:register ==# '"' ? '"+' : '') . 'p'
nnoremap <expr> P (v:register ==# '"' ? '"+' : '') . 'P'
xnoremap <expr> p (v:register ==# '"' ? '"+' : '') . 'p'
xnoremap <expr> P (v:register ==# '"' ? '"+' : '') . 'P'
end
"""""""""""""""""""""""
" FILETYPE SETTINGS "
"""""""""""""""""""""""
"annoying syntax-related values that need to be set before files are
"opened
let g:c_no_comment_fold = 1
let g:c_no_if0_fold = 1
let g:sh_fold_enabled = 1
if has("autocmd")
"always use rust instead of hercules
autocmd BufNewFile,BufRead *.rs set filetype=rust
"always use LaTeX
autocmd BufNewFile,BufRead *.tex set filetype=tex
"other filetype-specific settings. i can't figure out how to stick all
"the FileTypes in one dict (mostly because i have no idea what i'm
"doing with viml), so separate lines it is.
autocmd FileType asm call Settings_asm()
autocmd FileType c call Settings_c()
autocmd FileType coffee call Settings_coffee()
autocmd FileType cpp call Settings_c()
autocmd FileType css call Settings_c()
autocmd FileType d call Settings_c()
autocmd FileType tex call Settings_tex()
autocmd FileType haskell call Settings_haskell()
autocmd FileType html call Settings_html()
autocmd FileType xhtml call Settings_html()
autocmd FileType make call Settings_script()
autocmd FileType matlab call Settings_matlab()
autocmd FileType mkd call Settings_text()
autocmd FileType nim call Settings_nim()
autocmd FileType perl call Settings_script()
autocmd FileType php call Settings_html()
autocmd FileType python call Settings_script()
autocmd FileType ruby call Settings_script()
autocmd FileType rust call Settings_rust()
autocmd FileType sh call Settings_script()
autocmd FileType text call Settings_text()
autocmd FileType vim call Settings_vim()
autocmd FileType zsh call Settings_script()
function! Settings_asm()
"settings
setlocal foldmethod=syntax
"mappings
nnoremap <buffer> -- A<Tab>;<Space>
endfunction
function! Settings_c()
"settings
setlocal foldmethod=syntax
setlocal shiftwidth=4
setlocal tabstop=4
setlocal softtabstop=4
"mappings
nnoremap <buffer> -- O<Space>*/<Esc>hhi/*<Space>
endfunction
function! Settings_coffee()
"settings
setlocal foldmethod=syntax
setlocal shiftwidth=2
setlocal tabstop=2
setlocal softtabstop=2
"mappings
nnoremap <buffer> -- O#<Space>
endfunction
function! Settings_haskell()
"settings
setlocal shiftwidth=4
setlocal tabstop=4
setlocal softtabstop=4
setlocal expandtab
"mappings
nnoremap <buffer> -- O--<Space>
endfunction
function! Settings_html()
"settings
setlocal foldmethod=syntax
setlocal shiftwidth=4
setlocal tabstop=4
setlocal softtabstop=4
"mappings
nnoremap <buffer> -- O<Space>--><Esc>hhhi<!--<Space>
endfunction
function! Settings_matlab()
"settings
"mappings
nnoremap <buffer> -- O%<Space>
endfunction
function! Settings_nim()
call Settings_script()
function! JumpToDef()
if exists("*GotoDefinition_" . &filetype)
call GotoDefinition_{&filetype}()
else
execute "norm! <C-]>"
endif
endfunction
"mappings
nnoremap <buffer> <M-g> :call JumpToDef()<cr>
inoremap <buffer> <M-g> <esc>:call JumpToDef()<cr>i
nnoremap <buffer> -_ O##<Space>
endfunction
function! Settings_python()
call Settings_script()
"settings
setlocal expandtab
"mappings
endfunction
function! Settings_script()
"settings
setlocal shiftwidth=4
setlocal tabstop=4
setlocal softtabstop=4
"mappings
nnoremap <buffer> -- O#<Space>
endfunction
function! Settings_rust()
call Settings_c()
nnoremap <buffer> -_ O///<Space>
endfunction
function! Settings_tex()
"settings
setlocal noautoindent
setlocal nocindent
setlocal nosmartindent
setlocal shiftwidth=4
setlocal tabstop=4
setlocal softtabstop=4
"mappings
nnoremap <buffer> -- O%<Space>
nnoremap <buffer> <Leader>c :!latex -output-format=pdf "%"<CR><CR>
nnoremap <buffer> <Leader>C :!latex -output-format=pdf "%"<CR>
endfunction
function! Settings_text()
setlocal formatoptions+=ta
setlocal noautoindent
setlocal nocindent
setlocal nosmartindent
setlocal tabstop=4
setlocal softtabstop=4
setlocal spell
endfunction
function! Settings_vim()
"settings
setlocal shiftwidth=4
setlocal tabstop=4
setlocal softtabstop=4
"mappings
nnoremap <buffer> -- O"
endfunction
endif "autocmd
|