NameSizeMode
..
.config/nvim/init.vim 5K ?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
"  _       _ _         _           
" (_)     (_) |       (_)          
"  _ _ __  _| |___   ___ _ __ ___  
" | | '_ \| | __\ \ / / | '_ ` _ \ 
" | | | | | | |_ \ 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 tto store the undo files
set dir=~/.vimswap//,/var/tmp//,/tmp//,.
set undofile                          " Save undos after file closes
set undodir=$XDG_CACHE_HOME/nvim/undo " Where to save undo histories
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", "li", "i", "b"]

  " TODO: Handle the <a> tag better
  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 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 
endfunction

au BufNewFile,BufRead *.html 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 BufNewFile,BufRead *.tikz,*.tex call LaTeXInit()

""" Language-specific stuff

" Highlight .wat files as WebAssembly text format
au BufNewFile,BufRead *.wat               set ft=wast

" Correctly highlight fish scripts
au BufNewFile,BufRead *.fish              set ft=fish

" Read .pl files as Prolog (not Perl)
au BufNewFile,BufRead *.pl                set ft=prolog

" Read .m and .mathematica as Mathematica files
au BufNewFile,BufRead *.m,*.mathematica   set ft=mma

" Read .g and .gap files as GAP source files
au BufRead,BufNewFile *.g,*.gi,*.gd,*.gap set ft=gap 

" Highlight math as LaTeX in Markdown mode
let g:vim_markdown_math = 1

" Saner indenting for Rust
let g:rust_recommended_style = v:false