Further cleanup

This commit is contained in:
Natsu Kagami 2024-10-07 22:30:13 +02:00
parent 44ebe91151
commit 3367c32b1a
Signed by: nki
GPG key ID: 55A032EB38B49ADB
9 changed files with 2 additions and 534 deletions

View file

@ -2,7 +2,7 @@
{
imports = [
./kakoune/kak.nix
./kakoune.nix
./fish/fish.nix
./modules/programs/my-broot.nix
./modules/programs/my-sway

View file

@ -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

View file

@ -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 <a-o>, 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 "<esc>i\begin{b0}<ret>\end{b0}<esc>"
execute-keys "<a-/>b0<ret><a-N>"
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 "<esc>i\begin{b0}<ret>\end{b0}<esc>"
execute-keys "<a-/>b0<ret><a-N>c%arg{1}<esc>,"
execute-keys "o<esc>k"
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 "<esc>i%arg{1}<esc>hZa%arg{2}<esc>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<ret>"
map -docstring "Emphasize (emph)" global latex-font e ": create-block-with emph<ret>"
## Shape
map -docstring "Italics (textit)" global latex-font i ": create-block-with textit<ret>"
map -docstring "Upright (textup)" global latex-font u ": create-block-with textup<ret>"
# map -docstring "Slanted (textsl)" global latex-font S ": create-block-with textsl<ret>"
# map -docstring "Swash font (textsw)" global latex-font W ": create-block-with textsw<ret>"
# map -docstring "Small caps (textsc)" global latex-font C ": create-block-with textsc<ret>"
# Weight
map -docstring "Bold text (textbf)" global latex-font b ": create-block-with textbf<ret>"
# map -docstring "Medium bold (textmd)" global latex-font M ": create-block-with textmd<ret>"
# map -docstring "Normal (textnormal)" global latex-font N ": create-block-with textnormal<ret>"
## Family
# map -docstring "Serif font (textsf)" global latex-font s ": create-block-with textsf<ret>"
# map -docstring "Roman text (textrm)" global latex-font r ": create-block-with textrm<ret>"
map -docstring "Monospace (texttt)" global latex-font m ": create-block-with texttt<ret>"
## Math styles
map -docstring "Math Calligraphic (mathcal)" global latex-font <a-c> ": create-block-with mathcal<ret>"
map -docstring "Math Blackboard (mathbb)" global latex-font <a-b> ": create-block-with mathbb<ret>"
# map -docstring "Math Fraktur (mathfr)" global latex-font <a-F> ": create-block-with mathfr<ret>"
# map -docstring "Math Roman (mathrm)" global latex-font <a-r> ": create-block-with mathrm<ret>"
# map -docstring "Math Italics (mathit)" global latex-font <a-i> ": create-block-with mathit<ret>"
# map -docstring "Math Bold (mathbf)" global latex-font <a-B> ": create-block-with mathbf<ret>"
# map -docstring "Serif font (mathsf)" global latex-font <a-s> ": create-block-with mathsf<ret>"
map -docstring "Math Monospace (mathtt)" global latex-font <a-m> ": create-block-with mathtt<ret>"
map -docstring "Math Fraktur (mathfrak)" global latex-font f ": create-block-with mathfrak<ret>"
# "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<ret>"
map -docstring "Ordered list" global latex-insert-block o ": create-begin-block-with enumerate<ret>"
## Common math blocks
map -docstring "Theorem" global latex-insert-block t ": create-begin-block-with theorem<ret>"
map -docstring "Definition" global latex-insert-block d ": create-begin-block-with definition<ret>"
map -docstring "Lemma" global latex-insert-block l ": create-begin-block-with lemma<ret>"
map -docstring "Example" global latex-insert-block e ": create-begin-block-with example<ret>"
map -docstring "Proof" global latex-insert-block p ": create-begin-block-with proof<ret>"
map -docstring "Remark" global latex-insert-block r ": create-begin-block-with remark<ret>"
map -docstring "Proposition" global latex-insert-block <a-p> ": create-begin-block-with proposition<ret>"
map -docstring "Corollary" global latex-insert-block C ": create-begin-block-with corollary<ret>"
## Common environments
map -docstring "align*" global latex-insert-block a ": create-begin-block-with align*<ret>"
map -docstring "align" global latex-insert-block <a-a> ": create-begin-block-with align<ret>"
map -docstring "equation" global latex-insert-block E ": create-begin-block-with equation<ret>"
map -docstring "equation*" global latex-insert-block <a-e> ": create-begin-block-with equation*<ret>"
map -docstring "Matrix" global latex-insert-block m ": create-begin-block-with bmatrix<ret>"
map -docstring "Cases" global latex-insert-block C ": create-begin-block-with cases<ret>"
map -docstring "Table" global latex-insert-block T ": create-begin-block-with tabular<ret>"
## Custom
map -docstring "Custom" global latex-insert-block c ": create-begin-block<ret>"
# Pairs of delimiters
declare-user-mode latex-insert-delims
map -docstring "Grouping" global latex-insert-delims g ": create-delims { }<ret>"
map -docstring "Parentheses" global latex-insert-delims p ": create-delims ( )<ret>"
map -docstring "Large Parentheses" global latex-insert-delims P ": create-delims \left( \right)<ret>"
map -docstring "Brackets" global latex-insert-delims b ": create-delims \left[ \right]<ret>"
map -docstring "Sets" global latex-insert-delims s ": create-delims \{ \}<ret>"
map -docstring "Large Sets" global latex-insert-delims S ": create-delims \left\{ \right\}<ret>"
hook global WinSetOption filetype=(tex|latex) %{
## Create delims (shortcuts)
map buffer normal <a-1> ": enter-user-mode latex-insert-delims<ret>p"
map buffer insert <a-1> "<esc>: enter-user-mode latex-insert-delims<ret>p"
map buffer normal <a-2> ": enter-user-mode latex-insert-delims<ret>g"
map buffer insert <a-2> "<esc>: enter-user-mode latex-insert-delims<ret>g"
map buffer normal <a-3> "i\(\)<esc>Zhhi"
map buffer insert <a-3> "\(\)<a-;>Z<a-;>2h"
map buffer normal <a-4> "i\[\]<esc>Zhhi"
map buffer insert <a-4> "\[\]<a-;>Z<a-;>2h"
map buffer normal <a-5> ": enter-user-mode latex-insert-delims<ret>"
map buffer insert <a-5> "<esc>: enter-user-mode latex-insert-delims<ret>"
## Quickly create begin/end blocks
map buffer normal <c-n> ": create-begin-block<ret>"
map buffer insert <c-n> "<esc>: create-begin-block<ret>"
## Font menu
map buffer normal <c-b> ": enter-user-mode latex-font<ret>"
map buffer insert <c-b> "<esc>: enter-user-mode latex-font<ret>"
## Insert menu
map buffer normal <a-b> ": enter-user-mode latex-insert-block<ret>"
map buffer insert <a-b> "<esc>: enter-user-mode latex-insert-block<ret>"
## Select math equations and environment blocks
map buffer object e -docstring "Inline Math equation \( \)" "c\\\\\\(,\\\\\\)<ret>"
map buffer object E -docstring "Display Math equation \[ \]" "c\\\\\\[,\\\\\\]<ret>"
map buffer object v -docstring "Simple environment \env{}" "c\\\\\\w+\\{,\\}<ret>"
map buffer object V -docstring "Full environment \begin{env}\end{env}" "c\\\\begin\\{\\w+\\}(?:\\{[\\w\\s]*\\})*(?:\\[[\\w\\s]*\\])*,\\\\end\\{\\w+\\}<ret>"
## Quickly get a new item
map buffer normal <a-o> "o\item "
map buffer insert <a-ret> "<esc>o\item "
}

View file

@ -1,29 +0,0 @@
hook global WinSetOption filetype=(markdown) %{
map buffer normal <c-b> ": enter-user-mode markdown-menu<ret>"
}
# 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<ret>"
define-command -hidden markdown-toggle-checkbox %{
try %{
execute-keys -draft "xs^\s*- \[( |x)\]<ret>h: markdown-toggle-checkbox-selections<ret>"
}
}
define-command -hidden markdown-toggle-checkbox-selections %{
try %{
execute-keys -draft -itersel ": markdown-toggle-checkbox-one<ret>"
}
}
define-command -hidden markdown-toggle-checkbox-one %{
try %{
execute-keys -draft "sx<ret>r "
} catch %{
execute-keys -draft "s <ret>rx"
}
}

View file

@ -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}"

View file

@ -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 <c-t> ": enter-user-mode tree-sitter<ret>"
# ## 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<ret>'
map global normal <a-#> ': comment-block<ret>'
# Go to grep-jump
map global goto f -docstring "current grep-jump match" '<esc>: grep-jump<ret>'
# 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<ret>'
map global user p -docstring "Paste after cursor from clipboard" '<a-!> pbpaste -n | cat<ret>'
map global user R -docstring "Replace selection with text from clipboard" '<a-d>! pbpaste -n | cat<ret>'
define-command -params 0 -docstring "Copy line down" copyline %{
execute-keys -draft 'xy'%val{count}'P'
}
map global normal <+> -docstring "Copy line down" ': copyline<ret>'
define-command -params 0 -docstring "Delete current pair of brackets" delete-current-brackets %{
execute-keys 'm<a-:>'
execute-keys -draft '<a-S>d'
execute-keys 'H'
}
map global normal D ": delete-current-brackets<ret>"
# 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 <c-a> '<esc>'
# 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<a-K>\h<ret>'
map window insert <tab> <c-n>
map window insert <s-tab> <c-p>
}
}
hook global InsertCompletionHide .* %{
unmap window insert <tab> <c-n>
unmap window insert <s-tab> <c-p>
}
# 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<ret>"
map window normal <c-l> ": enter-user-mode lsp<ret>"
map window normal <c-h> ": lsp-hover<ret>"
map window normal <c-s-h> ": lsp-hover-buffer<ret>"
# lsp-auto-hover-insert-mode-enable
set window lsp_hover_anchor true
map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
map global object a '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
map global object <a-a> '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
map global object f '<a-semicolon>lsp-object Function Method<ret>' -docstring 'LSP function or method'
map global object t '<a-semicolon>lsp-object Class Interface Struct<ret>' -docstring 'LSP class interface or struct'
map global object d '<a-semicolon>lsp-diagnostic-object --include-warnings<ret>' -docstring 'LSP errors and warnings'
map global object D '<a-semicolon>lsp-diagnostic-object<ret>' -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
}
}
# <a-a> in Insert mode moves to end of line.
map global insert <a-a> '<esc>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 '<a-;>d'
} catch %{
exec -with-hooks '<c-n>'
}
}
map global insert <c-n> "<a-;>: insert-c-n<ret>"
# 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 <a-[> ':inc-dec-modify-numbers + %val{count}<ret>'
map global normal <a-]> ':inc-dec-modify-numbers - %val{count}<ret>'

View file

@ -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

View file

@ -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
}
}
}
'';
}

View file

@ -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