diff --git a/home/common.nix b/home/common.nix index b646fc1..7e4e944 100644 --- a/home/common.nix +++ b/home/common.nix @@ -2,7 +2,7 @@ { imports = [ - ./kakoune/kak.nix + ./kakoune.nix ./fish/fish.nix ./modules/programs/my-broot.nix ./modules/programs/my-sway diff --git a/home/kakoune/kak.nix b/home/kakoune.nix similarity index 98% rename from home/kakoune/kak.nix rename to home/kakoune.nix index cfd5d6a..1963430 100644 --- a/home/kakoune/kak.nix +++ b/home/kakoune.nix @@ -3,7 +3,7 @@ let in { - imports = [ ../modules/programs/my-kakoune ./kaktex.nix ]; + imports = [ ./modules/programs/my-kakoune ]; home.packages = with pkgs; [ # ctags for peneira diff --git a/home/kakoune/autoload/latex.kak b/home/kakoune/autoload/latex.kak deleted file mode 100644 index 4bb9c9d..0000000 --- a/home/kakoune/autoload/latex.kak +++ /dev/null @@ -1,133 +0,0 @@ -## Author: @natsukagami (https://github.com/natsukagami) -## -## To activate, source the file into kakrc and add: -### require-module latex-kak -## -## NOTE: This overrides , so if you don't like it, remove it. - -# 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" - -# "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\}" - - -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" - map buffer normal ": enter-user-mode latex-insert-delimsg" - map buffer insert ": enter-user-mode latex-insert-delimsg" - map buffer normal "i\(\)Zhhi" - map buffer insert "\(\)Z2h" - map buffer normal "i\[\]Zhhi" - map buffer insert "\[\]Z2h" - map buffer normal ": enter-user-mode latex-insert-delims" - map buffer insert ": enter-user-mode latex-insert-delims" - - ## Quickly create begin/end blocks - map buffer normal ": create-begin-block" - map buffer insert ": create-begin-block" - - ## Font menu - map buffer normal ": enter-user-mode latex-font" - map buffer insert ": enter-user-mode latex-font" - - ## Insert menu - map buffer normal ": enter-user-mode latex-insert-block" - map buffer insert ": enter-user-mode latex-insert-block" - - ## Select math equations and environment blocks - map buffer object e -docstring "Inline Math equation \( \)" "c\\\\\\(,\\\\\\)" - map buffer object E -docstring "Display Math equation \[ \]" "c\\\\\\[,\\\\\\]" - map buffer object v -docstring "Simple environment \env{}" "c\\\\\\w+\\{,\\}" - map buffer object V -docstring "Full environment \begin{env}\end{env}" "c\\\\begin\\{\\w+\\}(?:\\{[\\w\\s]*\\})*(?:\\[[\\w\\s]*\\])*,\\\\end\\{\\w+\\}" - - ## Quickly get a new item - map buffer normal "o\item " - map buffer insert "o\item " -} - diff --git a/home/kakoune/autoload/markdown.kak b/home/kakoune/autoload/markdown.kak deleted file mode 100644 index fb10581..0000000 --- a/home/kakoune/autoload/markdown.kak +++ /dev/null @@ -1,29 +0,0 @@ -hook global WinSetOption filetype=(markdown) %{ - map buffer normal ": enter-user-mode markdown-menu" -} - -# A menu for common markdown actions -declare-user-mode markdown-menu - -map -docstring "Toggle the checkboxes on the same line" global markdown-menu t ": markdown-toggle-checkbox" - -define-command -hidden markdown-toggle-checkbox %{ - try %{ - execute-keys -draft "xs^\s*- \[( |x)\]h: markdown-toggle-checkbox-selections" - } -} - -define-command -hidden markdown-toggle-checkbox-selections %{ - try %{ - execute-keys -draft -itersel ": markdown-toggle-checkbox-one" - } -} - -define-command -hidden markdown-toggle-checkbox-one %{ - try %{ - execute-keys -draft "sxr " - } catch %{ - execute-keys -draft "s rx" - } -} - diff --git a/home/kakoune/catppuccin-latte.kak b/home/kakoune/catppuccin-latte.kak deleted file mode 100644 index bd40ead..0000000 --- a/home/kakoune/catppuccin-latte.kak +++ /dev/null @@ -1,79 +0,0 @@ -# Catppuccin theme for Kakoune - -declare-option str rosewater "rgb:dc8a78" -declare-option str flamingo "rgb:dd7878" -declare-option str pink "rgb:ea76cb" -declare-option str mauve "rgb:8839ef" -declare-option str red "rgb:d20f39" -declare-option str maroon "rgb:e64553" -declare-option str peach "rgb:fe640b" -declare-option str yellow "rgb:df8e1d" -declare-option str green "rgb:40a02b" -declare-option str teal "rgb:179299" -declare-option str sky "rgb:04a5e5" -declare-option str sapphire "rgb:209fb5" -declare-option str blue "rgb:1e66f5" -declare-option str lavender "rgb:7287fd" -declare-option str text "rgb:4c4f69" -declare-option str subtext1 "rgb:5c5f77" -declare-option str subtext0 "rgb:6c6f85" -declare-option str overlay2 "rgb:7c7f93" -declare-option str overlay1 "rgb:8c8fa1" -declare-option str overlay0 "rgb:9ca0b0" -declare-option str surface2 "rgb:acb0be" -declare-option str surface1 "rgb:bcc0cc" -declare-option str surface0 "rgb:ccd0da" -declare-option str base "rgb:eff1f5" -declare-option str mantle "rgb:e6e9ef" -declare-option str crust "rgb:dce0e8" - - -set-face global title "%opt{text}+b" -set-face global header "%opt{subtext0}+b" -set-face global bold "%opt{maroon}+b" -set-face global italic "%opt{maroon}+i" -set-face global mono "%opt{green}" -set-face global block "%opt{sapphire}" -set-face global link "%opt{blue}" -set-face global bullet "%opt{peach}" -set-face global list "%opt{peach}" - -set-face global Default "%opt{text},%opt{base}" -set-face global PrimarySelection "%opt{text},%opt{surface2}" -set-face global SecondarySelection "%opt{text},%opt{surface2}" -set-face global PrimaryCursor "%opt{crust},%opt{rosewater}" -set-face global SecondaryCursor "%opt{text},%opt{overlay0}" -set-face global PrimaryCursorEol "%opt{surface2},%opt{lavender}" -set-face global SecondaryCursorEol "%opt{surface2},%opt{overlay1}" -set-face global LineNumbers "%opt{overlay1},%opt{base}" -set-face global LineNumberCursor "%opt{rosewater},%opt{surface2}+b" -set-face global LineNumbersWrapped "%opt{rosewater},%opt{surface2}+i" -set-face global MenuForeground "%opt{text},%opt{surface1}+b" -set-face global MenuBackground "%opt{text},%opt{surface0}" -set-face global MenuInfo "%opt{crust},%opt{teal}" -set-face global Information "%opt{crust},%opt{teal}" -set-face global Error "%opt{crust},%opt{red}" -set-face global StatusLine "%opt{text},%opt{mantle}" -set-face global StatusLineMode "%opt{crust},%opt{yellow}" -set-face global StatusLineInfo "%opt{crust},%opt{teal}" -set-face global StatusLineValue "%opt{crust},%opt{yellow}" -set-face global StatusCursor "%opt{crust},%opt{rosewater}" -set-face global Prompt "%opt{teal},%opt{base}+b" -set-face global MatchingChar "%opt{maroon},%opt{base}" -set-face global Whitespace "%opt{overlay1},%opt{base}+f" -set-face global WrapMarker "Whitespace" -set-face global BufferPadding "%opt{base},%opt{base}" - -set-face global value "%opt{peach}" -set-face global type "%opt{blue}" -set-face global variable "%opt{text}" -set-face global module "%opt{maroon}" -set-face global function "%opt{blue}" -set-face global string "%opt{green}" -set-face global keyword "%opt{mauve}" -set-face global operator "%opt{sky}" -set-face global attribute "%opt{green}" -set-face global comment "%opt{overlay0}" -set-face global documentation "comment" -set-face global meta "%opt{yellow}" -set-face global builtin "%opt{red}" diff --git a/home/kakoune/kakrc b/home/kakoune/kakrc deleted file mode 100644 index c254669..0000000 --- a/home/kakoune/kakrc +++ /dev/null @@ -1,233 +0,0 @@ -# Enable kak-tree-sitter -eval %sh{test -z "$WE_STARTED_KAK" && kak-tree-sitter --kakoune -d --server --init $kak_session} -map global normal ": enter-user-mode tree-sitter" -# ## Set some color overrides -# set global kts_yellow "rgb:e2b75e" -# set global kts_teal "rgb:008080" -# set global kts_mauve "rgb:c264ff" -# set global kts_sky "rgb:6aa622" -# Color scheme -colorscheme catppuccin-latte -set global base "default" - -# Set indentation guides -add-highlighter global/indent-guides show-whitespaces -tab " " -spc " " -lf " " -nbsp " " -set-face global Whitespace default,default -set-face global WhitespaceIndent +d@comment - -# Assistant -set global ui_options terminal_assistant=cat - -# Enable line numbers -hook global WinCreate .* %{ - addhl window/number-lines number-lines -} - -set global grepcmd "rg --line-number --no-column --no-heading --color=never " - -# Kitty-specific options -hook -group windowing global KakBegin .* %{ - set global kitty_window_type os-window -} - -# Comment line and block -map global normal <#> ': comment-line' -map global normal ': comment-block' - -# Go to grep-jump -map global goto f -docstring "current grep-jump match" ': grep-jump' - -# System clipboard interactions -hook global RegisterModified '"' %{ nop %sh{ - printf "%s" "$kak_main_reg_dquote" | pbcopy >/dev/null 2>/dev/null & -}} -map global user P -docstring "Paste before cursor from clipboard" '! pbpaste -n | cat' -map global user p -docstring "Paste after cursor from clipboard" ' pbpaste -n | cat' -map global user R -docstring "Replace selection with text from clipboard" '! pbpaste -n | cat' -define-command -params 0 -docstring "Copy line down" copyline %{ - execute-keys -draft 'xy'%val{count}'P' -} -map global normal <+> -docstring "Copy line down" ': copyline' -define-command -params 0 -docstring "Delete current pair of brackets" delete-current-brackets %{ - execute-keys 'm' - execute-keys -draft 'd' - execute-keys 'H' -} -map global normal D ": delete-current-brackets" - -# Disable write-to -# unalias global w -# define-command -params 0 -docstring "Writes the current file" w "write" - -# Tab sizes -hook global InsertChar \t %{ exec -draft -itersel h@ } -set global tabstop 2 -set global indentwidth 2 - -# Language-specific tabstop with override -hook global WinSetOption filetype=(rust) %{ - set window tabstop 4 - set window indentwidth 4 -} - -# Ctrl + a in insert mode = esc -map global insert '' - -# Tab completion -hook global InsertCompletionShow .* %{ - try %{ - # this command temporarily removes cursors preceded by whitespace; - # if there are no cursors left, it raises an error, does not - # continue to execute the mapping commands, and the error is eaten - # by the `try` command so no warning appears. - execute-keys -draft 'h\h' - map window insert - map window insert - } -} -hook global InsertCompletionHide .* %{ - unmap window insert - unmap window insert -} - -# Enable LSP -try %{ - eval %sh{test -z "$WE_STARTED_KAK" && kak-lsp --kakoune -s $kak_session} - set-option global lsp_cmd "kak-lsp -s %val{session}" -} -hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c|cpp|tex|latex|fsharp|ocaml|haskell|nix|scala|typst|html|css|json|markdown|templ|elixir) %{ - lsp-enable-window - map window lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" - map window normal ": enter-user-mode lsp" - map window normal ": lsp-hover" - map window normal ": lsp-hover-buffer" - # lsp-auto-hover-insert-mode-enable - set window lsp_hover_anchor true - map global insert ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' - map global object a 'lsp-object' -docstring 'LSP any symbol' - map global object 'lsp-object' -docstring 'LSP any symbol' - map global object f 'lsp-object Function Method' -docstring 'LSP function or method' - map global object t 'lsp-object Class Interface Struct' -docstring 'LSP class interface or struct' - map global object d 'lsp-diagnostic-object --include-warnings' -docstring 'LSP errors and warnings' - map global object D 'lsp-diagnostic-object' -docstring 'LSP errors' -} - -hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c|cpp|tex|latex|haskell|nix|fsharp|templ) %{ - # Format the document if possible - hook window BufWritePre .* %{ lsp-formatting-sync } -} - -hook global WinSetOption filetype=(rust|scala|fsharp) %{ - # Enable inlay hints - lsp-inlay-hints-enable window -} - -hook global WinSetOption filetype=(rust|go|fsharp|typst|scala) %{ - hook window -group semantic-tokens BufReload .* lsp-semantic-tokens - hook window -group semantic-tokens NormalIdle .* lsp-semantic-tokens - hook window -group semantic-tokens InsertIdle .* lsp-semantic-tokens - hook -once -always window WinSetOption filetype=.* %{ - remove-hooks window semantic-tokens - } -} - -# in Insert mode moves to end of line. -map global insert 'A' - -hook global WinSetOption filetype=(fsharp) %{ - set-option window comment_line "//" - # Set up formatting - # set-option window formatcmd "~/.dotnet/tools/fantomas --stdin --stdout" - # hook window -group fsharp-format BufWritePre .* %{ format } -} - -hook global WinSetOption filetype=(ocaml) %{ - unset-option buffer comment_line - set-option buffer comment_block_begin "(*" - set-option buffer comment_block_end "*)" -} - -hook global WinSetOption filetype=(haskell) %{ - set-option buffer makecmd "cabal build" -} - -hook global WinSetOption filetype=(rust) %{ - set-option buffer makecmd "cargo check" -} - -hook global WinSetOption filetype=(scala) %{ - # Format the document if possible - hook -group scala-fmt window BufWritePre .* %{ lsp-formatting-sync } -} - -hook global WinSetOption filetype=(typst) %{ - set-option window comment_line "//" - set-option window comment_block_begin "/*" - set-option window comment_block_end "*/" - - # borrow markdown's hooks - require-module markdown - - hook window ModeChange pop:insert:.* -group markdown-trim-indent markdown-trim-indent - hook window InsertChar \n -group markdown-insert markdown-insert-on-new-line - hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } -} - - -define-command -params 0 -docstring "Set up build" scala-build-connect %{ - lsp-execute-command 'build-connect' '"[]"' -} - -define-command -params 0 -docstring "Import build" scala-build-import %{ - lsp-execute-command 'build-import' '"[]"' -} - -def -hidden insert-c-n %{ - try %{ - lsp-snippets-select-next-placeholders - exec 'd' - } catch %{ - exec -with-hooks '' - } -} -map global insert ": insert-c-n" - -# Use C++ for .h headers -hook global BufCreate .*[.](h) %{ - set-option buffer filetype cpp -} - -hook global BufCreate .*[.]kakrc %{ - set-option buffer filetype kak -} - -hook global BufCreate .*[.]md %{ - add-highlighter buffer/ wrap -} - -hook global BufCreate .*[.](sc|sbt) %{ - set-option buffer filetype scala -} - -hook global BufCreate .*[.]typ %{ - set-option buffer filetype typst - add-highlighter buffer/ wrap -} - -hook global BufCreate .*[.]templ %{ - set-option buffer filetype templ - set-option buffer comment_line "//" -} - -hook global BufCreate .*[.]hylo %{ - set-option buffer filetype hylo - set-option buffer comment_line "//" -} - -hook global BufOpenFile .* %{ - modeline-parse -} - -map global normal ':inc-dec-modify-numbers + %val{count}' -map global normal ':inc-dec-modify-numbers - %val{count}' diff --git a/home/kakoune/kaktex b/home/kakoune/kaktex deleted file mode 100755 index bdcf722..0000000 --- a/home/kakoune/kaktex +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env fish - -function usage - echo "Usage: " - echo " kaktex set [client] [session]" - echo " kaktex jump [file] [line] [column]" - exit 1 -end - -if test (count $argv) -lt 3 - usage -end - -switch $argv[1] - case "set" - set -U _kaktex_client $argv[2] - set -U _kaktex_session $argv[3] - case "jump" - echo " - evaluate-commands -client $_kaktex_client %{ - evaluate-commands -try-client $_kaktex_client %{ - edit -existing -- $argv[2] $(math $argv[3] + 1) $(math $argv[4] + 1) - } - } - " | kak -p $_kaktex_session - case '*' - usage -end diff --git a/home/kakoune/kaktex.nix b/home/kakoune/kaktex.nix deleted file mode 100644 index 1256c79..0000000 --- a/home/kakoune/kaktex.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - # Source kaktex whenever we have a tex file - programs.my-kakoune.rc = '' - hook global WinSetOption filetype=(tex|latex) %{ - hook window WinDisplay '.*' %{ - eval %sh{ - ${./kaktex} set $kak_client $kak_session - } - } - } - ''; -} diff --git a/home/kakoune/source-pwd b/home/kakoune/source-pwd deleted file mode 100755 index 35e5b0f..0000000 --- a/home/kakoune/source-pwd +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env fish - -if test (pwd) = "/home/natsukagami/.config/kak" - exit 0 -end - -while true - set kakrc (pwd)/.kakrc - if test -f $kakrc - echo source $kakrc - end - if test (pwd) = "/" - exit 0 - end - cd .. -end