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
|
runtime! archlinux.vim
set nocompatible
" encodings
scriptencoding utf-8
set fileencoding=utf-8
set encoding=utf-8
set fileformats=unix
" Avoid infinite screen recursion
unlet $SSH_CLIENT
" Set sane defaults, if not using neovim already
if !has('nvim')
let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc"
" Check if the backup/swap dir exists
if !isdirectory($XDG_CACHE_HOME . '/vim')
silent!mkdir -p "$XDG_CACHE_HOME/vim"
endif
set directory=$XDG_CACHE_HOME/vim,/tmp
set backupdir=$XDG_CACHE_HOME/vim,/tmp
if has('viminfo')
set viminfo=%,'10,<10,/200,:200,h,n$XDG_CACHE_HOME/vim/.viminfo
endif
" Fix shift-tab
exe 'set t_kB=' . nr2char(27) . '[Z'
" Everything apparently breaks (in Neovim) if setting background = dark
set bg=dark
syntax enable
filetype plugin indent on
endif
set runtimepath=$XDG_CONFIG_HOME/vim,$XDG_CONFIG_HOME/vim/after,$VIM,$VIMRUNTIME,$VIM/vimfiles,$VIM/vimfiles/after,$VIM/vimfiles/plugin
" behaviour
set history=1024
set wildmenu
set ruler
set cursorline
set showmatch
set hlsearch
set incsearch
set backspace=indent,eol,start
set laststatus=2
set number
set splitright
set conceallevel=2
set scrolloff=0
set sidescrolloff=1
set display+=truncate
"" Format options see :help fo-<CHARACTER> for help on each of the options
" Autowrap text and comments using `textwidth`, autoinsert comment-leader, and
" other leaders when wrapping, also with `gq`.
set formatoptions=tcro/q
" Recognize numbered lists
set formatoptions+=n
" Autowrap lines.
set formatoptions+=bl1
" Remove comment leader when joining lines
set formatoptions+=j
"
set formatoptions+=p
set nowrap
set textwidth=80
set colorcolumn=81
" tabs
set expandtab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set smartindent
set smarttab
" Sets terminal title to current filename
set title
" Search up in every parent dir for a tags file.
if has('path_extra') && (',' . &g:tags . ',') =~# ',\./tags,'
setglobal tags-=./tags tags-=./tags; tags^=./tags;
endif
" Allow color schemes to do bright colors without forcing bold.
if &t_Co == 8 && $TERM !~# '^Eterm'
set t_Co=16
endif
" Enable mouse support
set mouse=a
" Set clipboard to system one
set clipboard+=unnamedplus
" netrw settings
let g:netrw_banner=0
let g:netrw_browse_split=1
let g:netrw_altv=4
" thematics
set listchars=tab:\ \ >,extends:…,precedes:…
set list
" Enable termguicolors
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
" Remove trailing cancer on write
autocmd BufWritePre * %s/\s\+$//e
let mapleader=","
" Move around in insert mode with Alt+{hjkl}
inoremap <A-h> <Left>
inoremap <A-l> <Right>
inoremap <A-k> <Up>
inoremap <A-j> <Down>
nnoremap <A-h> <C-w>h
nnoremap <A-j> <C-w>j
nnoremap <A-k> <C-w>k
nnoremap <A-l> <C-w>l
" Go to end/start of line, like in the shell
imap <C-E> <ESC>A
imap <C-A> <ESC>I
cmap <C-A> <Home>
cmap <C-E> <End>
" Search for VISUAL-highlighted text (very brittle)
vmap // y/\V<C-R>"<CR>
" Wrap selection in parenthesis, hard or soft brackets
vnoremap <leader>( <ESC>`>a)<ESC>`<i(<ESC>
vnoremap <leader>[ <ESC>`>a]<ESC>`<i[<ESC>
vnoremap <leader>{ <ESC>`>a}<ESC>`<i{<ESC>
""" X11 specific stuff, that is also only relevant with vim
"" Preserve clipboard only relevant if !has('nvim')
"autocmd VimLeave * call system("xsel -ib", getreg())
"autocmd VimSuspend * call system("xsel -ib", getreg())
"" Turn on capslock LED when in insert mode.
"augroup CapsLockLED
" autocmd!
" autocmd InsertEnter * :silent !xset led named 'Caps Lock'
" autocmd InsertLeave * :silent !xset -led named 'Caps Lock'
" autocmd VimLeave * :silent !xset -led named 'Caps Lock'
"augroup END
"" Plugin settings
" junegunn/fzf.vim bindings
noremap <C-f> :Files<cr>
noremap <C-b> :Buffers<cr>
"" Alternatively use telescope (if on neovim)
"noremap <C-f> :Telescope find_files<cr>
"noremap <C-f> :Telescope buffers<cr>
" lervag/vimtex
let g:tex_flavor='latex'
let g:vimtex_view_method='zathura'
let g:vimtex_quickfix_mode=0
let g:tex_conceal='abdmg'
let g:vimtex_parser_bib_backend = 'bibtex'
let g:vimtex_compiler_method = 'latexrun'
let g:vimtex_compiler_latexrun = {
\ 'backend' : 'jobs',
\ 'background' : 1,
\ 'build_dir' : 'latex.out',
\ 'options' : [
\ '-verbose-cmds',
\ '--latex-args="-synctex=1"',
\ ],
\}
let g:latex_view_general_viewer = 'zathura'
let g:vimtex_view_method = 'zathura'
" tpope/vim-markdown specific settings
let g:markdown_fenced_languages = ['c', 'css', 'sh', 'vim', 'futhark', 'haskell']
"if has("autocmd")
" augroup templates
" autocmd BufNewFile *.h 0r $XDG_CONFIG_HOME/vim/templates/skeleton.h
" autocmd BufNewFile *.h "s/<++DEF++>/" toupper(expand('%:t:r') . "_" . expand('%:e')))
" augroup END
"endif
" Change cursor to block
" 1 -> solid underscore
" 2 -> block
" 4 -> underline
" 5 -> blinking vertical bar
" 6 -> solid vertical bar
" 7 -> snowman
"autocmd VimEnter * silent execute "!echo -e '\e[2 q'"
"autocmd VimResume * silent execute "!echo -e '\e[2 q'"
"autocmd VimLeave * silent execute "!echo -e '\e[6 q'"
"autocmd InsertEnter * silent execute "!echo -ne '\e[6 q'"
"autocmd InsertLeave * silent execute "!echo -ne '\e[2 q'"
" "Start Insert-mode" line
let &t_SI = "\e[6 q"
" "Start Replace-mode" underscore
let &t_SR = "\e[4 q"
" "End Insert-mode" block
let &t_EI = "\e[2 q"
"autocmd VimResume * silent execute "!echo -e '\e[2 q'"
"" Undercurls/spelling
let &t_Cs = "\e[4:3m"
let &t_Ce = "\e[4:0m"
if !has('nvim')
highlight SpellBad guisp=red gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl ctermul=red
highlight SpellCap guisp=yellow gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl ctermul=yellow
endif
if has('nvim')
call plug#begin()
Plug 'neovim/nvim-lspconfig'
" deps for haskell-tools.nvim
Plug 'nvim-lua/plenary.nvim'
Plug 'mfussenegger/nvim-dap'
Plug 'phoityne/haskell-debug-adapter'
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.1' }
Plug 'nvim-treesitter/nvim-treesitter'
" For Haskell LSP (hls)
Plug 'mrcjkb/haskell-tools.nvim'
Plug 'neovimhaskell/haskell-vim'
" Fuzzy Wuzzy Finding
Plug 'junegunn/fzf.vim'
" VimTex
Plug 'lervag/vimtex'
Plug 'tpope/vim-markdown'
"" Colorschemes
"Plug 'bluz71/vim-moonfly-colors', { 'as': 'moonfly' }
"Plug 'pineapplegiant/spaceduck', { 'branch': 'main' }
Plug 'ghifarit53/tokyonight-vim'
"Plug 'folke/tokyonight.nvim'
Plug 'oxfist/night-owl.nvim'
Plug '0undefined/futhark.vim'
call plug#end()
endif
"autocmd FileType markdown
" \ set formatoptions-=q |
" \ set formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*\[-*+]\\s\\+
autocmd FileType markdown set comments-=mb:*
autocmd FileType markdown set comments-=mb:+
autocmd FileType markdown set comments-=mb:-
autocmd FileType markdown set formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*\[-*+]\\s\\+
if has('nvim')
colorscheme night-owl
else
colorscheme tokyonight
endif
|