Compare commits

...

4 Commits

8 changed files with 158 additions and 7 deletions

View File

@ -63,6 +63,7 @@ function Compile()
if exists(":Source")
Source
endif
w
execute "make ~/.cache/termdebug/" .. expand("%:r") .. " -f ~/.config/nvim/makefile"
endfunction
nnoremap <silent> <leader>dc :call Compile()<cr>
@ -115,6 +116,13 @@ nnoremap <silent> ZF :qa<cr>
" copy URL under cursor to clipboard bind
:nnoremap <silent><leader>uu :let @+ = expand('<cfile>')<CR>
" edit figure in Inkscape
function EditFig()
let figure_fname = expand('<cfile>')
exec "silent !typst-figure " .. figure_fname
endfunc
:nnoremap <silent><leader>ff :call EditFig()<cr>
" Plugins
" Run PlugInstall if there are missing plugins
@ -190,6 +198,8 @@ Plug 'axieax/urlview.nvim'
Plug 'ggandor/leap.nvim'
Plug 'kaarmu/typst.vim'
call plug#end()
if $SYSTEM_PROFILE == "DEFAULT"

View File

@ -64,7 +64,7 @@ local servers = {
}
}
},
clangd = {}
clangd = {},
}
local nvim_lsp = require('lspconfig')

View File

@ -0,0 +1,31 @@
snippet problem "template for problem notes" bi
#import "../templates/problems.typ": template, source_code, status
#show: template.with(
title: "$1",
problem_url: "$2",
stat: "${3:incomplete}",
)
endsnippet
snippet math_prob "template for math problems" bi
#import "../../../templates/math_prob.typ": template
#show: template.with(
title: "$1",
)
endsnippet
snippet ss "superscript" i
^$1
endsnippet
snippet im "inline math" w
\$${1:${VISUAL}}\$
endsnippet
snippet fig "create new figure" bi
#figure(
image("fig/${0:name}.svg"),
caption: [$2],
) <${3:identifier}>
endsnippet

View File

@ -43,6 +43,7 @@ find ~/quar \
-name '*.jpg' -o \
-name '*.png' -o \
-name '*.jpeg' -o \
-name '*.webp' -o \
-name '*.gif' \
\) | \
while read -r FILE; do

51
src/.local/bin/svg-typst Executable file
View File

@ -0,0 +1,51 @@
#!/bin/sh
# Write Typst markup, then copy it as an SVG.
# This can be used to paste math labels in Inkscape.
# Requires
# --------
# pdf2svg
# typst
# xclip
# $EDITOR set to an editor (prefer nvim)
# create temp files
TMP_SRC="$(mktemp --suffix=.typ)"
TMP_PDF="$(mktemp --suffix=.pdf)"
TMP_SVG="$(mktemp --suffix=.svg)"
# Typst template
cat <<'EOF' > "$TMP_SRC"
#set page(
width: 10cm,
height: auto,
margin: (x: 1cm, y: 1cm)
)
#show math.equation: eq => scale(x: 150%, y: 150%, text(font: "Fira Math", size: 17pt, eq))
#show text: set text(font: "Fira Math", size: 25pt)
$ $
EOF
# edit Typst source
if [ "$EDITOR" = "nvim" ] || [ "$EDITOR" = "vim" ]; then
# if we're using vim we can jump to the end of the template
$EDITOR -c "normal Gll" -c "startinsert" "$TMP_SRC"
else
$EDITOR "$TMP_SRC"
fi
# compile to pdf
typst c "$TMP_SRC" "$TMP_PDF"
# convert to svg
pdf2svg "$TMP_PDF" "$TMP_SVG"
# copy (x-inkscape-svg necessary otherwise it rasterizes the image when pasting)
xclip -selection clipboard -t image/x-inkscape-svg -i "$TMP_SVG"
# clean up
rm "$TMP_SRC"
rm "$TMP_PDF"
rm "$TMP_SVG"

58
src/.local/bin/typst-figure Executable file
View File

@ -0,0 +1,58 @@
#!/bin/sh
# Figure manager for typst.
# Run this from Vim and it will edit a figure with the given filename in Inkscape.
SVG_PATH="$1"
mkdir -p fig/
if [ -e fig/"$1" ]; then
# just edit it
inkscape "$SVG_PATH" &
else
# otherwise, copy this template file and edit it
cat <<'EOF' > "$SVG_PATH"
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="300mm"
height="300mm"
viewBox="0 0 300 300"
version="1.1"
id="svg5"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="drawing.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#252525"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="0.62272556"
inkscape:cx="353.28564"
inkscape:cy="546.78983"
inkscape:window-width="1836"
inkscape:window-height="986"
inkscape:window-x="40"
inkscape:window-y="30"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1" />
</svg>
EOF
inkscape "$SVG_PATH" &
fi

View File

@ -58,14 +58,14 @@ export KEYID="A3A5FA72F8E5E54FBEE425057225FE3592EFFA38"
export KEEPASSDB="$HOME"/dox/sec/pass.kdbx
# Identity (see ~/.local/bin/identity.sh)
if [ -r "$XDG_CONFIG_HOME"/identity ]; then
source "$XDG_CONFIG_HOME"/identity
. "$XDG_CONFIG_HOME"/identity
fi
# Profile to enable/disable features on certain devices
if [ ! -f "$XDG_CONFIG_HOME"/dot_profile ]; then
export SYSTEM_PROFILE="DEFAULT"
else
source "$XDG_CONFIG_HOME"/dot_profile
. "$XDG_CONFIG_HOME"/dot_profile
fi
source .config/bashrc
. .config/bashrc

View File

@ -2,12 +2,12 @@
mon-on
if [ $SYSTEM_PROFILE == "MINIMAL" ]; then
if [ $SYSTEM_PROFILE = "MINIMAL" ]; then
dwm
exit
fi
if [ $SYSTEM_PROFILE == "DEFAULT" ]; then
if [ $SYSTEM_PROFILE = "DEFAULT" ]; then
picom &
fi
xwallpaper --center .config/wall.png
@ -16,7 +16,7 @@ wallpaper
xss-lock -- slock &
dunst &
xrdb .Xresources
gentoo-pipewire-launcher &
# gentoo-pipewire-launcher &
# DBus
export NO_AT_BRIDGE=1