From e161127590172142c5e2914707023543c86db3d3 Mon Sep 17 00:00:00 2001 From: Michael Chalupiak Date: Sat, 22 Mar 2025 20:10:25 -0400 Subject: [PATCH 1/2] typst ts --- config/.config/kak-tree-sitter/config.toml | 21 +++++++++++++++++++++ config/.config/kak/kakrc | 1 + 2 files changed, 22 insertions(+) diff --git a/config/.config/kak-tree-sitter/config.toml b/config/.config/kak-tree-sitter/config.toml index 1cadefa..24a5b6f 100644 --- a/config/.config/kak-tree-sitter/config.toml +++ b/config/.config/kak-tree-sitter/config.toml @@ -21,3 +21,24 @@ # [language.lua.queries] # # path = "runtime/queries/lua" # path = "queries/lua" + +# typst +[language.typst.grammar.source.git] +url = "https://github.com/uben0/tree-sitter-typst" +pin = "46cf4ded12ee974a70bf8457263b67ad7ee0379d" + +[language.typst.grammar] +path = "src" +compile = "cc" +compile_args = ["-c", "-fpic", "../scanner.c", "../parser.c", "-I", ".."] +compile_flags = ["-O3"] +link = "cc" +link_args = ["-shared", "-fpic", "scanner.o", "parser.o", "-o", "typst.so"] +link_flags = ["-O3"] + +[language.typst.queries.source.git] +url = "https://github.com/uben0/tree-sitter-typst" +pin = "46cf4ded12ee974a70bf8457263b67ad7ee0379d" + +[language.typst.queries] +path = "queries/typst" diff --git a/config/.config/kak/kakrc b/config/.config/kak/kakrc index 2bb53fb..678b24d 100644 --- a/config/.config/kak/kakrc +++ b/config/.config/kak/kakrc @@ -25,6 +25,7 @@ plug "gustavo-hms/luar" %{ } } +plug "custom-filetypes" load-path "~/.config/kak/al" # # Color Themes plug "tinted-theming/base16-kakoune" theme plug "https://git.sr.ht/~hadronized/kakoune-tree-sitter-themes" theme From 957701fce9efca810ca5c563b46192f45aa588a1 Mon Sep 17 00:00:00 2001 From: Michael Chalupiak Date: Sat, 22 Mar 2025 20:10:45 -0400 Subject: [PATCH 2/2] temp typst filetype --- config/.config/kak/al/rc/typst.kak | 69 ++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 config/.config/kak/al/rc/typst.kak diff --git a/config/.config/kak/al/rc/typst.kak b/config/.config/kak/al/rc/typst.kak new file mode 100644 index 0000000..5353ea6 --- /dev/null +++ b/config/.config/kak/al/rc/typst.kak @@ -0,0 +1,69 @@ +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufCreate .*[.](typ) %{ + set-option buffer filetype typst +} + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook -group typst-highlight global WinSetOption filetype=typst %{ + require-module typst + + add-highlighter window/typst ref typst + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/typst } + hook window InsertChar \n -group typst typst-on-new-line +} + +provide-module typst %§ + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +add-highlighter shared/typst group + +# Comments +add-highlighter shared/typst/ regex ^//(?:[^\n/][^\n]*|)$ 0:comment + +# Strings +add-highlighter shared/typst/ regex '"[^"]*"' 0:string + +# Headings +add-highlighter shared/typst/ regex ^=+\h+[^\n]+$ 0:header + +# Code blocks +# Raw with optional syntax highlighting +add-highlighter shared/typst/ regex '^```[^(```)]*```' 0:mono +# Multiline monospace +add-highlighter shared/typst/ regex '^`[^(`)]*`' 0:mono + +# Monospace text +add-highlighter shared/typst/ regex \B(`[^\n]+?`)\B 0:mono +add-highlighter shared/typst/ regex \B(```[^\n]+?```)\B 0:mono + +# Bold text +add-highlighter shared/typst/ regex \s\*[^\*]+\*\B 0:+b + +# Italic text +add-highlighter shared/typst/ regex \b_.*?_\b 0:+i + +# Code expressions: functions, variables +add-highlighter shared/typst/ regex (^|\h)#(\w|\.|-)+ 0:meta + +# Bold terms in term lists +add-highlighter shared/typst/ regex ^/\h[^:]*: 0:+b + +§ + +# Commands +# ‾‾‾‾‾‾‾‾ + +define-command -hidden typst-on-new-line %< + evaluate-commands -draft -itersel %< + # Preserve previous line indent + try %{ execute-keys -draft K } + # Cleanup trailing whitespaces from previous line + try %{ execute-keys -draft k x s \h+$ d } + > +>