NameSizeMode
..
.config/nvim/init.vim 6K ?rw-r--r--
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
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
"  _       _ _         _           
" (_)     (_) |       (_)          
"  _ _ __  _| |___   ___ _ __ ___  
" | | '_ \| | __\ \ / / | '_ ` _ \ 
" | | | | | | |_ \ V /| | | | | | |
" |_|_| |_|_|\__(_)_/ |_|_| |_| |_|
" 
" Pablo (C) 2020
"

" turn on syntax highlighting
syntax on
filetype indent plugin on

" configure keybindings
let mapleader = " "
"Maps <Leader><Leader> to 'next window'
map <Leader><Leader> <C-W>w
map <Leader><CR>     :NERDTreeToggle<CR>

" configure tabs so that tabs are expanded to 2 spaces
set tabstop=2 softtabstop=0 expandtab shiftwidth=2 smarttab

" set the column-cap
set colorcolumn=80
set textwidth=79

" highlight the cursor line
set cursorline

" turn-on spell checking
set spell
set spelllang=

" set up the colorscheme
colo snazzy
let g:SnazzyTransparent = 1
let g:lightline = {'colorscheme': 'snazzy',}

" turn on the transparent background
hi Normal ctermbg=NONE guibg=NONE

" fix the highlighting of underlined text
hi Underlined cterm=bold,underline gui=bold,underline ctermbg=none guibg=none

" highlight tyṕos in red
hi clear SpellBad
hi SpellBad cterm=underline gui=underline guifg=#ff5f5f

" set up line numbering
hi LineNr cterm=bold gui=bold
hi CursorLineNr cterm=bold gui=bold ctermfg=White guifg=White
set relativenumber
set number

" configure the directory to store the undo files
" NOTE: `set undofile` has to come AFTER `set undodir`
set dir=~/.vimswap//,/var/tmp//,/tmp//,.
set undodir=$XDG_CACHE_HOME/nvim/undo " where to save undo histories
set undofile                          " save undos after file closes
set undolevels=1000                   " how many undos
set undoreload=10000                  " number of lines to save for undo

" enabling mouse support
set mouse=a

" auto-update a file when it changes externally
set autoread
au CursorHold * checktime

" configure the status line
set noshowmode

" disable the arrow keys
noremap <Up>      <Nop>
noremap <Down>    <Nop>
noremap <Left>    <Nop>
noremap <Right>   <Nop>
noremap <S-Left>  <Nop>
noremap <S-Right> <Nop>

" search/replace the visual selection
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
vnoremap /s y:%s/<C-R>=escape(@",'/\')<CR>//g<Left><Left>

" disable folding
set nofoldenable

" highlight TODO items with multiple 'O's at the end
au Syntax * syn match toodoo /\v<TODO+/ containedin=.*Comment,vimCommentTitle
hi def link toodoo Todo

""" HTML-specific stuff

" begin a HTML tag
function! HTMLBegin(blockname)
  let single_tags = ["br"]
  let inline_tags = ["em", "strong", "sub", "sup", "dt", "i", "b"]
  let li_tags     = ["li", "dt", "dd"]

  if a:blockname =~ "h[1-6]"
    if line(".") == 1
      execute "normal! O<" . a:blockname . "></" . a:blockname . ">\n"
    else
      execute "normal! o<" . a:blockname . "></" . a:blockname . ">\n"
    endif
    execute "normal! k$4h"
    call    feedkeys("i")
  elseif a:blockname == "a"
    let l:url = input("Input URL: ")
    if  l:url == ""
      echo "Aborted"
      return
    endif
    execute "normal! i<a href=\"" . l:url . "\"></a>"
    execute "normal! 3h"
    call    feedkeys("i")
  elseif a:blockname == "ol" || a:blockname == "ul"
    execute "normal! o<" . a:blockname . ">\n<li></li>\n</" . a:blockname . ">\n"
    call    feedkeys("2k4li")
  elseif a:blockname == "dl"
    execute "normal! o<dl>\n<dt></dt>\n</dl>\n"
    call    feedkeys("2k4li")
  elseif index(li_tags, a:blockname) != -1
    execute "normal! o<" . a:blockname . "></" . a:blockname . ">"
    execute "normal! " . (strlen(a:blockname) + 2) . "h"
    call    feedkeys("i")
  elseif index(single_tags, a:blockname) != -1
    execute "normal! a<" . a:blockname . ">"
    call    feedkeys("a")
  elseif index(inline_tags, a:blockname) != -1
    execute "normal! a<" . a:blockname . "></" . a:blockname . ">"
    execute "normal! " . (strlen(a:blockname) + 2) . "h"
    call    feedkeys("i")
  elseif line(".") == 1
    execute "normal! O<" . a:blockname . ">\n</" . a:blockname . ">"
    call    feedkeys("O")
  else
    execute "normal! o<" . a:blockname . ">\n</" . a:blockname . ">\n"
    call    feedkeys("kO")
  endif
endfunction

" converts the characters in the visual section to HTML character codes
command! -range HTMLObfuscate execute "s/[a-zA-Z0-9]/\\=\"&#\" . char2nr(submatch(0)) . \";\"/g | noh"

function! HTMLInit()
  set ft=html
  command! -nargs=1 Begin call HTMLBegin(<f-args>)
  nnoremap BB :Begin

  " disable smart indentation: I like my HTML flat!
  setlocal noautoindent nosmartindent nocindent indentexpr= indentkeys=
endfunction

au BufEnter *.html,/tmp/neomutt-* call HTMLInit()

""" LaTeX-specific stuff

" begin a LaTeX block
function! LaTeXBegin(blockname)
  execute "normal! o\\begin{" . a:blockname . "}\n\\end{" . a:blockname . "}"
  call feedkeys('kA')
endfunction

" enter insert mode inside the \emph macro
function! LaTeXEmph()
  execute "normal! i \\emph{}"
  call feedkeys('i')
endfunction

function! LaTeXInit()
  set ft=tex
  command! -nargs=1 Begin call LaTeXBegin(<f-args>)
  command! -nargs=0 Emph call LaTeXEmph()
  nnoremap BB :Begin
  nnoremap EE :Emph<CR>

  " highlight \mathscr and \mathds as font styles
  syn match texTypeStyle "\\mathcal\>"
  syn match texTypeStyle "\\mathfrak\>"
  syn match texTypeStyle "\\mathbb\>"
  syn match texTypeStyle "\\mathscr\>"
  syn match texTypeStyle "\\mathds\>"

  " highlight \citetitle in the same way as \cite
  syn match texRefZone '\\citetitle\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite

  " highlight stuff inside a align blocks and TikZ environments as math
  call TexNewMathZone("E","align",1)
  call TexNewMathZone("E","gather",1)
  call TexNewMathZone("E","tikzcd",1)
  call TexNewMathZone("E","tikzpicture",1)
  call TexNewMathZone("E","multline",1)
endfunction

au BufEnter *.tikz,*.tex call LaTeXInit()

""" language-specific stuff

au BufEnter *.conf              set ft=dosini
au BufEnter *.wat               set ft=wast
au BufEnter *.fish              set ft=fish
au BufEnter *.pl                set ft=prolog
au BufEnter *.m,*.mathematica   set ft=mma
au BufEnter *.g,*.gi,*.gd,*.gap set ft=gap

au BufEnter *.c,*.h syntax keyword cType u8
au BufEnter *.c,*.h syntax keyword cType u16
au BufEnter *.c,*.h syntax keyword cType u32
au BufEnter *.c,*.h syntax keyword cType u64
au BufEnter *.c,*.h syntax keyword cType i8
au BufEnter *.c,*.h syntax keyword cType i16
au BufEnter *.c,*.h syntax keyword cType i32
au BufEnter *.c,*.h syntax keyword cType i64
au BufEnter *.c,*.h syntax keyword cType f32
au BufEnter *.c,*.h syntax keyword cType f64
au BufEnter *.c,*.h syntax keyword cType b8
hi link cType Type

let g:vim_markdown_math      = 1
let g:rust_recommended_style = v:false