From 1df631061a547c8e4517402905893ee118b78d64 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 12 Jan 2022 18:17:05 -0500 Subject: [PATCH] More stuff for kakoune --- home/kakoune/autoload/latex.kak | 171 ++++++++++++++++---------------- home/kakoune/kakrc | 4 - home/kakoune/kaktex.nix | 2 + 3 files changed, 88 insertions(+), 89 deletions(-) diff --git a/home/kakoune/autoload/latex.kak b/home/kakoune/autoload/latex.kak index 2e57396..c8b8293 100644 --- a/home/kakoune/autoload/latex.kak +++ b/home/kakoune/autoload/latex.kak @@ -5,96 +5,97 @@ ## ## NOTE: This overrides , so if you don't like it, remove it. -provide-module latex-kak %{ - # Create a simple begin block, put the cursors in and remove multi-cursor on exit. - define-command -hidden create-begin-block %{ - execute-keys "i\begin{b0}\end{b0}" - execute-keys "b0" - execute-keys -with-hooks -with-maps "c" - hook -once buffer ModeChange .*:normal %{ - execute-keys -with-maps "gl" - } - } - # Create a begin block with the given parameter as block name. - define-command -params 1 create-begin-block-with %{ - execute-keys "i\begin{b0}\end{b0}" - execute-keys "b0c%arg{1}" - execute-keys "ok" - execute-keys -with-maps "gl" - } - # Create a \param{} block and put the cursor in the middle. - define-command -params 2 -hidden create-delims %{ - execute-keys "i%arg{1}hZa%arg{2}zl" - execute-keys -with-hooks -with-maps "i" - } - define-command -params 1 create-block-with %{ - create-delims "\%arg{1}{" "}" +# Create a simple begin block, put the cursors in and remove multi-cursor on exit. +define-command -hidden create-begin-block %{ + execute-keys "i\begin{b0}\end{b0}" + execute-keys "b0" + execute-keys -with-hooks -with-maps "c" + hook -once buffer ModeChange .*:normal %{ + execute-keys -with-maps "gl" } +} +# Create a begin block with the given parameter as block name. +define-command -params 1 create-begin-block-with %{ + execute-keys "i\begin{b0}\end{b0}" + execute-keys "b0c%arg{1}" + execute-keys "ok" + execute-keys -with-maps "gl" +} +# Create a \param{} block and put the cursor in the middle. +define-command -params 2 -hidden create-delims %{ + execute-keys "i%arg{1}hZa%arg{2}zl" + execute-keys -with-hooks -with-maps "i" +} +define-command -params 1 create-block-with %{ + create-delims "\%arg{1}{" "}" +} - # The font-menu - declare-user-mode latex-font - ## Semantics - map -docstring "Text" global latex-font t ": create-block-with text" - map -docstring "Emphasize (emph)" global latex-font e ": create-block-with emph" - ## Shape - map -docstring "Italics (textit)" global latex-font i ": create-block-with textit" - map -docstring "Upright (textup)" global latex-font u ": create-block-with textup" - # map -docstring "Slanted (textsl)" global latex-font S ": create-block-with textsl" - # map -docstring "Swash font (textsw)" global latex-font W ": create-block-with textsw" - # map -docstring "Small caps (textsc)" global latex-font C ": create-block-with textsc" - # Weight - map -docstring "Bold text (textbf)" global latex-font b ": create-block-with textbf" - # map -docstring "Medium bold (textmd)" global latex-font M ": create-block-with textmd" - # map -docstring "Normal (textnormal)" global latex-font N ": create-block-with textnormal" - ## Family - # map -docstring "Serif font (textsf)" global latex-font s ": create-block-with textsf" - # map -docstring "Roman text (textrm)" global latex-font r ": create-block-with textrm" - map -docstring "Monospace (texttt)" global latex-font m ": create-block-with texttt" - ## Math styles - map -docstring "Math Calligraphic (mathcal)" global latex-font ": create-block-with mathcal" - map -docstring "Math Blackboard (mathbb)" global latex-font ": create-block-with mathbb" - # map -docstring "Math Fraktur (mathfr)" global latex-font ": create-block-with mathfr" - # map -docstring "Math Roman (mathrm)" global latex-font ": create-block-with mathrm" - # map -docstring "Math Italics (mathit)" global latex-font ": create-block-with mathit" - # map -docstring "Math Bold (mathbf)" global latex-font ": create-block-with mathbf" - # map -docstring "Serif font (mathsf)" global latex-font ": create-block-with mathsf" - map -docstring "Math Monospace (mathtt)" global latex-font ": create-block-with mathtt" - map -docstring "Math Fraktur (mathfrak)" global latex-font f ": create-block-with mathfrak" +# The font-menu +declare-user-mode latex-font +## Semantics +map -docstring "Text" global latex-font t ": create-block-with text" +map -docstring "Emphasize (emph)" global latex-font e ": create-block-with emph" +## Shape +map -docstring "Italics (textit)" global latex-font i ": create-block-with textit" +map -docstring "Upright (textup)" global latex-font u ": create-block-with textup" +# map -docstring "Slanted (textsl)" global latex-font S ": create-block-with textsl" +# map -docstring "Swash font (textsw)" global latex-font W ": create-block-with textsw" +# map -docstring "Small caps (textsc)" global latex-font C ": create-block-with textsc" +# Weight +map -docstring "Bold text (textbf)" global latex-font b ": create-block-with textbf" +# map -docstring "Medium bold (textmd)" global latex-font M ": create-block-with textmd" +# map -docstring "Normal (textnormal)" global latex-font N ": create-block-with textnormal" +## Family +# map -docstring "Serif font (textsf)" global latex-font s ": create-block-with textsf" +# map -docstring "Roman text (textrm)" global latex-font r ": create-block-with textrm" +map -docstring "Monospace (texttt)" global latex-font m ": create-block-with texttt" +## Math styles +map -docstring "Math Calligraphic (mathcal)" global latex-font ": create-block-with mathcal" +map -docstring "Math Blackboard (mathbb)" global latex-font ": create-block-with mathbb" +# map -docstring "Math Fraktur (mathfr)" global latex-font ": create-block-with mathfr" +# map -docstring "Math Roman (mathrm)" global latex-font ": create-block-with mathrm" +# map -docstring "Math Italics (mathit)" global latex-font ": create-block-with mathit" +# map -docstring "Math Bold (mathbf)" global latex-font ": create-block-with mathbf" +# map -docstring "Serif font (mathsf)" global latex-font ": create-block-with mathsf" +map -docstring "Math Monospace (mathtt)" global latex-font ": create-block-with mathtt" +map -docstring "Math Fraktur (mathfrak)" global latex-font f ": create-block-with mathfrak" - # "Insert block" menu - declare-user-mode latex-insert-block - ## Common normal text blocks - map -docstring "Unordered list" global latex-insert-block u ": create-begin-block-with itemize" - map -docstring "Ordered list" global latex-insert-block o ": create-begin-block-with enumerate" - ## Common math blocks - map -docstring "Theorem" global latex-insert-block t ": create-begin-block-with theorem" - map -docstring "Definition" global latex-insert-block d ": create-begin-block-with definition" - map -docstring "Lemma" global latex-insert-block l ": create-begin-block-with lemma" - map -docstring "Example" global latex-insert-block e ": create-begin-block-with example" - map -docstring "Proof" global latex-insert-block p ": create-begin-block-with proof" - map -docstring "Remark" global latex-insert-block r ": create-begin-block-with remark" - map -docstring "Proposition" global latex-insert-block ": create-begin-block-with proposition" - map -docstring "Corollary" global latex-insert-block c ": create-begin-block-with corollary" - ## Common environments - map -docstring "align*" global latex-insert-block a ": create-begin-block-with align*" - map -docstring "align" global latex-insert-block ": create-begin-block-with align" - map -docstring "equation" global latex-insert-block e ": create-begin-block-with equation" - map -docstring "equation*" global latex-insert-block ": create-begin-block-with equation*" - map -docstring "Matrix" global latex-insert-block m ": create-begin-block-with bmatrix" - map -docstring "Cases" global latex-insert-block C ": create-begin-block-with cases" - map -docstring "Table" global latex-insert-block T ": create-begin-block-with tabular" - ## Custom - map -docstring "Custom" global latex-insert-block c ": create-begin-block" +# "Insert block" menu +declare-user-mode latex-insert-block +## Common normal text blocks +map -docstring "Unordered list" global latex-insert-block u ": create-begin-block-with itemize" +map -docstring "Ordered list" global latex-insert-block o ": create-begin-block-with enumerate" +## Common math blocks +map -docstring "Theorem" global latex-insert-block t ": create-begin-block-with theorem" +map -docstring "Definition" global latex-insert-block d ": create-begin-block-with definition" +map -docstring "Lemma" global latex-insert-block l ": create-begin-block-with lemma" +map -docstring "Example" global latex-insert-block e ": create-begin-block-with example" +map -docstring "Proof" global latex-insert-block p ": create-begin-block-with proof" +map -docstring "Remark" global latex-insert-block r ": create-begin-block-with remark" +map -docstring "Proposition" global latex-insert-block ": create-begin-block-with proposition" +map -docstring "Corollary" global latex-insert-block c ": create-begin-block-with corollary" +## Common environments +map -docstring "align*" global latex-insert-block a ": create-begin-block-with align*" +map -docstring "align" global latex-insert-block ": create-begin-block-with align" +map -docstring "equation" global latex-insert-block e ": create-begin-block-with equation" +map -docstring "equation*" global latex-insert-block ": create-begin-block-with equation*" +map -docstring "Matrix" global latex-insert-block m ": create-begin-block-with bmatrix" +map -docstring "Cases" global latex-insert-block C ": create-begin-block-with cases" +map -docstring "Table" global latex-insert-block T ": create-begin-block-with tabular" +## Custom +map -docstring "Custom" global latex-insert-block c ": create-begin-block" - # Pairs of delimiters - declare-user-mode latex-insert-delims - map -docstring "Grouping" global latex-insert-delims g ": create-delims { }" - map -docstring "Parentheses" global latex-insert-delims p ": create-delims ( )" - map -docstring "Large Parentheses" global latex-insert-delims P ": create-delims \left( \right)" - map -docstring "Brackets" global latex-insert-delims b ": create-delims \left[ \right]" - map -docstring "Sets" global latex-insert-delims s ": create-delims \{ \}" - map -docstring "Large Sets" global latex-insert-delims S ": create-delims \left\{ \right\}" +# Pairs of delimiters +declare-user-mode latex-insert-delims +map -docstring "Grouping" global latex-insert-delims g ": create-delims { }" +map -docstring "Parentheses" global latex-insert-delims p ": create-delims ( )" +map -docstring "Large Parentheses" global latex-insert-delims P ": create-delims \left( \right)" +map -docstring "Brackets" global latex-insert-delims b ": create-delims \left[ \right]" +map -docstring "Sets" global latex-insert-delims s ": create-delims \{ \}" +map -docstring "Large Sets" global latex-insert-delims S ": create-delims \left\{ \right\}" + +hook global WinSetOption filetype=(tex|latex) %{ ## Create delims (shortcuts) map buffer normal ": enter-user-mode latex-insert-delimsp" map buffer insert ": enter-user-mode latex-insert-delimsp" diff --git a/home/kakoune/kakrc b/home/kakoune/kakrc index 54d5b34..504bb8b 100644 --- a/home/kakoune/kakrc +++ b/home/kakoune/kakrc @@ -146,10 +146,6 @@ hook global WinSetOption filetype=(rust) %{ set-option buffer makecmd "cargo check" } -hook global WinSetOption filetype=(tex|latex) %{ - require-module latex-kak -} - def -hidden insert-c-n %{ try %{ lsp-snippets-select-next-placeholders diff --git a/home/kakoune/kaktex.nix b/home/kakoune/kaktex.nix index cf5c9db..c446a6d 100644 --- a/home/kakoune/kaktex.nix +++ b/home/kakoune/kaktex.nix @@ -14,9 +14,11 @@ in # Source kaktex whenever we have a tex file programs.my-kakoune.rc = '' hook global WinSetOption filetype=(tex|latex) %{ + hook window WinDisplay '.*' %{ eval %sh{ ${kaktexScript} set $kak_client $kak_session } + } } ''; }