Merge commit 'f035c9318b23aea7479c124d749f5678c060e7b3'

This commit is contained in:
2025-10-21 00:00:41 +02:00
57 changed files with 1143 additions and 1677 deletions

View File

@@ -0,0 +1,37 @@
vim.cmd([[
function GetClozeNumber()
let REGEX_CLOZE_START = '{{c\d\+::'
" Find previous cloze match
let prev_match = searchpos(REGEX_CLOZE_START, 'bW', line("gg"))
" Only get number if cloze was matched (i.e. when cursor does not end up at
" start of file)
if max(prev_match) != 0
" Get word under cursor (ignoring curly braces and `::`),
" get the second character of the word and cast it to an int
" add one for the next cloze number
return str2nr(expand("<cword>")[1]) + 1
else
return 1
endif
endfunction
" Wrap the next cloze number
function GetClozeStart()
return "{{c" . GetClozeNumber() . "::"
endfunction
function GetClozeEnd()
return "}}"
endfunction
let g:sandwich#recipes += [
\ {
\ 'buns': ['GetClozeStart()', 'GetClozeEnd()'],
\ 'expr' : 1,
\ 'filetype': ['pandoc'],
\ 'input': ['c'],
\ 'nesting': 1
\ }
\ ]
]])

View File

@@ -0,0 +1,5 @@
vim.cmd([[
" Paste clipboard images
au FileType pandoc nmap <buffer><silent> <leader>v :call mdip#MarkdownClipboardImage()<CR>
au FileType markdown nmap <buffer><silent> <leader>v :call mdip#MarkdownClipboardImage()<CR>
]])

View File

@@ -1,3 +1,5 @@
vim.env.ESLINT_D_PPID = vim.fn.getpid()
local eslint_linter = "eslint_d"
require("lint").linters_by_ft = {

View File

@@ -0,0 +1,5 @@
vim.cmd([[
nmap s <Nop>
xmap s <Nop>
let g:sandwich#recipes = deepcopy(g:sandwich#default_recipes)
]])

View File

@@ -0,0 +1,6 @@
vim.cmd([[
let g:taskwiki_taskrc_location='/home/h/.config/task/taskrc'
let g:taskwiki_disable_concealcursor=1
let g:taskwiki_dont_preserve_folds=1
let g:taskwiki_dont_fold=1
]])

View File

@@ -0,0 +1,8 @@
vim.cmd([[
let g:javascript_plugin_jsdoc = 1 " jsdoc syntax highlighting
let g:javascript_plugin_flow = 1 " flow syntax highlighting
let g:javascript_conceal_function = "ƒ"
let g:javascript_conceal_return = "⇖"
let g:svelte_indent_script = 0
let g:svelte_indent_style = 0
]])

View File

@@ -0,0 +1,17 @@
vim.cmd([[
let g:pandoc#syntax#conceal#urls=1
let g:pandoc#syntax#codeblocks#embeds#langs=[
\ 'python',
\ 'bash',
\ 'javascript',
\ 'typescript',
\ 'html',
\ 'css',
\ 'scss',
\ 'json',
\ 'yaml'
\ ]
let g:pandoc#syntax#style#emphases=0 " Bug workaround
let g:pandoc#syntax#conceal#cchar_overrides = { "atx": " ", "li": "·" }
let g:pandoc#syntax#conceal#blacklist=[]
]])

View File

@@ -0,0 +1,9 @@
vim.cmd([[
au FileType pandoc call pandoc#completion#Init()
let g:pandoc#filetypes#pandoc_markdown=0
let g:pandoc#spell#enabled=0
let g:pandoc#spell#default_langs=['en_us', 'nl_be']
let g:pandoc#formatting#mode='a'
let g:pandoc#formatting#textwidth=90
let g:pandoc#modules#disabled = ["formatting", "dashes", "yaml", "metadata"]
]])

View File

@@ -0,0 +1,16 @@
vim.cmd([[
" Tidalcycles (sclang and vim-tidal)
let g:tidal_default_config = {"socket_name": "default", "target_pane": "tidal:1.1"}
let g:tidal_no_mappings = 1
au FileType tidal nm <buffer> <leader>ep <Plug>TidalParagraphSend
au FileType tidal nm <buffer> <leader>ee <Plug>TidalLineSend
au FileType tidal nnoremap <buffer> <leader>h :TidalHush<cr>
au FileType tidal com! -nargs=1 S :TidalSilence <args>
au FileType tidal com! -nargs=1 P :TidalPlay <args>
au FileType tidal com! -nargs=0 H :TidalHush
" SuperCollider
au BufEnter,BufWinEnter,BufNewFile,BufRead *.sc,*.scd se filetype=supercollider
au Filetype supercollider packadd scvim
]])

View File

@@ -0,0 +1,6 @@
vim.cmd([[
let g:vimtex_view_method='zathura'
let g:tex_flavor='latex'
let g:tex_conceal='abdmgs'
let g:vimtex_quickfix_mode=0
]])

View File

@@ -0,0 +1,110 @@
vim.cmd([[
" Change local buffer to directory of current file after the plugin has loaded
autocmd VimEnter * lcd %:p:h
" " Override wiki index mapping to also cd into the wiki
nm <leader>ww <plug>(wiki-index)
" nm <leader>l <plug>(wiki-next-link)
" nm <leader>h <plug>(wiki-prev-link)
" nm <leader>j <plug>(wiki-link-follow)
" nm <leader>k <plug>(wiki-link-return)
" nm <leader>s <plug>(wiki-link-follow-split)
" nm <leader>v <plug>(wiki-link-follow-vsplit)
autocmd BufEnter *.md if expand('%:t') =~ '_' | echo 'hierarchical relation' | endif
autocmd BufEnter *.md if expand('%:t') =~ '--' | echo 'relation' | endif
autocmd BufEnter *.md if expand('%:t') =~ '<>' | echo 'dichotomy' | endif
autocmd BufEnter *.md if expand('%:t') =~ 'my-' | echo 'personal file' | endif
autocmd BufEnter *.md if expand('%:t') =~ 'project_' | echo 'project file' | endif
" Only load wiki.vim for zk directory
let g:wiki_index_name='index'
" Links
let g:wiki_link_extension=''
" Do not automatically transform to link, use `<leader>wf` for this
let g:wiki_link_target_type='md'
vmap <leader>wf <plug>(wiki-link-toggle-visual)
"
" Links
"
"
" Options
"
"
" Events
"
"
" Mappings and commands
"
"
" Completion
"
let g:wiki_completion_enabled=1
let g:wiki_completion_case_sensitive=0
"
" Tags
"
"
" Templates
"
let g:wiki_templates = [
\ { 'match_re': '^my-',
\ 'source_filename': '.my.md'},
\ { 'match_re': '^project[-_]',
\ 'source_filename': '.project.md'},
\ { 'match_re': '^blog[-_]',
\ 'source_filename': '.blog.md'},
\ { 'match_re': '^journal[-_]',
\ 'source_filename': '.journal.md'},
\ { 'match_func': { x -> v:true },
\ 'source_filename': '.md'},
\]
"
" Advanced configuration
"
let g:wiki_filetypes=['md']
let g:wiki_root='~/.zk'
let g:wiki_global_load=0
let g:wiki_link_creation = {
\ 'md': {
\ 'link_type': 'md',
\ 'url_extension': '',
\ 'url_transform': { x -> substitute(tolower(x), '\s\+', '-', 'g') },
\ },
\ '_': {
\ 'link_type': 'wiki',
\ 'url_extension': '',
\ },
\}
" let g:wiki_link_default_schemes
" let g:wiki_link_schemes
let g:wiki_link_toggle_on_follow=0
" let g:wiki_link_transforms
" let g:wiki_mappings_use_defaults
" let g:wiki_mappings_global
" let g:wiki_mappings_local
" let g:wiki_mappings_local_journal
" ... tags
" let g:wiki_template_month_names
" let g:wiki_template_title_month =
" let g:wiki_template_title_week
" let g:wiki_ui_method
let g:wiki_write_on_nav=1
let g:wiki_zotero_root='~/.local/share/zotero'
" ... mappings and commands
" ...
]])

View File

@@ -0,0 +1,7 @@
vim.cmd([[
syn match Todo /TODO/
syn match Todo /FIXME/
syn match Todo /FIX/
syn match Todo /QUESTION/
syn match Todo /NOTE/
]])

View File

@@ -0,0 +1,26 @@
vim.cmd([[
" Override the pandoc-syntax highlighting colors for more subtle citations
hi! link pandocPCite Comment
hi! link pandocICite Comment
hi! link pandocCiteKey Comment
hi! link pandocCiteAnchor Comment
hi! link pandocCiteLocator Comment
" Match cloze delimiters e.g. `{{c1::` and `}}`
syn match ClozeDelimiter /{{c\d\+::/ conceal containedin=pandocUListItem,pandocListItem
syn match ClozeDelimiter /}}/ conceal containedin=pandocUListItem,pandocListItem
" Match text between cloze delimiters
syn match Cloze /\({{c\d\+::\)\@<=\(\_[A-Za-z0-9$\ \\\-\*,_`()]*\)\(}}\)\@=/ containedin=pandocUListItem,pandocListItem
hi! link ClozeDelimiter Special
hi! link Cloze Special
" Fix task UUIDs not being highlighted correctly in pandoc lists
syn match pandocUListItem /^>\=\s*[*+-]\s\+-\@!.*$/ nextgroup=pandocUListItem,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocEscapedDollar,pandocDelimitedCodeBlock,pandocListItemContinuation contains=@Spell,pandocEmphasis,pandocStrong,pandocNoFormatted,pandocStrikeout,pandocSubscript,pandocSuperscript,pandocStrongEmphasis,pandocStrongEmphasis,pandocPCite,pandocICite,pandocCiteKey,pandocReferenceLabel,pandocLaTeXCommand,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocEscapedDollar,pandocReferenceURL,pandocAutomaticLink,pandocFootnoteDef,pandocFootnoteBlock,pandocFootnoteID,pandocAmpersandEscape,TaskWikiTaskUuid skipempty display
syn match TaskWikiTaskUuid containedin=TaskWikiTask /\v#([A-Z]:)?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/
syn match TaskWikiTaskUuid containedin=TaskWikiTask /\v#([A-Z]:)?[0-9a-fA-F]{8}$/
highlight link TaskWikiTaskUuid Comment
]])
vim.cmd.runtime("syntax/_comment_keywords.lua")

View File

@@ -0,0 +1,7 @@
vim.cmd([[
syn keyword Operator \+ conceal cchar=¬
syn keyword Operator , conceal cchar=∧
syn keyword Operator ; conceal cchar=
]])
vim.cmd.runtime("syntax/_comment_keywords.lua")

View File

@@ -0,0 +1,41 @@
vim.cmd([[
syntax keyword Statement define conceal cchar=≔
syn keyword Operator not conceal cchar=¬
syn keyword Operator and conceal cchar=∧
syn keyword Operator or conceal cchar=
syn keyword Operator mod conceal cchar=%
syn keyword Operator exp conceal cchar=^
syn keyword Operator sqrt conceal cchar=√
syn keyword Operator quote conceal cchar='
" Conceal greek letters
syn keyword Operator alpha conceal cchar=α
syn keyword Operator beta conceal cchar=β
syn keyword Operator gamma conceal cchar=γ
syn keyword Operator delta conceal cchar=δ
syn keyword Operator epsilon conceal cchar=ε
syn keyword Operator zeta conceal cchar=ζ
syn keyword Operator eta conceal cchar=η
syn keyword Operator theta conceal cchar=θ
syn keyword Operator iota conceal cchar=ι
syn keyword Operator kappa conceal cchar=κ
syn keyword Operator lambda conceal cchar=λ
syn keyword Operator mu conceal cchar=μ
syn keyword Operator nu conceal cchar=ν
syn keyword Operator xi conceal cchar=ξ
syn keyword Operator omicron conceal cchar=ο
syn keyword Operator pi conceal cchar=π
syn keyword Operator rho conceal cchar=ρ
syn keyword Operator sigma conceal cchar=σ
syn keyword Operator tau conceal cchar=τ
syn keyword Operator upsilon conceal cchar=υ
syn keyword Operator phi conceal cchar=φ
syn keyword Operator chi conceal cchar=χ
syn keyword Operator psi conceal cchar=ψ
syn keyword Operator omega conceal cchar=ω
]])
vim.cmd.runtime("syntax/_comment_keywords.lua")

View File

@@ -0,0 +1 @@
vim.opt.matchpairs:append("=:;")

View File

@@ -1,15 +0,0 @@
-- NOTE: May want to move this, as it is more specific to wiki than to pandoc
vim.api.nvim_create_user_command("AnkiDeck", function()
local handle = io.popen("get-anki-decks")
local decks = {}
for line in handle:lines() do
table.insert(decks, line)
end
handle:close()
vim.ui.select(decks, { prompt = "Select Anki deck" }, function(choice)
if choice then
vim.api.nvim_put({ choice }, "", true, true)
end
end)
end, {})

View File

@@ -0,0 +1,24 @@
vim.cmd([[
" Anki helper functions
" Convert cloze note to regular text
"
" * `AnkiRemoveAllClozes` all cloze notes in file
" * `AnkiRemoveSelectedClozes` all clozes in selected range
"
" E.g.
"
" ```markdown
" START
" Cloze
" In this sentence {{c1::this word}} was closed.
" END
" ```
"
" ```markdown
" In this sentence this word was closed.
" ```
au FileType pandoc com! -range AnkiRemoveAllClozes :%s/\%V{{c\d\+:://ge | :%s/\%V}}//ge | :%s/\%VSTART\nCloze\n//ge | :%s/\%VEND\n//ge
au FileType pandoc com! -range AnkiRemoveSelectedClozes :%s/\%V{{c\d\+:://ge | :%s/\%V}}//ge | :%s/\%VSTART\nCloze\n//ge | :%s/\%VEND\n//ge
]])

View File

@@ -0,0 +1,37 @@
-- NOTE: May want to move this, as it is more specific to wiki than to pandoc
vim.api.nvim_create_user_command("AnkiDeck", function()
local handle = io.popen("get-anki-decks")
local decks = {}
for line in handle:lines() do
table.insert(decks, line)
end
handle:close()
vim.ui.select(decks, { prompt = "Select Anki deck" }, function(choice)
if choice then
vim.api.nvim_put({ choice }, "", true, true)
end
end)
end, {})
vim.cmd([[
set cc=81
set cocu=""
func! GetContext()
" https://stackoverflow.com/questions/9464844/how-to-get-group-name-of-highlighting-under-cursor-in-vim
if !exists("*synstack")
return
endif
let matches = map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
if index(matches, 'pandocLaTeXInlineMath') >= 0
echo 'math_inline'
elseif index(matches, 'pandocLaTeXMathBlock') >= 0
echo 'math_block'
elseif !empty(matches)
echo matches[0]
else
echo ''
endif
endfunc
com! -nargs=0 GetContext :call GetContext()
]])

View File

@@ -0,0 +1,27 @@
vim.cmd([[
"
" Source: https://wiki.call-cc.org/vim / Jonathan Palardy
"
" Note, this is assuming you have an R5RS Scheme REPL runnning in the second
" TMUX pane.
" Send `(load <current-file>)` to tmux pane
nmap <leader>rf :call Scheme_send_sexp("(#%require xrepl)(load \"" . expand("%:p") . "\")\n")<cr>
nmap <leader>re :call Scheme_eval_defun()<cr>
" Send s-expression to TMUX buffer
fun! Scheme_send_sexp(sexp)
let ss = escape(a:sexp, '\"')
" Send to second tmux pane
call system("tmux send-keys -t 1 \"" . ss . "\n\"")
endfun
" Send s-expression under cursor to TMUX buffer
fun! Scheme_eval_defun()
let pos = getpos('.')
silent! exec "normal! 99[(yab"
call Scheme_send_sexp(@")
call setpos('.', pos)
endfun
]])

View File

@@ -1,12 +1,29 @@
require("nixCatsUtils").setup({ non_nix_value = true }) -- https://github.com/BirdeeHub/nixCats-nvim/blob/77dffad8235eb77684fcb7599487c8e9f23d5b8f/templates/example/init.lua
require("vim")
vim.cmd([[
set termguicolors
set bg=light
hi Normal ctermbg=none guibg=NONE
]])
require("base")
require("cursor")
require("fold")
require("netrw")
require("ftdetect")
require("plug")
require("pandoc")
require("keymaps")
require("highlight")
require("paq-setup")
require("statusline")
require("diagnostic")
require("utils")
require("zk")
require("reload")
require("paq-setup") -- when not on nixCats
-- vim.opt.background = "dark"
-- vim.opt.laststatus = 3
vim.opt.laststatus = 3

View File

@@ -0,0 +1,30 @@
vim.cmd([[
" Tip: acronyms for overview, use `:h` for a quick lookup.
set nocp " Disable vi incompatibility
filetype plugin indent on " Filetype recognition
set enc=utf8 " Default to UTF-8 encoding
set hid " Allow hiding unsaved buffers
set tf " Fast tty
set ut=300 " 300ms for update time
set to tm=200 ttm=5 " Timeouts
set shm+=c " ...
set ul=500 hi=500 " History and undo
set nu rnu scl=number " Line numbers & signs
set nowrap
set bs=indent,eol,start " Indentation
set ai ts=2 sts=2 sw=2 et " Indentation
set is ic scs hls " Search
set lz " Only essential redraws
set nobk nowb noswf " No backups
set vi='20,\"101 " Max 100 lines in registers
set novb " Bell
set cole=0 cocu="" " Conceal
set cb=unnamedplus " Clipboard
set fcs+=vert:│ " Cleaner split separator (tmux style)
set list
set lcs=trail:·,tab:→\ ,nbsp:␣ " Whitespace rendering
set ar " Autoread
set spellsuggest+=5 " Limit spell suggestions
set wildignore+=*/node_modules/*,*/tmp/*,*.so,*.swp,*.zip
" set thesaurus+=./thesaurus/mthesaur.txt " FIXME
]])

View File

@@ -0,0 +1,16 @@
vim.cmd([[
" Taken from /usr/share/vim/vim90/defaults.vim
augroup vimStartup
au!
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid, when inside an event handler
" (happens when dropping a file on gvim) and for a commit message (it's
" likely a different one than last time).
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\""
\ | endif
augroup END
]])

View File

@@ -0,0 +1,26 @@
vim.cmd([[
" Folds {{{
set foldmethod=marker
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
augroup filetype_python
autocmd!
autocmd FileType python setlocal foldmethod=indent
augroup END
augroup filetype_sh
autocmd!
autocmd FileType sh setlocal foldmethod=marker
augroup END
augroup filetype_snippets
autocmd!
autocmd FileType snippets setlocal foldmethod=marker
augroup END
" }}}
]])

View File

@@ -7,5 +7,6 @@ vim.filetype.add({
[".*/%.vscode/.*%.json"] = "jsonc",
[".*/%.ssh/config%.d/.*"] = "sshconfig",
["%.env.*"] = "dotenv",
["%.pl$"] = "prolog",
},
})

View File

@@ -1,3 +1,50 @@
vim.cmd([[
" Leader keys
let mapleader = " "
let maplocalleader = ";"
" Splits & navigation
nm s <c-w> " Split horizontal
nm ss :sp<CR><c-w>w| " Split horizontal
nm sv :vs<CR><c-w>w| " Split vertical
nm sw <c-w>w| " Navigate splits
nm sh <c-w>h| "
nm sj <c-w>j| "
nm sk <c-w>k| "
nm sl <c-w>l| "
nn sH <c-w>8<| " Resize splits
nn sJ <c-w>8-| "
nn sK <c-w>8+| "
nn sL <c-w>8>| "
nn s= <c-w>=| " Equalize splits
" Open
nn sb :Lex<cr>| " File tree
nn <leader><leader> :noh<cr> |"
nn <leader>t :term<cr>| " Open terminal
" Remaps
ino <nowait> jj <esc>| " Normal now
nn <left> <nop>| " Hard mode
nn <down> <nop>| " "
nn <up> <nop>| " "
nn <right> <nop>| " "
ino <left> <nop>| " "
ino <down> <nop>| " "
ino <up> <nop>| " "
ino <right> <nop>| " "
" Search
nn <c-_> :noh<cr>| " map 'ctrl + /'
" Line numbers
nn <leader>n :set nu! rnu!<cr>
" Vim configuration
nn <leader>ec :vs $MYVIMRC<cr>
nn <leader>so :so %<cr>
]])
local set = vim.keymap.set
set("n", "<leader>cx", "<cmd>!chmod +x %<CR>", { silent = true, desc = "Run `chmod +x` on current file" })

View File

@@ -0,0 +1,5 @@
vim.cmd([[
let g:netrw_winsize = 30
let g:netrw_liststyle=3
let g:netrw_banner = 0
]])

View File

@@ -0,0 +1,12 @@
vim.cmd([[
fu! Compile()
if expand('%:e') == "md"
:silent exec "!pandoc % -s -o /tmp/op.pdf &"
endif
endfu
fu! Preview()
:call Compile()
:silent exec "!zathura /tmp/op.pdf &"
endfu
]])

View File

@@ -0,0 +1,31 @@
vim.cmd([[
call plug#begin()
Plug 'machakann/vim-sandwich'
Plug 'Shougo/context_filetype.vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'honza/vim-snippets'
Plug 'chrisbra/unicode.vim'
Plug 'ap/vim-css-color'
" Jupyter
Plug 'quarto-dev/quarto-vim'
" LaTeX
Plug 'lervag/vimtex'
" Wiki
Plug 'lervag/wiki.vim'
Plug 'hektor/taskwiki'
" Markdown
Plug 'vim-pandoc/vim-pandoc'
Plug 'vim-pandoc/vim-pandoc-syntax'
Plug 'ferrine/md-img-paste.vim'
" TidalCycles
Plug 'supercollider/scvim'
Plug 'tidalcycles/vim-tidal'
" GLSL
Plug 'tikhomirov/vim-glsl'
Plug 'timtro/glslView-nvim'
" Jupyter notebooks
Plug 'goerz/jupytext.vim'
" OpenSCAD
Plug 'sirtaj/vim-openscad'
call plug#end()
]])

View File

@@ -0,0 +1,7 @@
vim.cmd([[
augroup Vim
au!
" Reload vim config when ~/.vimrc is changed
au BufWritePost $HOME/.vimrc so $MYVIMRC | redraw | echo "Reloaded vimrc"
augroup END
]])

View File

@@ -0,0 +1,9 @@
vim.cmd([[
se ls=2
se stl=\ %0*%n
se stl+=\ %m
se stl+=\ %y%0*
se stl+=\ %<%F
se stl+=\ %0*%=%5l%*
se stl+=%0*/%L%*
]])

View File

@@ -0,0 +1,8 @@
vim.cmd([[
function! SynGroup()
let l:s = synID(line('.'), col('.'), 1)
echo synIDattr(l:s, 'name') . ' -> ' . synIDattr(synIDtrans(l:s), 'name')
endfun
com! -nargs=0 Syn :call SynGroup()
]])

View File

@@ -1,5 +0,0 @@
vim.cmd([[
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vimrc"
]])

View File

@@ -0,0 +1,22 @@
vim.cmd([[
let s:zk_preview_enabled = 0
let s:live_server_job = -1
au BufEnter /home/h/.zk/*.md silent exe '!echo "%" > /home/h/.zk/current-zettel.txt'
function! ToggleZKPreview()
if s:zk_preview_enabled == 1
let s:zk_preview_enabled = 0
call jobstop(s:live_server_job)
au! ZKPreview
else
let s:zk_preview_enabled = 1
let s:live_server_job = jobstart('live-server --watch=/home/h/.zk/current-zettel-content.html --open=current-zettel-content.html --port=8080')
augroup ZKPreview
au BufEnter /home/h/.zk/*.md silent exe '!cat "%:r.html" > /home/h/.zk/current-zettel-content.html'
au BufWritePost /home/h/.zk/*.md silent exe '!make && cat "%:r.html" > /home/h/.zk/current-zettel-content.html'
augroup END
endif
endfunction
command! ToggleZKPreview call ToggleZKPreview()
nn <leader>o :ToggleZKPreview<cr> :!xdg-open http://localhost:8080/%:t:r.html & <cr>
]])

View File

@@ -27,7 +27,7 @@ return {
t("flex-wrap: wrap;"),
i(0),
}),
s({ trig = "dfc", dscr = "Display flex column" }, {
s({ trig = "dfc", dscr = "Add 'flex-direction: column;'" }, {
t("display: flex;"),
t("flex-direction: column;"),
i(0),

View File

@@ -5,6 +5,909 @@ local d = ls.dynamic_node
local sn = ls.snippet_node
local fmta = require("luasnip.extras.fmt").fmta
-- Original .snippets file - TODO: Migrate to lua snippets
-- ```viml
-- global !p
-- from datetime import datetime
-- from math import factorial
-- import subprocess
-- import re
-- import sys
--
-- ZOTERO_BASE = "http://127.0.0.1:23119/better-bibtex/cayw"
-- FENCES = {
-- "i": "idea",
-- "q": "question",
-- "n": "note",
-- "t": "thought",
-- }
--
-- def math_inline():
-- return vim.command_output('GetContext') == 'math_inline'
--
-- def math_block():
-- return vim.command_output('GetContext') == 'math_block'
--
-- def math():
-- return math_inline() or math_block()
--
-- def code_block():
-- return vim.command_output('GetContext') == 'pandocDelimitedCodeBlock'
--
-- def code_inline():
-- return vim.command_output('GetContext') == 'pandocNoFormatted'
--
-- def code():
-- return code_inline() or code_block()
--
-- def slugify(text):
-- return re.sub('\s+', '-', text.lower())
--
-- def linkify(text, link):
-- return f"[{text}]({link})"
--
-- def zot(action):
-- if action == "get_title":
-- cmd = f"curl -s '{ZOTERO_BASE}?format=json&selected=1' | jq '.[].title' -r"
-- elif action == "get_citekey":
-- cmd = f"curl -s '{ZOTERO_BASE}?format=pandoc&selected=1'"
-- elif action == "get_citekey_brackets":
-- cmd = f"curl -s '{ZOTERO_BASE}?format=pandoc&selected=1&brackets=1'"
-- elif action == "get_link":
-- link_path = re.sub("^@", "", zot("get_citekey"))
-- link_title = zot("get_title")
-- link = linkify(link_title, link_path)
-- return link
-- elif action == "get_file":
-- link_path = re.sub("^@", "", zot("get_citekey"))
-- link_title = zot("get_title")
-- link = linkify(link_title, f"file://{link_path}.pdf")
-- return link
-- else:
-- return "Zotero action not found"
-- return subprocess.check_output(cmd, shell=True).decode("utf-8").strip()
-- endglobal
--
-- snippet ctx "Context" i
-- `!p snip.rv = vim.command_output('GetContext')`
-- endsnippet
--
-- # General markdown
--
-- snippet ^h "Markdown header" r
-- # $1
-- endsnippet
--
-- snippet ^sec "Markdown section" r
-- ## $1
-- endsnippet
--
-- snippet ^ssec "Markdown subsection" r
-- ### $1
-- endsnippet
--
-- snippet ^sex "Markdown example section" r
-- ## Example: $1
-- endsnippet
--
-- snippet ^ssex "Markdown example subsection" r
-- ### Example: $1
-- endsnippet
--
-- # Zettelkasten templating
--
-- snippet nl
-- *nld*: $1
-- endsnippet
--
-- snippet eng
-- *eng*: $1
-- endsnippet
--
-- snippet fr
-- *fra*: $1
-- endsnippet
--
-- snippet (de
-- *deu*: $1
-- endsnippet
--
-- snippet (nl
-- (*nld*: $1)
-- endsnippet
--
-- snippet (eng
-- (*eng*: $1)
-- endsnippet
--
-- snippet (fr
-- (*fra*: $1)
-- endsnippet
--
-- snippet (de
-- (*deu*: $1)
-- endsnippet
--
-- snippet in
-- (In [$1]($2))$3
-- endsnippet
--
-- snippet liwhat "What?" A
-- `!p snip.rv = "* [What?](" + snip.basename + "_what)"`$1
-- endsnippet
--
-- snippet liwhy "Why?" A
-- `!p snip.rv = "* [Why?](" + snip.basename + "_why)"`$1
-- endsnippet
--
-- snippet < "Comment (html)"
-- <!-- $1 -->$2
-- endsnippet
--
-- snippet <. "Comment (html) ..." i
-- <!-- ... -->$1
-- endsnippet
--
-- snippet <t "Thought (html)" i
-- <!--:::thought
-- $1
-- :::-->
-- endsnippet
--
-- snippet <q "Question (html)" i
-- <!--:::question
-- $1
-- :::-->
-- endsnippet
--
-- snippet <i "Idea (html)" i
-- <!--:::idea
-- $1
-- :::-->
-- endsnippet
--
-- snippet <n "Note (html)" i
-- <!--:::note
-- $1
-- :::-->
-- endsnippet
--
-- snippet td "Todo"
-- TODO${1:: $2}
-- endsnippet
--
-- snippet ref "References"
-- <!--references-->
-- endsnippet
--
-- snippet sort "Sort"
-- <!--sort-->
-- endsnippet
--
-- snippet foot "Footnotes"
-- <!--footnotes-->
-- [^0]:
-- endsnippet
--
-- snippet def "Definition"
-- **Definition${1:: $2}**${3: [${4:citation}${5:, ${6:pointer}}]}
--
-- $7
--
-- ___
-- endsnippet
--
-- snippet theo "Theorem"
-- **Theorem${1:: $2}**${3: [${4:citation}${5:, ${6:pointer}}]}
--
-- $7
--
-- ${8/(\w+).*/**Theorem** \n\n.../}
--
-- ___
-- endsnippet
--
-- snippet prop "Property"
-- **Property $1** [@]
--
-- $2
--
-- ___
-- endsnippet
--
-- snippet lemm "Lemma"
-- **Lemma $1** [@]
--
-- $2
--
-- ___
-- endsnippet
--
-- snippet coro "Corollary"
-- **Corollary $1** [@]
--
-- $2
--
-- ___
-- endsnippet
--
-- # Greek symbols
--
-- context "math()"
-- snippet alpha "Alpha"
-- \\alpha
-- endsnippet
--
-- context "math()"
-- snippet beta "Beta"
-- \\beta
-- endsnippet
--
-- context "math()"
-- snippet gamma "Gamma"
-- \\gamma
-- endsnippet
--
-- context "math()"
-- snippet delta "Delta"
-- \\delta
-- endsnippet
--
-- context "math()"
-- snippet epsilon "Epsilon"
-- \\epsilonilon
-- endsnippet
--
-- context "math()"
-- snippet zeta "Zeta"
-- \\zeta
-- endsnippet
--
-- context "math()"
-- snippet eta "Eta"
-- \\eta
-- endsnippet
--
-- context "math()"
-- snippet theta "Theta"
-- \\theta
-- endsnippet
--
-- context "math()"
-- snippet iota "Iota"
-- \\iota
-- endsnippet
--
-- context "math()"
-- snippet kappa "Kappa"
-- \\kappa
-- endsnippet
--
-- context "math()"
-- snippet lambda "Lambda" i
-- \\lambda
-- endsnippet
--
-- context "math()"
-- snippet mu "Mu"
-- \\mu
-- endsnippet
--
-- context "math()"
-- snippet nu "Nu"
-- \\nu
-- endsnippet
--
-- context "math()"
-- snippet xi "Xi"
-- \\xi
-- endsnippet
--
-- context "math()"
-- snippet omicron "Omicron"
-- \\omicron
-- endsnippet
--
-- context "math()"
-- snippet pi "Pi"
-- \\pi
-- endsnippet
--
-- context "math()"
-- snippet rho "Rho"
-- \\rho
-- endsnippet
--
-- context "math()"
-- snippet sigma "Sigma"
-- \\sigma
-- endsnippet
--
-- context "math()"
-- snippet tau "Tau"
-- \\tau
-- endsnippet
--
-- context "math()"
-- snippet upsilon "Upsilon"
-- \\upsilon
-- endsnippet
--
-- context "math()"
-- snippet phi "Phi"
-- \\phi
-- endsnippet
--
-- context "math()"
-- snippet chi "Chi"
-- \\chi
-- endsnippet
--
-- context "math()"
-- snippet psi "Psi"
-- \\psi
-- endsnippet
--
-- context "math()"
-- snippet omega "Omega"
-- \\omega
-- endsnippet
--
-- context "math()"
-- snippet Gamma "Gamma"
-- \\Gamma
-- endsnippet
--
-- context "math()"
-- snippet Delta "Delta"
-- \\Delta
-- endsnippet
--
-- context "math()"
-- snippet Theta "Theta"
-- \\Theta
-- endsnippet
--
-- context "math()"
-- snippet Lambda "Lambda"
-- \\Lambda
-- endsnippet
--
-- context "math()"
-- snippet Xi "Xi"
-- \\Xi
-- endsnippet
--
-- context "math()"
-- snippet Pi "Pi"
-- \\Pi
-- endsnippet
--
-- context "math()"
-- snippet Sigma "Sigma"
-- \\Sigma
-- endsnippet
--
-- context "math()"
-- snippet Upsilon "Upsilon"
-- \\Upsilon
-- endsnippet
--
-- context "math()"
-- snippet Phi "Phi"
-- \\Phi
-- endsnippet
--
-- context "math()"
-- snippet Psi "Psi"
-- \\Psi
-- endsnippet
--
-- context "math()"
-- snippet Omega "Omega"
-- \\Omega
-- endsnippet
--
-- snippet asaw "Als en slechts als (woorden)" i
-- als en slechts als
-- endsnippet
--
-- snippet iffw "If and only if (words)" i
-- if and only if
-- endsnippet
--
-- snippet asas "Als en slechts als (shorthand)" i
-- **asa**
-- endsnippet
--
-- snippet iffs "If and only if (shorthand)" i
-- **iff**
-- endsnippet
--
-- snippet beg "Begin"
-- \begin{$1}
-- $2
-- \end{$1}
-- endsnippet
--
-- snippet align "" i
-- \begin{align}
-- $1
-- \end{align}
-- endsnippet
--
-- snippet cases "" i
-- \begin{cases}
-- $1 \\\\
-- $2
-- \end{cases}
-- $3
-- endsnippet
--
-- snippet tik "Tikzpicture" i
-- \begin{tikzpicture}
-- $1
-- \end{tikzpicture}
-- endsnippet
--
-- snippet matrix "Matrix" i
-- \begin{bmatrix}
-- $1
-- \end{bmatrix}
-- endsnippet
--
-- # Insert anything after m/M in math mode
--
-- snippet "(\b)m(.*)" "MathJax" r
-- `!p snip.rv = match.group(1) + "$" + match.group(2) + "$"`
-- endsnippet
--
-- snippet (\b)M(.*) "MathJax block" irw
-- $$
-- `!p snip.rv = match.group(2)`
-- $$
-- endsnippet
--
-- # Calligraphic letters
--
-- context "math()"
-- snippet c([A-z]) "Calligraphic A" r
-- `!p snip.rv = "\\mathcal{" + match.group(1) + "}"`$1
-- endsnippet
--
-- # Subscripts
--
-- context "math()"
-- snippet '([A-z])(\w+)' "Subscripts" irw
-- `!p snip.rv = match.group(1) + '_' + match.group(2) if len(match.group(2)) == 1 else match.group(1) + '_{' + match.group(2) + '}'`$1
-- endsnippet
--
-- # MathJax
--
-- snippet fa "For all" i
-- \forall
-- endsnippet
--
-- snippet frac "" i
-- \frac{$1}{$2}$3
-- endsnippet
--
-- snippet set "" i
-- \\{$1\\}$2
-- endsnippet
--
-- snippet N "" i
-- \mathbb{N}
-- endsnippet
--
-- snippet N0 "" i
-- \mathbb{N}_0
-- endsnippet
--
-- snippet N+ "" i
-- \mathbb{N}^+
-- endsnippet
--
-- snippet Z "" i
-- \mathbb{Z}
-- endsnippet
--
-- snippet Z0 "" i
-- \mathbb{Z}_0
-- endsnippet
--
-- snippet Z+ "" i
-- \mathbb{Z}^+
-- endsnippet
--
-- snippet R "" i
-- \mathbb{R}
-- endsnippet
--
-- snippet R0 "" i
-- \mathbb{R}_0
-- endsnippet
--
-- snippet R+ "" i
-- \mathbb{R}^+
-- endsnippet
--
-- snippet C "" i
-- \mathbb{C}
-- endsnippet
--
-- snippet lim "" i
-- \lim_{$1}$2
-- endsnippet
--
-- snippet limn "" i
-- \lim_{n \to \infty}$2
-- endsnippet
--
-- snippet binom "" i
-- \binom{$1}{$2}$3
-- endsnippet
--
-- snippet andmath "description" i
-- \text{ and }
-- endsnippet
--
-- snippet enmath "description" i
-- \text{ en }
-- endsnippet
--
-- snippet lra "MathJax: long right arrow" i
-- \longrightarrow
-- endsnippet
--
-- snippet Ra "MathJax: right arrow" i
-- \Rightarrow
-- endsnippet
--
-- snippet Im "MathJax: image operator" i
-- \operatorname{Im}
-- endsnippet
--
-- snippet ggd "Grootste gemene deler" i
-- \operatorname{ggd}
-- endsnippet
--
-- snippet fl "Floating point" i
-- \operatorname{fl}
-- endsnippet
--
-- snippet Var "Variance" i
-- \operatorname{Var}
-- endsnippet
--
-- snippet E "Expectation" i
-- \operatorname{E}
-- endsnippet
--
-- snippet Cov "Covariance" i
-- \operatorname{Cov}
-- endsnippet
--
-- context "math()" i
-- snippet ntup "Alpha"
-- (x_1, \ldots, x_n)
-- endsnippet
--
-- snippet mxn "Matrix" i
-- m \times n
-- endsnippet
--
-- snippet mxn- "Matrix" i
-- $m \times n$-matrix
-- endsnippet
--
-- snippet nxn "Matrix" i
-- n \times n
-- endsnippet
--
-- snippet det "Determinant" i
-- \operatorname{det}(${1:A})$2
-- endsnippet
--
-- snippet det| "Determinant alternative notation" i
-- |${1:A}|$2
-- endsnippet
--
-- snippet Span "Span" i
-- \operatorname{Span}\\{$1\\}$2
-- endsnippet
--
-- snippet Nul "Null" i
-- \operatorname{Nul}($1)$2
-- endsnippet
--
-- snippet Col "Column space" i
-- \operatorname{Col}($1)$2
-- endsnippet
--
-- snippet kern "Kernel" i
-- \operatorname{kern}($1)$2
-- endsnippet
--
-- context "math()"
-- snippet vec "Vector" i
-- \mathbf{$1}$2
-- endsnippet
--
-- context "math()"
-- snippet vec([A-z]) "Vector ..." r
-- `!p snip.rv = "\\mathbf{" + match.group(1) + "}"`$1
-- endsnippet
--
-- snippet v1tovp "Vectors v indexed from 1 to p"
-- \mathbf{v_1},...,\mathbf{v_p}$2
-- endsnippet
--
-- snippet a1toan "Vectors a indexed from 1 to n"
-- \mathbf{a_1},...,\mathbf{v_n}$2
-- endsnippet
--
-- snippet .. "Dot dot dot" i
-- \dots $1
-- endsnippet
--
-- snippet text "MathJax text" i
-- \text{$1}$2
-- endsnippet
--
-- snippet leq "Less than or equal to" i
-- \leq
-- endsnippet
--
-- snippet leq "Greater than or equal to" i
-- \geq
-- endsnippet
--
-- snippet eat "Evaluated at" i
-- {\biggr\rvert}_{$1}$2
-- endsnippet
--
-- snippet sketch "Link a sketch" i
-- [$1](file:///home/h/sketches/$2)
-- endsnippet
--
-- snippet deck "Get anki deck"
-- `get-anki-decks`
-- endsnippet
--
-- # snippet ` "Inline code" i
-- # `$1`
-- # endsnippet
--
-- # Escape backticks
-- snippet `` "Code block" bA
-- \`\`\`$1
-- $2
-- \`\`\`
-- endsnippet
--
-- snippet `tex "Latex block (see latex filter)" bA
-- \`\`\`{.tex}
-- $1
-- \`\`\`
-- endsnippet
--
-- snippet `tik "Tikz block (see tikz filter)" bA
-- \`\`\`{.tex}
-- \\begin{tikzpicture}
-- $1
-- \\end{tikzpicture}
-- \`\`\`
-- endsnippet
--
-- snippet task "Task" i
-- * [ ] $1 -- pro:$2
-- endsnippet
--
-- snippet "(\b)fn(\d+)" "" ir
-- `!p snip.rv = snip.basename + "_" + match.group(2).zfill(2)`$1
-- endsnippet
--
-- snippet "ch(\d+)" "Link chapter" ir
-- `!p
-- num_str = match.group(1).zfill(2)
-- title = 3*"."
-- link = snip.basename + "_" + num_str
-- snip.rv = num_str + ". " + linkify(title, link)
-- `
-- endsnippet
--
-- snippet "ch(\d+)to(\d+)" "Link chapters ... to ..." irA
-- `!p
-- for i in range(int(match.group(1)), int(match.group(2)) + 1):
-- num_str = str(i).zfill(2)
-- title = 3*"."
-- link = snip.basename + "_" + num_str
-- snip.rv += num_str + ". " + linkify(title, link) + "\n"
-- `
-- endsnippet
--
-- snippet "sec([\sA-z]+)" "Link section titled ..." r
-- `!p
-- snip.rv = "* " + linkify(match.group(1), f"{snip.basename}_{slugify(match.group(1))}")
-- `
-- endsnippet
--
-- snippet cp(\d+) "Comment current page (and date)" r
-- `!p snip.rv = "<!--" + datetime.now().strftime("%Y-%m-%d") + " p. " + match.group(1) + "-->"`
-- endsnippet
--
-- snippet (\d+)! "Factorial of ..." r
-- `!p snip.rv = factorial(int(match.group(1)))`
-- endsnippet
--
-- snippet d "Date"
-- `!p snip.rv = datetime.now().strftime("%Y-%m-%d")`
-- endsnippet
--
-- snippet :(\w*) "Fence" r
-- `!p snip.rv += ":::" + FENCES.get(match.group(1) or "", "") + "\n" `$1
-- `!p snip.rv += ":::"`$2
-- endsnippet
--
-- snippet \[(\w*) "Fence inline" ir
-- `!p snip.rv += "["`$1`!p snip.rv += "]{." + FENCES.get(match.group(1) or "", "") + "}"`$2
-- endsnippet
--
-- snippet ^eg "Example" r
-- E.g. $1
-- endsnippet
--
-- # E.g. after list (or list preceded by space)
-- snippet (\*\s|\*)eg "Example" r
-- * E.g. $1
-- endsnippet
--
-- # E.g. after dot (or dot preceded by space)
-- snippet (\.\s|\.)eg "Example" r
-- . E.g. $1
-- endsnippet
--
-- snippet (?<!^|\*\s|\*|\.\s|\.)eg "Example" r
-- e.g. $1
-- endsnippet
--
-- # Zettelkasten to Anki
--
-- snippet td "TARGET DECK: <Deck name>"
-- TARGET DECK: $1::$2
-- endsnippet
--
-- snippet clo "Cloze"
-- START
-- Cloze
-- ${0:${VISUAL}}$1
-- END
-- $2
-- endsnippet
--
-- snippet clos "Cloze start"
-- START
-- Cloze
-- $1
-- endsnippet
--
-- snippet cloe "Cloze end"
-- END
-- endsnippet
--
-- snippet clod
-- START
-- Cloze
-- **Definition$1**
--
-- $2
-- END
-- endsnippet
--
-- snippet clop
-- START
-- Cloze
-- **Property$1**
--
-- $2
-- END
-- endsnippet
--
-- snippet clot
-- START
-- Cloze
-- **Theorem$1**
--
-- $2
-- END
-- endsnippet
--
-- snippet clol
-- START
-- Cloze
-- **Lemma$1**
--
-- $2
-- END
-- endsnippet
--
-- snippet "c(\d+)" "Cloze <number>" r
-- {{c`!p snip.rv = int(match.group(1))`::${0:${VISUAL}}$1}}$2
-- endsnippet
--
-- # Match preceded by whitespace or start of line
-- snippet (?<!\S)z($|t|l|z|o|\.) "Zotero" r
-- `!p
--
-- ACTIONS = {
-- "": "get_citekey",
-- "t": "get_title",
-- "l": "get_link",
-- "z": "get_citekey_brackets",
-- "o": "get_file",
-- }
--
-- snip.rv = zot(ACTIONS.get(match.group(1)))
-- `
-- endsnippet
--
-- snippet zq "Zotero quote" r
-- `!p snip.rv = '>\n> --' + zot("get_citekey_brackets")`
-- endsnippet
--
-- snippet acz "According to ..."
-- `!p snip.rv = "According to " + zot("get_citekey")`
-- endsnippet
--
-- snippet azex "As ... explains"
-- `!p snip.rv = "As " + zot("get_citekey") + " explains, "`
-- endsnippet
--
-- snippet iz "In ..."
-- `!p snip.rv = "In " + zot("get_citekey")`
-- endsnippet
--
-- snippet izd "In ...'s definition"
-- `!p snip.rv = "In " + zot("get_citekey") + "'s definition, "`
-- endsnippet
--
-- snippet zintends "... intends to ..." A
-- `!p snip.rv = zot("get_citekey") + " intends to "`
-- endsnippet
--
-- snippet tfol "The following" wA
-- the following
-- endsnippet
--
-- snippet tfolt "It follows that" wA
-- it follows that
-- endsnippet
--
-- snippet ntfol "In the following" wA
-- in the following
-- endsnippet
--
-- snippet algos "algorithms" wA
-- algorithms
-- endsnippet
--
-- snippet algo "algorithm" wA
-- algorithm
-- endsnippet
--
-- # TODO: Make only available in tikzpicture
-- context "code()"
-- snippet q "State" w
-- \node[state] ($1) [] {$2};
-- endsnippet
--
-- context "code()"
-- snippet q0 "Initial state" w
-- \node[initial,state] ($1) {$2};
-- endsnippet
-- ```
-- Taken from https://ejmastnak.com/tutorials/vim-latex/luasnip/#anatomy
local get_visual = function(_, parent)
if #parent.snippet.env.LS_SELECT_RAW > 0 then

View File

@@ -0,0 +1,24 @@
local ls = require("luasnip")
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
return {
s("reqtrace", t({ "(#%require racket/trace)" })),
s("strln", t({ "(string-length " }), i(1), t({ ")" })),
s("impb", t({ "(import (rnrs base (6))", " (rnrs io simple" }), i(0), t({ ")" })),
s("def", {
t("(define "),
i(1),
t(" "),
i(2),
t(")"),
}),
s("defp", {
t("(define ("),
i(1),
t(" "),
i(2),
t("))"),
}),
}

View File

@@ -0,0 +1,69 @@
local ls = require("luasnip")
local s = ls.snippet
local i = ls.insert_node
local t = ls.text_node
local f = ls.function_node
-- Inspired by https://castel.dev/post/lecture-notes-1/
ls.add_snippets("tex", {
s("beg", {
t("\\begin{"),
i(1),
t({ "}", "\t" }),
i(0),
t({ "", "\\end{" }),
f(function(args)
return args[1][1]
end, { 1 }),
t("}"),
}),
s("def", {
t("\\begin{definition}"),
t({ "", "\t" }),
i(0),
t({ "", "\\end{definition}" }),
}),
s("fig", {
t("\\begin{figure}"),
t({ "", "\t" }),
i(0),
t({ "", "\\end{figure}" }),
}),
s(
"time",
f(function()
return os.date("%H:%M")
end)
),
s("i", t("\\textit{"), i(0), t("}")),
s("b", t("\\textbf{"), i(0), t("}")),
s("center", {
t("\\begin{center}"),
t({ "", "" }),
i(0),
t({ "", "\\end{center}" }),
}),
s("pac", t("\\usepackage{"), i(0), t("}")),
s("foot", t("\\footnote{"), i(0), t("}")),
s("dm", {
t({ "\\[", "" }),
i(1),
t({ "", "\\]" }),
i(0),
}),
s("ch", t("\\chapter{"), i(0), t("}")),
s("sec", t("\\section{"), i(0), t("}")),
s("ssec", t("\\subsection{"), i(0), t("}")),
s("sssec", t("\\subsubsection{"), i(0), t("}")),
})