From f636223a8c451d135f1611bcdc8cd3bb5219e5b0 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 28 Sep 2024 16:18:16 +0200 Subject: [PATCH 01/41] kakoune: set up package with plugins --- packages/common/default.nix | 1 + .../common/nki-kakoune/autoload/latex.kak | 133 +++++++++++ .../common/nki-kakoune/autoload/markdown.kak | 29 +++ packages/common/nki-kakoune/default.nix | 3 + packages/common/nki-kakoune/plugins.nix | 209 ++++++++++++++++++ 5 files changed, 375 insertions(+) create mode 100644 packages/common/nki-kakoune/autoload/latex.kak create mode 100644 packages/common/nki-kakoune/autoload/markdown.kak create mode 100644 packages/common/nki-kakoune/default.nix create mode 100644 packages/common/nki-kakoune/plugins.nix diff --git a/packages/common/default.nix b/packages/common/default.nix index be4ba2a..fadb679 100644 --- a/packages/common/default.nix +++ b/packages/common/default.nix @@ -2,4 +2,5 @@ final: prev: { epfl-cups-drivers = final.callPackage ./epfl-cups-drivers { }; ttaenc = final.callPackage ./ttaenc.nix { }; suwako-cursors = final.callPackage ./suwako-cursors { }; + nki-kakoune = final.callPackage ./nki-kakoune { }; } diff --git a/packages/common/nki-kakoune/autoload/latex.kak b/packages/common/nki-kakoune/autoload/latex.kak new file mode 100644 index 0000000..4bb9c9d --- /dev/null +++ b/packages/common/nki-kakoune/autoload/latex.kak @@ -0,0 +1,133 @@ +## 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/packages/common/nki-kakoune/autoload/markdown.kak b/packages/common/nki-kakoune/autoload/markdown.kak new file mode 100644 index 0000000..fb10581 --- /dev/null +++ b/packages/common/nki-kakoune/autoload/markdown.kak @@ -0,0 +1,29 @@ +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/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix new file mode 100644 index 0000000..6e181ce --- /dev/null +++ b/packages/common/nki-kakoune/default.nix @@ -0,0 +1,3 @@ +{ callPackage, kakoune, ... }: kakoune.override { + plugins = (callPackage ./plugins.nix { }).plugins; +} diff --git a/packages/common/nki-kakoune/plugins.nix b/packages/common/nki-kakoune/plugins.nix new file mode 100644 index 0000000..a16c898 --- /dev/null +++ b/packages/common/nki-kakoune/plugins.nix @@ -0,0 +1,209 @@ +{ pkgs, symlinkJoin, writeTextDir, kakouneUtils, ... }: +with { + inherit (kakouneUtils) buildKakounePluginFrom2Nix; +}; +let + toDir = name: file: writeTextDir name (builtins.readFile file); + + writeActivationScript = script: writeTextDir "on-load.kak" '' + hook global KakBegin .* %{ + ${script} + } + ''; + + writeModuleWrapper = name: script: writeTextDir "module.kak" '' + provide-module ${name} %◍ + ${script} + ◍ + ''; + + kakounePlugin = { name, src, wrapAsModule ? false, activationScript ? null, ... }@attrs: + let + module = if wrapAsModule then writeModuleWrapper name (builtins.readFile src) else src; + in + buildKakounePluginFrom2Nix { + pname = name; + version = attrs.version or "latest"; + src = if activationScript == null then module else + symlinkJoin { + name = "${name}-src"; + paths = [ + module + (writeActivationScript activationScript) + ]; + }; + }; +in +{ + plugins = builtins.map kakounePlugin + [ + # My own scripts + { + name = "latex.kak"; + src = toDir "latex.kak" ./autoload/latex.kak; + } + { + name = "markdown.kak"; + src = toDir "markdown.kak" ./autoload/markdown.kak; + } + + # Plugins + { + name = "luar"; + src = pkgs.fetchFromGitHub { + owner = "gustavo-hms"; + repo = "luar"; + rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; + sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; + }; + activationScript = '' + # Enable luar + require-module luar + # Use luajit + set-option global luar_interpreter ${pkgs.luajit}/bin/luajit + ''; + } + { + name = "peneira"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "peneira"; + rev = "743b9971472853a752475e7c070ce99089c6840c"; + sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; + }; + activationScript = '' + require-module peneira + + # Change selection color + set-face global PeneiraSelected @PrimarySelection + + # Buffers list + define-command -hidden peneira-buffers %{ + peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ + buffer %arg{1} + } + } + + # Grep in the current location + define-command peneira-grep %{ + peneira 'line: ' "rg -n ." %{ + lua %arg{1} %{ + local file, line = arg[1]:match("([^:]+):(%d+):") + kak.edit(file, line) + } + } + } + + # A peneira menu + declare-user-mode fuzzy-match-menu + + map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" + map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" + map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" + map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" + map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" + map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" + + # Bind menu to user mode + map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" + ''; + } + { + name = "kakoune-focus"; + src = pkgs.fetchFromGitHub { + owner = "caksoylar"; + repo = "kakoune-focus"; + rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; + sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; + }; + activationScript = '' + map global user ': focus-toggle' -docstring "toggle selections focus" + ''; + } + { + name = "kakoune-inc-dec"; + src = pkgs.fetchFromGitLab { + owner = "Screwtapello"; + repo = "kakoune-inc-dec"; + rev = "7bfe9c51"; + sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; + }; + } + { + name = "racket.kak"; + src = (builtins.fetchTree { + type = "git"; + url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; + rev = "e397042009b46916ff089d79166ec0e8ca813a18"; + narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; + }) + "/rc"; + } + # { + # name = "kakoune-discord"; + # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; + # } + rec { + name = "kakoune-mirror"; + src = pkgs.fetchFromGitHub + { + owner = "Delapouite"; + repo = "kakoune-mirror"; + rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; + sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; + } + "/mirror.kak"; + wrapAsModule = true; + activationScript = '' + require-module ${name} + + # Bind to ${name} + map global normal ': enter-user-mode -lock mirror' + ''; + } + { + name = "unicode-math"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "kakoune-unicode-math"; + rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; + # sha256 = lib.fakeSha256; + sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; + fetchSubmodules = true; + }; + activationScript = '' + require-module unicode-math + + # Bind to the menu + map global insert ': insert-unicode ' + ''; + } + { + name = "kakoune-buffers"; + src = pkgs.fetchFromGitHub { + owner = "Delapouite"; + repo = "kakoune-buffers"; + rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; + sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; + }; + activationScript = '' + # Suggested hook + + hook global WinDisplay .* info-buffers + + # Suggested mappings + + map global user b ':enter-buffers-mode' -docstring 'buffers…' + map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' + map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' + + # Suggested aliases + + alias global bd delete-buffer + alias global bf buffer-first + alias global bl buffer-last + alias global bo buffer-only + alias global bo! buffer-only-force + ''; + } + ]; +} + -- 2.47.2 From 6a924444c9acab3bceb29610505d51061033804e Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 28 Sep 2024 16:34:57 +0200 Subject: [PATCH 02/41] kakoune: add back kaktex --- packages/common/nki-kakoune/default.nix | 4 +- .../common/nki-kakoune/kaktex/default.nix | 22 ++ .../common/nki-kakoune/kaktex/kaktex.fish | 26 ++ packages/common/nki-kakoune/plugins.nix | 312 +++++++++--------- 4 files changed, 205 insertions(+), 159 deletions(-) create mode 100644 packages/common/nki-kakoune/kaktex/default.nix create mode 100755 packages/common/nki-kakoune/kaktex/kaktex.fish diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 6e181ce..53622ec 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,3 +1,5 @@ { callPackage, kakoune, ... }: kakoune.override { - plugins = (callPackage ./plugins.nix { }).plugins; + plugins = (callPackage ./plugins.nix { }) ++ [ + ./kaktex + ]; } diff --git a/packages/common/nki-kakoune/kaktex/default.nix b/packages/common/nki-kakoune/kaktex/default.nix new file mode 100644 index 0000000..a8005d5 --- /dev/null +++ b/packages/common/nki-kakoune/kaktex/default.nix @@ -0,0 +1,22 @@ +{ fish, lib, writeScript, writeTextDir, kakouneUtils, ... }: +let + kaktex-script = writeScript "kaktex" '' + #!/usr/bin/env ${lib.getExe fish} + + ${builtins.readFile ./kaktex.fish} + ''; + kaktex = writeTextDir "kaktex.kak" '' + hook global WinSetOption filetype=(tex|latex) %{ + hook window WinDisplay '.*' %{ + eval %sh{ + ${kaktex-script} set $kak_client $kak_session + } + } + } + ''; +in +kakouneUtils.buildKakounePluginFrom2Nix { + pname = "kaktex"; + version = "latest"; + src = kaktex; +} diff --git a/packages/common/nki-kakoune/kaktex/kaktex.fish b/packages/common/nki-kakoune/kaktex/kaktex.fish new file mode 100755 index 0000000..bb6690b --- /dev/null +++ b/packages/common/nki-kakoune/kaktex/kaktex.fish @@ -0,0 +1,26 @@ +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/packages/common/nki-kakoune/plugins.nix b/packages/common/nki-kakoune/plugins.nix index a16c898..b524a14 100644 --- a/packages/common/nki-kakoune/plugins.nix +++ b/packages/common/nki-kakoune/plugins.nix @@ -34,176 +34,172 @@ let }; }; in -{ - plugins = builtins.map kakounePlugin - [ - # My own scripts - { - name = "latex.kak"; - src = toDir "latex.kak" ./autoload/latex.kak; - } - { - name = "markdown.kak"; - src = toDir "markdown.kak" ./autoload/markdown.kak; - } +builtins.map kakounePlugin [ + # My own scripts + { + name = "latex.kak"; + src = toDir "latex.kak" ./autoload/latex.kak; + } + { + name = "markdown.kak"; + src = toDir "markdown.kak" ./autoload/markdown.kak; + } - # Plugins - { - name = "luar"; - src = pkgs.fetchFromGitHub { - owner = "gustavo-hms"; - repo = "luar"; - rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; - sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; - }; - activationScript = '' - # Enable luar - require-module luar - # Use luajit - set-option global luar_interpreter ${pkgs.luajit}/bin/luajit - ''; - } - { - name = "peneira"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "peneira"; - rev = "743b9971472853a752475e7c070ce99089c6840c"; - sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; - }; - activationScript = '' - require-module peneira + # Plugins + { + name = "luar"; + src = pkgs.fetchFromGitHub { + owner = "gustavo-hms"; + repo = "luar"; + rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; + sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; + }; + activationScript = '' + # Enable luar + require-module luar + # Use luajit + set-option global luar_interpreter ${pkgs.luajit}/bin/luajit + ''; + } + { + name = "peneira"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "peneira"; + rev = "743b9971472853a752475e7c070ce99089c6840c"; + sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; + }; + activationScript = '' + require-module peneira - # Change selection color - set-face global PeneiraSelected @PrimarySelection + # Change selection color + set-face global PeneiraSelected @PrimarySelection - # Buffers list - define-command -hidden peneira-buffers %{ - peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ - buffer %arg{1} - } + # Buffers list + define-command -hidden peneira-buffers %{ + peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ + buffer %arg{1} } + } - # Grep in the current location - define-command peneira-grep %{ - peneira 'line: ' "rg -n ." %{ - lua %arg{1} %{ - local file, line = arg[1]:match("([^:]+):(%d+):") - kak.edit(file, line) - } - } + # Grep in the current location + define-command peneira-grep %{ + peneira 'line: ' "rg -n ." %{ + lua %arg{1} %{ + local file, line = arg[1]:match("([^:]+):(%d+):") + kak.edit(file, line) } - - # A peneira menu - declare-user-mode fuzzy-match-menu - - map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" - map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" - map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" - map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" - map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" - map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" - - # Bind menu to user mode - map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" - ''; + } } + + # A peneira menu + declare-user-mode fuzzy-match-menu + + map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" + map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" + map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" + map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" + map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" + map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" + + # Bind menu to user mode + map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" + ''; + } + { + name = "kakoune-focus"; + src = pkgs.fetchFromGitHub { + owner = "caksoylar"; + repo = "kakoune-focus"; + rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; + sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; + }; + activationScript = '' + map global user ': focus-toggle' -docstring "toggle selections focus" + ''; + } + { + name = "kakoune-inc-dec"; + src = pkgs.fetchFromGitLab { + owner = "Screwtapello"; + repo = "kakoune-inc-dec"; + rev = "7bfe9c51"; + sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; + }; + } + { + name = "racket.kak"; + src = (builtins.fetchTree { + type = "git"; + url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; + rev = "e397042009b46916ff089d79166ec0e8ca813a18"; + narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; + }) + "/rc"; + } + # { + # name = "kakoune-discord"; + # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; + # } + rec { + name = "kakoune-mirror"; + src = pkgs.fetchFromGitHub { - name = "kakoune-focus"; - src = pkgs.fetchFromGitHub { - owner = "caksoylar"; - repo = "kakoune-focus"; - rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; - sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; - }; - activationScript = '' - map global user ': focus-toggle' -docstring "toggle selections focus" - ''; - } - { - name = "kakoune-inc-dec"; - src = pkgs.fetchFromGitLab { - owner = "Screwtapello"; - repo = "kakoune-inc-dec"; - rev = "7bfe9c51"; - sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; - }; - } - { - name = "racket.kak"; - src = (builtins.fetchTree { - type = "git"; - url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; - rev = "e397042009b46916ff089d79166ec0e8ca813a18"; - narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; - }) + "/rc"; - } - # { - # name = "kakoune-discord"; - # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; - # } - rec { - name = "kakoune-mirror"; - src = pkgs.fetchFromGitHub - { - owner = "Delapouite"; - repo = "kakoune-mirror"; - rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; - sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; - } + "/mirror.kak"; - wrapAsModule = true; - activationScript = '' - require-module ${name} + owner = "Delapouite"; + repo = "kakoune-mirror"; + rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; + sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; + } + "/mirror.kak"; + wrapAsModule = true; + activationScript = '' + require-module ${name} - # Bind to ${name} - map global normal ': enter-user-mode -lock mirror' - ''; - } - { - name = "unicode-math"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "kakoune-unicode-math"; - rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; - # sha256 = lib.fakeSha256; - sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; - fetchSubmodules = true; - }; - activationScript = '' - require-module unicode-math + # Bind to ${name} + map global normal ': enter-user-mode -lock mirror' + ''; + } + { + name = "unicode-math"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "kakoune-unicode-math"; + rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; + # sha256 = lib.fakeSha256; + sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; + fetchSubmodules = true; + }; + activationScript = '' + require-module unicode-math - # Bind to the menu - map global insert ': insert-unicode ' - ''; - } - { - name = "kakoune-buffers"; - src = pkgs.fetchFromGitHub { - owner = "Delapouite"; - repo = "kakoune-buffers"; - rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; - sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; - }; - activationScript = '' - # Suggested hook + # Bind to the menu + map global insert ': insert-unicode ' + ''; + } + { + name = "kakoune-buffers"; + src = pkgs.fetchFromGitHub { + owner = "Delapouite"; + repo = "kakoune-buffers"; + rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; + sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; + }; + activationScript = '' + # Suggested hook - hook global WinDisplay .* info-buffers + hook global WinDisplay .* info-buffers - # Suggested mappings + # Suggested mappings - map global user b ':enter-buffers-mode' -docstring 'buffers…' - map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' - map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' + map global user b ':enter-buffers-mode' -docstring 'buffers…' + map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' + map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' - # Suggested aliases - - alias global bd delete-buffer - alias global bf buffer-first - alias global bl buffer-last - alias global bo buffer-only - alias global bo! buffer-only-force - ''; - } - ]; -} + # Suggested aliases + alias global bd delete-buffer + alias global bf buffer-first + alias global bl buffer-last + alias global bo buffer-only + alias global bo! buffer-only-force + ''; + } +] -- 2.47.2 From 22f6e123de7ce8ebc20c655de04b83dde0c4294e Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 28 Sep 2024 16:54:39 +0200 Subject: [PATCH 03/41] kakoune: add back themes --- packages/common/nki-kakoune/default.nix | 4 +- packages/common/nki-kakoune/themes.nix | 9 +++ .../nki-kakoune/themes/catppuccin-latte.kak | 79 +++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 packages/common/nki-kakoune/themes.nix create mode 100644 packages/common/nki-kakoune/themes/catppuccin-latte.kak diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 53622ec..2c6a83d 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,5 +1,7 @@ { callPackage, kakoune, ... }: kakoune.override { - plugins = (callPackage ./plugins.nix { }) ++ [ + plugins = callPackage ./plugins.nix { } + ++ callPackage ./themes.nix { } + ++ [ ./kaktex ]; } diff --git a/packages/common/nki-kakoune/themes.nix b/packages/common/nki-kakoune/themes.nix new file mode 100644 index 0000000..5be9a6d --- /dev/null +++ b/packages/common/nki-kakoune/themes.nix @@ -0,0 +1,9 @@ +{ writeScriptDir, ... }: +let + themes = [ + { name = "catppuccin-latte"; src = ./themes/catppucin-latte.kak; } + ]; + + themeToColorscheme = name: src: writeScriptDir "share/kak/colors/${name}.kak" (builtins.readFile src); +in +builtins.map themeToColorscheme themes diff --git a/packages/common/nki-kakoune/themes/catppuccin-latte.kak b/packages/common/nki-kakoune/themes/catppuccin-latte.kak new file mode 100644 index 0000000..bd40ead --- /dev/null +++ b/packages/common/nki-kakoune/themes/catppuccin-latte.kak @@ -0,0 +1,79 @@ +# 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}" -- 2.47.2 From 87af0ae3bacf4073325c895a02c38763212ae621 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 14:30:47 +0200 Subject: [PATCH 04/41] Add lsp and rc --- home/common.nix | 1 + overlay.nix | 2 + packages/common/nki-kakoune/default.nix | 22 +- packages/common/nki-kakoune/kakrc | 191 ++++++++++++ packages/common/nki-kakoune/lsp.nix | 307 ++++++++++++++++++++ packages/common/nki-kakoune/rc.nix | 18 ++ packages/common/nki-kakoune/source-pwd.fish | 14 + packages/common/nki-kakoune/themes.nix | 6 +- packages/common/nki-kakoune/utils.nix | 5 + 9 files changed, 560 insertions(+), 6 deletions(-) create mode 100644 packages/common/nki-kakoune/kakrc create mode 100644 packages/common/nki-kakoune/lsp.nix create mode 100644 packages/common/nki-kakoune/rc.nix create mode 100755 packages/common/nki-kakoune/source-pwd.fish create mode 100644 packages/common/nki-kakoune/utils.nix diff --git a/home/common.nix b/home/common.nix index 2034fce..3007565 100644 --- a/home/common.nix +++ b/home/common.nix @@ -42,6 +42,7 @@ unzip zstd atool + nki-kakoune ]; home.sessionVariables = { diff --git a/overlay.nix b/overlay.nix index 4ad7209..e38f3a1 100644 --- a/overlay.nix +++ b/overlay.nix @@ -102,6 +102,8 @@ let buildInputs = (with final; lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Security SystemConfiguration CoreServices ]) ) ++ (with final; [ libiconv ]); + + meta.mainProgram = "kak-lsp"; }; zen-browser-bin = final.callPackage inputs.zen-browser.packages.${final.stdenv.system}.zen-browser.override { diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 2c6a83d..bb65355 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,7 +1,23 @@ -{ callPackage, kakoune, ... }: kakoune.override { +{ callPackage, kakoune, kakoune-unwrapped, ... }: +let + lsp = callPackage ./lsp.nix { }; +in +(kakoune.override { plugins = callPackage ./plugins.nix { } ++ callPackage ./themes.nix { } ++ [ - ./kaktex + (callPackage ./kaktex { }) + (callPackage ./rc.nix { }) + lsp.plugin ]; -} +}).overrideAttrs (attrs: { + buildCommand = '' + ${attrs.buildCommand or ""} + # location of kak binary is used to find ../share/kak/autoload, + # unless explicitly overriden with KAKOUNE_RUNTIME + rm "$out/bin/kak" + makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \ + --set KAKOUNE_RUNTIME "$out/share/kak" \ + --suffix PATH ":" "${lsp.extraPaths}" + ''; +}) diff --git a/packages/common/nki-kakoune/kakrc b/packages/common/nki-kakoune/kakrc new file mode 100644 index 0000000..aafa044 --- /dev/null +++ b/packages/common/nki-kakoune/kakrc @@ -0,0 +1,191 @@ +# 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 +} + +# 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/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix new file mode 100644 index 0000000..3712d6f --- /dev/null +++ b/packages/common/nki-kakoune/lsp.nix @@ -0,0 +1,307 @@ +{ lib +, writeTextDir +, formats +, kak-lsp +, # LSP packages + ccls +, gopls +, nil +, nixpkgs-fmt +, python311Packages +, ltex-ls +, nodePackages +, tailwindcss-language-server +, fsautocomplete +, metals +, texlab +, marksman +, rust-analyzer +, ... +}: +let + # Configuration for kak-lsp + config = { + languageIDs = { + c = "c_cpp"; + cpp = "c_cpp"; + javascript = "javascriptreact"; + typescript = "typescriptreact"; + protobuf = "proto"; + sh = "shellscript"; + }; + + languageServers = + let + vscodeServerOf = name: { + name = "vscode-${name}-language-server"; + value = { + args = [ "--stdio" ]; + command = "vscode-${name}-language-server"; + filetypes = [ name "templ" ]; + roots = [ "package.json" ".git" ]; + }; + package = nodePackages.vscode-langservers-extracted; + }; + in + { + ccls = { + args = [ "-v=2" "-log-file=/tmp/ccls.log" ]; + package = ccls; + command = "ccls"; + filetypes = [ "c" "cpp" ]; + roots = [ "compile_commands.json" ".cquery" ".git" ]; + }; + gopls = { + command = "gopls"; + package = gopls; + filetypes = [ "go" ]; + offset_encoding = "utf-8"; + roots = [ "Gopkg.toml" "go.mod" ".git" ".hg" ]; + settings = { gopls = { hoverKind = "SynopsisDocumentation"; semanticTokens = true; }; }; + settings_section = "gopls"; + }; + haskell-language-server = { + args = [ "--lsp" ]; + command = "haskell-language-server-wrapper"; + filetypes = [ "haskell" ]; + roots = [ "Setup.hs" "stack.yaml" "*.cabal" "package.yaml" ]; + settings_section = "haskell"; + }; + nil = { + command = "nil"; + package = nil; + filetypes = [ "nix" ]; + roots = [ "flake.nix" "shell.nix" ".git" ]; + settings.nil = { + formatting.command = [ "${lib.getExe nixpkgs-fmt}" ]; + }; + }; + pylsp = { + command = "pylsp"; + package = python311Packages.python-lsp-server; + filetypes = [ "python" ]; + offset_encoding = "utf-8"; + roots = [ "requirements.txt" "setup.py" ".git" ".hg" ]; + }; + # Spellchecking server + ltex-ls = { + command = "ltex-ls"; + args = [ "--log-file=/tmp" ]; + filetypes = [ "latex" "typst" ]; + roots = [ "main.tex" "main.typ" ".git" ]; + package = ltex-ls; + }; + tailwind = { + command = "tailwindcss-language-server"; + args = [ "--stdio" ]; + filetypes = [ "html" "css" "javascript" "typescript" "templ" ]; + roots = [ "tailwind.config.{js,cjs,mjs,ts}" "package.json" ".git" ]; + settings_section = "tailwindCSS"; + settings.tailwindCSS = { + validate = "warning"; + userLanguages.templ = "html"; + }; + package = tailwindcss-language-server; + }; + elixir-ls = { + args = [ ]; + command = "elixir-ls"; + filetypes = [ "elixir" ]; + roots = [ "mix.exs" ]; + }; + typescript-language-server = { + args = [ "--stdio" ]; + command = "typescript-language-server"; + filetypes = [ "typescript" "javascript" ]; + roots = [ "package.json" ]; + package = nodePackages.typescript-language-server; + }; + fsautocomplete = { + args = [ "--adaptive-lsp-server-enabled" "--project-graph-enabled" "--source-text-factory" "RoslynSourceText" ]; + command = "fsautocomplete"; + filetypes = [ "fsharp" ]; + roots = [ "*.fsproj" ]; + settings_section = "FSharp"; + settings.FSharp = { + AutomaticWorkspaceInit = true; + }; + package = fsautocomplete; + }; + metals = { + command = "metals"; + filetypes = [ "scala" ]; + roots = [ "build.sbt" "build.sc" ]; + settings_section = "metals"; + settings.metals = { + enableSemanticHighlighting = true; + showInferredType = true; + decorationProvider = true; + inlineDecorationProvider = true; + # From kakoune-lsp's own options + icons = "unicode"; + isHttpEnabled = true; + statusBarProvider = "log-message"; + compilerOptions = { overrideDefFormat = "unicode"; }; + }; + package = metals; + }; + texlab = { + command = "texlab"; + filetypes = [ "latex" ]; + roots = [ "main.tex" "all.tex" ".git" ]; + settings_section = "texlab"; + settings.texlab = { + build.executable = "latexmk"; + build.args = [ "-pdf" "-shell-escape" "-interaction=nonstopmode" "-synctex=1" "%f" ]; + + build.forwardSearchAfter = true; + build.onSave = true; + + # forwardSearch = + # (if pkgs.stdenv.isDarwin then { + # executable = "/Applications/Skim.app/Contents/SharedSupport/displayline"; + # args = [ "-r" "-g" "%l" "%p" "%f" ]; + # } else + # { + # executable = "${pkgs.zathura}/bin/zathura"; + # args = [ "--synctex-forward" "%l:1:%f" "%p" "-x" "${./kaktex} jump %%{input} %%{line} %%{column}" ]; + # }); + }; + package = texlab; + }; + typst-lsp = { + command = "typst-lsp"; + filetypes = [ "typst" ]; + roots = [ "main.typ" ".git" ]; + settings_section = "typst-lsp"; + settings.typst-lsp = { + experimentalFormatterMode = "on"; + }; + }; + marksman = { + command = "marksman"; + filetypes = [ "markdown" ]; + roots = [ ".marksman.toml" ".git" ]; + package = marksman; + }; + rust-analyzer = { + args = [ ]; + command = "rust-analyzer"; + filetypes = [ "rust" ]; + roots = [ "Cargo.toml" ]; + package = rust-analyzer; + }; + + } // (builtins.listToAttrs (builtins.map vscodeServerOf [ "html" "css" "json" ])); + + faces = [ + ## Items + # (Rust) Macros + { face = "attribute"; token = "attribute"; } + { face = "attribute"; token = "derive"; } + { face = "macro"; token = "macro"; } # Function-like Macro + # Keyword and Fixed Tokens + { face = "keyword"; token = "keyword"; } + { face = "operator"; token = "operator"; } + # Functions and Methods + { face = "function"; token = "function"; } + { face = "method"; token = "method"; } + # Constants + { face = "string"; token = "string"; } + { face = "format_specifier"; token = "formatSpecifier"; } + # Variables + { face = "variable"; token = "variable"; modifiers = [ "readonly" ]; } + { face = "mutable_variable"; token = "variable"; } + { face = "module"; token = "namespace"; } + { face = "variable"; token = "type_parameter"; } + { face = "class"; token = "enum"; } + { face = "class"; token = "struct"; } + { face = "class"; token = "trait"; } + { face = "class"; token = "union"; } + { face = "class"; token = "class"; } + + ## Comments + { face = "documentation"; token = "comment"; modifiers = [ "documentation" ]; } + { face = "comment"; token = "comment"; } + + # Typst + { face = "header"; token = "heading"; } + { face = "ts_markup_link_url"; token = "link"; } + { face = "ts_markup_link_uri"; token = "ref"; } + { face = "ts_markup_link_label"; token = "label"; } + { face = "ts_property"; token = "pol"; } + { face = "ts_markup_list_checked"; token = "marker"; } + { face = "ts_constant_builtin_boolean"; token = "bool"; } + { face = "ts_keyword_control"; token = "delim"; } + { face = "ts_number"; token = "text"; modifiers = [ "math" ]; } + { face = "ts_markup_bold"; token = "text"; modifiers = [ "strong" ]; } + { face = "ts_markup_italic"; token = "text"; modifiers = [ "emph" ]; } + ]; + + raw = { + server = { timeout = 1800; }; + snippet_support = false; + verbosity = 255; + }; + }; + + kak-lsp-config = + let + toml = formats.toml { }; + toLspConfig = attrs: builtins.removeAttrs attrs [ "package" ]; + in + toml.generate "kak-lsp.toml" ({ + semantic_tokens.faces = config.faces; + language_server = toLspConfig config.languageServers; + language_ids = config.languageIDs; + } // config.raw); + + serverPackages = + builtins.filter (v: v != null) + (lib.mapAttrsToList (_: serv: serv.package or null) config.languageServers); +in +{ + extraPaths = lib.makeBinPath serverPackages; + plugin = writeTextDir "share/kak/autoload/kak-lsp.kak" '' + hook global KakBegin .* %{ + try %{ + eval %sh{${lib.getExe kak-lsp} --config ${kak-lsp-config} -s $kak_session} + } + + lsp-enable + 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 + } + } + } + ''; +} + diff --git a/packages/common/nki-kakoune/rc.nix b/packages/common/nki-kakoune/rc.nix new file mode 100644 index 0000000..fa4c94d --- /dev/null +++ b/packages/common/nki-kakoune/rc.nix @@ -0,0 +1,18 @@ +{ lib, fish, writeScript, writeTextDir, ... }: + +let + source-pwd = writeScript "source-pwd" '' + #!/usr/bin/env ${lib.getExe fish} + + ${builtins.readFile ./source-pwd.fish} + ''; +in +writeTextDir "share/kak/kakrc.local" '' + ${builtins.readFile ./kakrc} + + # Source any settings in the current working directory, + # recursive upwards + evaluate-commands %sh{ + ${source-pwd} + } +'' diff --git a/packages/common/nki-kakoune/source-pwd.fish b/packages/common/nki-kakoune/source-pwd.fish new file mode 100755 index 0000000..aa9aa37 --- /dev/null +++ b/packages/common/nki-kakoune/source-pwd.fish @@ -0,0 +1,14 @@ +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 diff --git a/packages/common/nki-kakoune/themes.nix b/packages/common/nki-kakoune/themes.nix index 5be9a6d..5c24299 100644 --- a/packages/common/nki-kakoune/themes.nix +++ b/packages/common/nki-kakoune/themes.nix @@ -1,9 +1,9 @@ -{ writeScriptDir, ... }: +{ writeTextDir, ... }: let themes = [ - { name = "catppuccin-latte"; src = ./themes/catppucin-latte.kak; } + { name = "catppuccin-latte"; src = ./themes/catppuccin-latte.kak; } ]; - themeToColorscheme = name: src: writeScriptDir "share/kak/colors/${name}.kak" (builtins.readFile src); + themeToColorscheme = { name, src }: writeTextDir "share/kak/colors/${name}.kak" (builtins.readFile src); in builtins.map themeToColorscheme themes diff --git a/packages/common/nki-kakoune/utils.nix b/packages/common/nki-kakoune/utils.nix new file mode 100644 index 0000000..47e7c75 --- /dev/null +++ b/packages/common/nki-kakoune/utils.nix @@ -0,0 +1,5 @@ +{ lib, writeFile, ... }: { + mkFacesScript = name: faces: writeFile "${name}-faces.kak" ( + lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") faces)) + ); +} -- 2.47.2 From 53cafeb0210aeb3baef41fe81449a774363d9d13 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 16:31:33 +0200 Subject: [PATCH 05/41] Add tree-sitter --- packages/common/kak-tree-sitter.nix | 2 + packages/common/nki-kakoune/default.nix | 7 +- packages/common/nki-kakoune/kakrc | 3 - packages/common/nki-kakoune/rc.nix | 11 +- .../nki-kakoune/tree-sitter/default.nix | 171 ++++++++++++++++++ .../nki-kakoune/tree-sitter/grammars.nix | 119 ++++++++++++ packages/common/nki-kakoune/utils.nix | 10 +- 7 files changed, 314 insertions(+), 9 deletions(-) create mode 100644 packages/common/nki-kakoune/tree-sitter/default.nix create mode 100644 packages/common/nki-kakoune/tree-sitter/grammars.nix diff --git a/packages/common/kak-tree-sitter.nix b/packages/common/kak-tree-sitter.nix index 3e0c6a9..9819e3a 100644 --- a/packages/common/kak-tree-sitter.nix +++ b/packages/common/kak-tree-sitter.nix @@ -35,6 +35,8 @@ let self.runtime_dir.join("sources").join(url_dir) '') ]; + + meta.mainProgram = "kak-tree-sitter"; }; in kak-tree-sitter diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index bb65355..0d48b06 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,13 +1,18 @@ { callPackage, kakoune, kakoune-unwrapped, ... }: let lsp = callPackage ./lsp.nix { }; + tree-sitter = callPackage ./tree-sitter { }; + rc = (callPackage ./rc.nix { + prependRc = tree-sitter.rc; + }); in (kakoune.override { plugins = callPackage ./plugins.nix { } ++ callPackage ./themes.nix { } ++ [ (callPackage ./kaktex { }) - (callPackage ./rc.nix { }) + rc + tree-sitter.plugin lsp.plugin ]; }).overrideAttrs (attrs: { diff --git a/packages/common/nki-kakoune/kakrc b/packages/common/nki-kakoune/kakrc index aafa044..dc06ca3 100644 --- a/packages/common/nki-kakoune/kakrc +++ b/packages/common/nki-kakoune/kakrc @@ -1,6 +1,3 @@ -# 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" diff --git a/packages/common/nki-kakoune/rc.nix b/packages/common/nki-kakoune/rc.nix index fa4c94d..ac579c9 100644 --- a/packages/common/nki-kakoune/rc.nix +++ b/packages/common/nki-kakoune/rc.nix @@ -1,4 +1,11 @@ -{ lib, fish, writeScript, writeTextDir, ... }: +{ lib +, fish +, writeScript +, writeTextDir +, prependRc ? "" +, appendRc ? "" +, ... +}: let source-pwd = writeScript "source-pwd" '' @@ -8,7 +15,9 @@ let ''; in writeTextDir "share/kak/kakrc.local" '' + ${prependRc} ${builtins.readFile ./kakrc} + ${appendRc} # Source any settings in the current working directory, # recursive upwards diff --git a/packages/common/nki-kakoune/tree-sitter/default.nix b/packages/common/nki-kakoune/tree-sitter/default.nix new file mode 100644 index 0000000..ce16343 --- /dev/null +++ b/packages/common/nki-kakoune/tree-sitter/default.nix @@ -0,0 +1,171 @@ +{ lib +, callPackage +, formats +, runCommandLocal +, kak-tree-sitter +, ... +}: +let + utils = callPackage ../utils.nix { }; + grammars = (callPackage ./grammars.nix { }).grammars; + # Highlighter groups to add to the `highlighterGroups`. Maps from group names to face names. + highlighterGroups = { + attribute = "@attribute"; + comment = "@comment"; + conceal = "%opt{mauve}+i"; + constant = "%opt{peach}"; + constant_builtin_boolean = "%opt{sky}"; + constant_character = "%opt{yellow}"; + constant_macro = "%opt{mauve}"; + constant_numeric = "%opt{peach}"; + constructor = "%opt{sapphire}"; + diff_plus = "%opt{green}"; + diff_minus = "%opt{red}"; + diff_delta = "%opt{blue}"; + diff_delta_moved = "%opt{mauve}"; + error = "%opt{red}+b"; + function = "@function"; + function_builtin = "@builtin"; + function_macro = "+i@ts_function"; + hint = "%opt{blue}+b"; + info = "%opt{green}+b"; + keyword = "keyword"; + keyword_conditional = "+i@ts_keyword"; + keyword_control_conditional = "+i@ts_keyword"; + keyword_control_directive = "+i@ts_keyword"; + keyword_control_import = "+i@ts_keyword"; + keyword_directive = "+i@ts_keyword"; + label = "%opt{sapphire}+i"; + markup_bold = "%opt{peach}+b"; + markup_heading = "%opt{red}"; + markup_heading_1 = "%opt{red}"; + markup_heading_2 = "%opt{mauve}"; + markup_heading_3 = "%opt{green}"; + markup_heading_4 = "%opt{yellow}"; + markup_heading_5 = "%opt{pink}"; + markup_heading_6 = "%opt{teal}"; + markup_heading_marker = "%opt{peach}+b"; + markup_italic = "%opt{pink}+i"; + markup_list_checked = "%opt{green}"; + markup_list_numbered = "%opt{blue}+i"; + markup_list_unchecked = "%opt{teal}"; + markup_list_unnumbered = "%opt{mauve}"; + markup_link_label = "%opt{blue}"; + markup_link_url = "%opt{teal}+u"; + markup_link_uri = "%opt{teal}+u"; + markup_link_text = "%opt{blue}"; + markup_quote = "%opt{crust}"; + markup_raw = "%opt{sky}"; + markup_raw_block = "%opt{sky}"; + markup_raw_inline = "%opt{green}"; + markup_strikethrough = "%opt{crust}+s"; + namespace = "@module"; + operator = "@operator"; + property = "%opt{sky}"; + punctuation = "%opt{overlay2}"; + punctuation_special = "%opt{sky}"; + special = "%opt{blue}"; + spell = "%opt{mauve}"; + string = "%opt{green}"; + string_regex = "%opt{peach}"; + string_regexp = "%opt{peach}"; + string_escape = "%opt{mauve}"; + string_special = "%opt{blue}"; + string_special_path = "%opt{green}"; + string_special_symbol = "%opt{mauve}"; + string_symbol = "%opt{red}"; + tag = "%opt{teal}"; + tag_error = "%opt{red}"; + text_title = "%opt{mauve}"; + type = "@type"; + type_enum_variant = "+i@ts_type"; + variable = "@variable"; + variable_builtin = "@builtin"; + variable_other_member = "%opt{teal}"; + variable_parameter = "+i@variable"; + warning = "%opt{peach}+b"; + }; + + # Highlighter groups to be aliased by other groups + aliases = { + comment_block = "comment"; + comment_line = "comment"; + constant_character_escape = "constant_character"; + constant_numeric_float = "constant_numeric"; + constant_numeric_integer = "constant_numeric"; + function_method = "function"; + function_special = "function"; + keyword_control = "keyword"; + keyword_control_repeat = "keyword"; + keyword_control_return = "keyword"; + keyword_control_except = "keyword"; + keyword_control_exception = "keyword"; + keyword_function = "keyword"; + keyword_operator = "keyword"; + keyword_special = "keyword"; + keyword_storage = "keyword"; + keyword_storage_modifier = "keyword"; + keyword_storage_modifier_mut = "keyword"; + keyword_storage_modifier_ref = "keyword"; + keyword_storage_type = "keyword"; + punctuation_bracket = "punctuation"; + punctuation_delimiter = "punctuation"; + text = "string"; + type_builtin = "type"; + + # Scala stuff + method = "function"; + module = "namespace"; + function_call = "function"; + method_call = "method"; + + boolean = "constant_builtin_boolean"; + number = "constant_numeric"; + float = "constant_numeric_float"; + + type_qualifier = "keyword_special"; + storageclass = "keyword_storage_modifier"; + conditional = "keyword_conditional"; + include = "keyword_control_import"; + }; + + configDir = + let + toScm = name: lib.concatStringsSep "." (lib.splitString "_" name); + + toml = formats.toml { }; + file = + toml.generate "config.toml" { + highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); + features = { + highlighting = true; + text_objects = true; + }; + language = grammars; + }; + in + runCommandLocal "kak-tree-sitter-config" { } '' + mkdir -p $out/kak-tree-sitter + ln -s ${file} $out/kak-tree-sitter/config.toml + ''; + + extraFaces = + let + toTs = name: "ts_${lib.concatStringsSep "_" (lib.splitString "." name)}"; + + definedFaces = lib.mapAttrs' (name: value: { inherit value; name = toTs name; }) highlighterGroups; + aliasFaces = lib.mapAttrs' (name: value: { name = toTs name; value = "@${toTs value}"; }) aliases; + faces = lib.recursiveUpdate definedFaces aliasFaces; + in + faces; +in +{ + rc = '' + # Enable kak-tree-sitter + eval %sh{env XDG_CONFIG_DIR=${configDir} ${lib.getExe' kak-tree-sitter "kak-tree-sitter"} --kakoune -d --server --init $kak_session} + map global normal ": enter-user-mode tree-sitter" + ''; + + plugin = utils.mkFacesScript "kak-tree-sitter" extraFaces; +} + diff --git a/packages/common/nki-kakoune/tree-sitter/grammars.nix b/packages/common/nki-kakoune/tree-sitter/grammars.nix new file mode 100644 index 0000000..426edb3 --- /dev/null +++ b/packages/common/nki-kakoune/tree-sitter/grammars.nix @@ -0,0 +1,119 @@ +{ lib, stdenv, fetchFromGitHub, runCommandLocal, ... }: +let + mkGrammarPackage = + { name + , src + , grammarPath ? "src" + , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] + , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] + , ... + }: stdenv.mkDerivation { + inherit src; + name = "kak-tree-sitter-grammar-${name}"; + version = "latest"; + buildPhase = '' + mkdir ${grammarPath}/build + cd ${grammarPath}/build + $CC ${lib.concatStringsSep " " grammarCompileArgs} + $CC ${lib.concatStringsSep " " grammarLinkArgs} -o ${name}.so + ''; + installPhase = '' + mkdir $out + cp ${name}.so $out + ''; + }; + mkGrammar = + args @ { name + , src + , grammarPath ? "src" + , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] + , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] + , querySrc ? src + , queryPath ? "runtime/queries/${name}" + , + }: { + grammar.source.local.path = "${mkGrammarPackage args}"; + queries.source.local.path = querySrc; + queries.path = queryPath; + }; + + tree-sitter-go = fetchFromGitHub { + owner = "tree-sitter"; + repo = "tree-sitter-go"; + rev = "v0.20.0"; + hash = "sha256-G7d8CHCyKDAb9j6ijRfHk/HlgPqSI+uvkuRIRRvjkHI="; + }; +in +{ + grammars = builtins.mapAttrs (name: value: mkGrammar ({ inherit name; } // value)) { + scala = { + src = fetchFromGitHub { + owner = "tree-sitter"; + repo = "tree-sitter-scala"; + rev = "70afdd5632d57dd63a960972ab25945e353a52f6"; + hash = "sha256-bi0Lqo/Zs2Uaz1efuKAARpEDg5Hm59oUe7eSXgL1Wow="; + }; + queryPath = "queries/scala"; + }; + haskell = { + src = fetchFromGitHub { + owner = "tree-sitter"; + repo = "tree-sitter-haskell"; + rev = "ba0bfb0e5d8e9e31c160d287878c6f26add3ec08"; + hash = "sha256-ZSOF0CLOn82GwU3xgvFefmh/AD2j5zz8I0t5YPwfan0="; + }; + grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "../unicode.h" "-I" ".." ]; + queryPath = "queries"; + }; + yaml = { + src = fetchFromGitHub { + owner = "ikatyang"; + repo = "tree-sitter-yaml"; + rev = "0e36bed171768908f331ff7dff9d956bae016efb"; + hash = "sha256-bpiT3FraOZhJaoiFWAoVJX1O+plnIi8aXOW2LwyU23M="; + }; + grammarCompileArgs = [ "-c" "-fpic" "../scanner.cc" "../parser.c" "-I" ".." ]; + grammarLinkArgs = [ "-lstdc++" "-shared" "-fpic" "scanner.o" "parser.o" ]; + querySrc = fetchFromGitHub { + owner = "helix-editor"; + repo = "helix"; + rev = "dbd248fdfa680373d94fbc10094a160aafa0f7a7"; + hash = "sha256-wk8qVUDFXhAOi1Ibc6iBMzDCXb6t+YiWZcTd0IJybqc="; + }; + }; + templ = rec { + src = fetchFromGitHub { + owner = "vrischmann"; + repo = "tree-sitter-templ"; + rev = "044ad200092170727650fa6d368df66a8da98f9d"; + hash = "sha256-hJuB3h5pp+LLfP0/7bAYH0uLVo+OQk5jpzJb3J9BNkY="; + }; + querySrc = runCommandLocal "templ-tree-sitter-queries" { } '' + mkdir -p $out/queries + # copy most stuff from tree-sitter-templ + install -m644 ${src}/queries/templ/* $out/queries + # override inherited files + cat ${tree-sitter-go}/queries/highlights.scm ${src}/queries/templ/highlights.scm > $out/queries/highlights.scm + ''; + queryPath = "queries"; + }; + go = { + src = tree-sitter-go; + grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; + grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; + queryPath = "queries"; + }; + hylo = { + src = fetchFromGitHub { + owner = "natsukagami"; + repo = "tree-sitter-hylo"; + rev = "494cbdff0d13cbc67348316af2efa0286dbddf6f"; + hash = "sha256-R5UeoglCTl0do3VDJ/liCTeqbxU9slvmVKNRA/el2VY="; + }; + grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; + grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; + queryPath = "queries"; + }; + }; +} + diff --git a/packages/common/nki-kakoune/utils.nix b/packages/common/nki-kakoune/utils.nix index 47e7c75..4183aa6 100644 --- a/packages/common/nki-kakoune/utils.nix +++ b/packages/common/nki-kakoune/utils.nix @@ -1,5 +1,7 @@ -{ lib, writeFile, ... }: { - mkFacesScript = name: faces: writeFile "${name}-faces.kak" ( - lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") faces)) - ); +{ lib, writeTextDir, ... }: { + mkFacesScript = name: faces: writeTextDir "share/kak/autoload/${name}/faces.kak" '' + hook global KakBegin .* { + ${lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: " face global ${name} \"${face}\"") faces))} + } + ''; } -- 2.47.2 From eb3d53b829efb2937d6f386f64f6d2359513b78b Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 21:11:48 +0200 Subject: [PATCH 06/41] Make tree-sitter kinda work --- home/common.nix | 2 +- overlay.nix | 2 +- .../default.nix} | 1 + .../common/kak-tree-sitter/user_config.patch | 129 ++++++++++++++++++ packages/common/nki-kakoune/default.nix | 4 +- packages/common/nki-kakoune/faces.nix | 31 +++++ packages/common/nki-kakoune/lsp.nix | 14 +- .../nki-kakoune/tree-sitter/default.nix | 28 ++-- .../nki-kakoune/tree-sitter/grammars.nix | 1 + packages/common/nki-kakoune/utils.nix | 2 +- 10 files changed, 187 insertions(+), 27 deletions(-) rename packages/common/{kak-tree-sitter.nix => kak-tree-sitter/default.nix} (98%) create mode 100644 packages/common/kak-tree-sitter/user_config.patch create mode 100644 packages/common/nki-kakoune/faces.nix diff --git a/home/common.nix b/home/common.nix index 3007565..ef73608 100644 --- a/home/common.nix +++ b/home/common.nix @@ -2,7 +2,7 @@ { imports = [ - ./kakoune/kak.nix + # ./kakoune/kak.nix ./fish/fish.nix ./modules/programs/my-broot.nix ./modules/programs/my-sway diff --git a/overlay.nix b/overlay.nix index e38f3a1..29a8c34 100644 --- a/overlay.nix +++ b/overlay.nix @@ -90,7 +90,7 @@ let }; overlay-packages = final: prev: { - kak-tree-sitter = final.callPackage ./packages/common/kak-tree-sitter.nix { rustPlatform = final.unstable.rustPlatform; }; + kak-tree-sitter = final.callPackage ./packages/common/kak-tree-sitter { rustPlatform = final.unstable.rustPlatform; }; kak-lsp = let diff --git a/packages/common/kak-tree-sitter.nix b/packages/common/kak-tree-sitter/default.nix similarity index 98% rename from packages/common/kak-tree-sitter.nix rename to packages/common/kak-tree-sitter/default.nix index 9819e3a..69da116 100644 --- a/packages/common/kak-tree-sitter.nix +++ b/packages/common/kak-tree-sitter/default.nix @@ -34,6 +34,7 @@ let self.runtime_dir.join("sources").join(url_dir) '') + ./user_config.patch ]; meta.mainProgram = "kak-tree-sitter"; diff --git a/packages/common/kak-tree-sitter/user_config.patch b/packages/common/kak-tree-sitter/user_config.patch new file mode 100644 index 0000000..b2b1b6a --- /dev/null +++ b/packages/common/kak-tree-sitter/user_config.patch @@ -0,0 +1,129 @@ +diff --git a/kak-tree-sitter-config/src/lib.rs b/kak-tree-sitter-config/src/lib.rs +index e4edc42..a9c92cb 100644 +--- a/kak-tree-sitter-config/src/lib.rs ++++ b/kak-tree-sitter-config/src/lib.rs +@@ -52,9 +52,13 @@ impl Config { + } + + /// Load the default configuration, the user configuration, and merge both. +- pub fn load_default_user() -> Result { ++ pub fn load_default_user(path: Option>) -> Result { + let mut config = Self::load_default_config()?; +- match UserConfig::load_from_xdg() { ++ let user_config = match path { ++ Some(p) => UserConfig::load(p), ++ None => UserConfig::load_from_xdg(), ++ }; ++ match user_config { + Ok(user_config) => { + config.merge_user_config(user_config)?; + } +@@ -448,7 +452,7 @@ impl UserConfig { + } + + /// Load the configuration from a given path. +- fn load(path: impl AsRef) -> Result { ++ pub fn load(path: impl AsRef) -> Result { + let path = path.as_ref(); + + log::debug!("loading configuration at {path}", path = path.display()); +diff --git a/kak-tree-sitter/src/cli.rs b/kak-tree-sitter/src/cli.rs +index b8102cd..923312c 100644 +--- a/kak-tree-sitter/src/cli.rs ++++ b/kak-tree-sitter/src/cli.rs +@@ -22,6 +22,10 @@ pub struct Cli { + #[clap(short, long)] + pub server: bool, + ++ /// Specify a custom path for the user config. ++ #[clap(short, long)] ++ pub user_config: Option, ++ + /// Try to daemonize, if not already done. + #[clap(short, long)] + pub daemonize: bool, +diff --git a/kak-tree-sitter/src/main.rs b/kak-tree-sitter/src/main.rs +index bee9698..cbd7b39 100644 +--- a/kak-tree-sitter/src/main.rs ++++ b/kak-tree-sitter/src/main.rs +@@ -43,7 +43,7 @@ fn start() -> Result<(), OhNo> { + } + } + +- let config = Config::load_default_user()?; ++ let config = Config::load_default_user(cli.user_config.as_ref())?; + + // inject rc if we start from Kakoune + if cli.kakoune && cli.init.is_some() { +diff --git a/kak-tree-sitter/src/server.rs b/kak-tree-sitter/src/server.rs +index f3b7723..000c81d 100644 +--- a/kak-tree-sitter/src/server.rs ++++ b/kak-tree-sitter/src/server.rs +@@ -73,6 +73,7 @@ impl Server { + log::debug!("creating IO handler"); + let io_handler = IOHandler::new( + config, ++ cli.user_config.clone(), + cli.is_standalone(), + cli.with_highlighting || config.features.highlighting, + resources, +@@ -165,6 +166,7 @@ struct IOHandler { + connections: HashMap, + enqueue_response: EnqueueResponse, + handler: Handler, ++ user_config_path: Option, + } + + impl IOHandler { +@@ -173,6 +175,7 @@ impl IOHandler { + + fn new( + config: &Config, ++ user_config_path: Option, + is_standalone: bool, + with_highlighting: bool, + resources: ServerResources, +@@ -203,6 +206,7 @@ impl IOHandler { + connections, + enqueue_response, + handler, ++ user_config_path, + }) + } + +@@ -450,7 +454,7 @@ impl IOHandler { + } + + fn reload(&mut self) { +- let config = match Config::load_default_user() { ++ let config = match Config::load_default_user(self.user_config_path.as_ref()) { + Ok(config) => config, + Err(err) => { + log::error!("reloading config failed: {err}"); +diff --git a/ktsctl/src/cli.rs b/ktsctl/src/cli.rs +index dfac5c3..09f86f3 100644 +--- a/ktsctl/src/cli.rs ++++ b/ktsctl/src/cli.rs +@@ -11,6 +11,9 @@ pub struct Cli { + #[clap(long)] + pub verbose: bool, + ++ #[clap(short, long)] ++ pub user_config: Option, ++ + #[clap(subcommand)] + pub cmd: Cmd, + } +diff --git a/ktsctl/src/main.rs b/ktsctl/src/main.rs +index f9a3499..f823633 100644 +--- a/ktsctl/src/main.rs ++++ b/ktsctl/src/main.rs +@@ -37,7 +37,7 @@ fn start() -> Result<(), HellNo> { + simple_logger::init_with_level(log::Level::Debug)?; + } + +- let config = Config::load_default_user()?; ++ let config = Config::load_default_user(cli.user_config.as_ref())?; + log::debug!("ktsctl configuration:\n{config:#?}"); + + match cli.cmd { diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 0d48b06..4cb34c7 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -11,6 +11,7 @@ in ++ callPackage ./themes.nix { } ++ [ (callPackage ./kaktex { }) + (callPackage ./faces.nix { }) rc tree-sitter.plugin lsp.plugin @@ -23,6 +24,7 @@ in rm "$out/bin/kak" makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \ --set KAKOUNE_RUNTIME "$out/share/kak" \ - --suffix PATH ":" "${lsp.extraPaths}" + --suffix PATH ":" "${lsp.extraPaths}" \ + --suffix PATH ":" "${tree-sitter.extraPaths}" ''; }) diff --git a/packages/common/nki-kakoune/faces.nix b/packages/common/nki-kakoune/faces.nix new file mode 100644 index 0000000..367472c --- /dev/null +++ b/packages/common/nki-kakoune/faces.nix @@ -0,0 +1,31 @@ +{ callPackage, ... } : +let +utils = callPackage ./utils.nix { }; +faces = { + Default = "%opt{text},%opt{base}"; + BufferPadding = "%opt{base},%opt{base}"; + MenuForeground = "%opt{blue},white+bF"; + MenuBackground = "%opt{sky},white+F"; + Information = "%opt{sky},white"; + # Markdown help color scheme + InfoDefault = "Information"; + InfoBlock = "@block"; + InfoBlockQuote = "+i@block"; + InfoBullet = "@bullet"; + InfoHeader = "@header"; + InfoLink = "@link"; + InfoLinkMono = "+b@mono"; + InfoMono = "@mono"; + InfoRule = "+b@Information"; + InfoDiagnosticError = "@DiagnosticError"; + InfoDiagnosticHint = "@DiagnosticHint"; + InfoDiagnosticInformation = "@Information"; + InfoDiagnosticWarning = "@DiagnosticWarning"; + # Extra faces + macro = "+u@function"; + method = "@function"; + format_specifier = "+i@string"; + mutable_variable = "+i@variable"; + class = "+b@variable"; +}; +in utils.mkFacesScript "default-faces" faces diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix index 3712d6f..6511ee9 100644 --- a/packages/common/nki-kakoune/lsp.nix +++ b/packages/common/nki-kakoune/lsp.nix @@ -248,7 +248,7 @@ let kak-lsp-config = let toml = formats.toml { }; - toLspConfig = attrs: builtins.removeAttrs attrs [ "package" ]; + toLspConfig = builtins.mapAttrs (_: attrs: builtins.removeAttrs attrs [ "package" ]); in toml.generate "kak-lsp.toml" ({ semantic_tokens.faces = config.faces; @@ -265,16 +265,16 @@ in plugin = writeTextDir "share/kak/autoload/kak-lsp.kak" '' hook global KakBegin .* %{ try %{ - eval %sh{${lib.getExe kak-lsp} --config ${kak-lsp-config} -s $kak_session} + eval %sh{${lib.getExe kak-lsp} --kakoune --config ${kak-lsp-config} -s $kak_session} } lsp-enable - 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" + map global lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" + map global normal ": enter-user-mode lsp" + map global normal ": lsp-hover" + map global normal ": lsp-hover-buffer" # lsp-auto-hover-insert-mode-enable - set window lsp_hover_anchor true + set global 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' diff --git a/packages/common/nki-kakoune/tree-sitter/default.nix b/packages/common/nki-kakoune/tree-sitter/default.nix index ce16343..b94a771 100644 --- a/packages/common/nki-kakoune/tree-sitter/default.nix +++ b/packages/common/nki-kakoune/tree-sitter/default.nix @@ -129,25 +129,19 @@ let include = "keyword_control_import"; }; - configDir = + configFile = let toScm = name: lib.concatStringsSep "." (lib.splitString "_" name); - toml = formats.toml { }; - file = - toml.generate "config.toml" { - highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); - features = { - highlighting = true; - text_objects = true; - }; - language = grammars; - }; in - runCommandLocal "kak-tree-sitter-config" { } '' - mkdir -p $out/kak-tree-sitter - ln -s ${file} $out/kak-tree-sitter/config.toml - ''; + toml.generate "config.toml" { + highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); + features = { + highlighting = true; + text_objects = true; + }; + language = grammars; + }; extraFaces = let @@ -162,10 +156,12 @@ in { rc = '' # Enable kak-tree-sitter - eval %sh{env XDG_CONFIG_DIR=${configDir} ${lib.getExe' kak-tree-sitter "kak-tree-sitter"} --kakoune -d --server --init $kak_session} + eval %sh{kak-tree-sitter --kakoune -d --server --init $kak_session --user-config ${configFile}} map global normal ": enter-user-mode tree-sitter" ''; + extraPaths = "${kak-tree-sitter}/bin"; + plugin = utils.mkFacesScript "kak-tree-sitter" extraFaces; } diff --git a/packages/common/nki-kakoune/tree-sitter/grammars.nix b/packages/common/nki-kakoune/tree-sitter/grammars.nix index 426edb3..d1f6417 100644 --- a/packages/common/nki-kakoune/tree-sitter/grammars.nix +++ b/packages/common/nki-kakoune/tree-sitter/grammars.nix @@ -33,6 +33,7 @@ let , }: { grammar.source.local.path = "${mkGrammarPackage args}"; + grammar.link_args = grammarLinkArgs ++ [ "-o" "${name}.so" ]; queries.source.local.path = querySrc; queries.path = queryPath; }; diff --git a/packages/common/nki-kakoune/utils.nix b/packages/common/nki-kakoune/utils.nix index 4183aa6..0307bc6 100644 --- a/packages/common/nki-kakoune/utils.nix +++ b/packages/common/nki-kakoune/utils.nix @@ -1,6 +1,6 @@ { lib, writeTextDir, ... }: { mkFacesScript = name: faces: writeTextDir "share/kak/autoload/${name}/faces.kak" '' - hook global KakBegin .* { + hook global KakBegin .* %{ ${lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: " face global ${name} \"${face}\"") faces))} } ''; -- 2.47.2 From 8608362922eae578afd14d148cc5e1bf8d1f8422 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 22:25:59 +0200 Subject: [PATCH 07/41] Cleanup the home kakoune module, restore tree-sitter --- home/common.nix | 3 +- home/kakoune/kak.nix | 375 +----------------- home/modules/programs/my-kakoune/default.nix | 94 +---- home/modules/programs/my-kakoune/kak-lsp.nix | 213 ---------- .../programs/my-kakoune/tree-sitter.nix | 59 +-- packages/common/nki-kakoune/default.nix | 8 +- packages/common/nki-kakoune/kakrc | 1 + packages/common/nki-kakoune/lsp.nix | 2 +- 8 files changed, 59 insertions(+), 696 deletions(-) delete mode 100644 home/modules/programs/my-kakoune/kak-lsp.nix diff --git a/home/common.nix b/home/common.nix index ef73608..2034fce 100644 --- a/home/common.nix +++ b/home/common.nix @@ -2,7 +2,7 @@ { imports = [ - # ./kakoune/kak.nix + ./kakoune/kak.nix ./fish/fish.nix ./modules/programs/my-broot.nix ./modules/programs/my-sway @@ -42,7 +42,6 @@ unzip zstd atool - nki-kakoune ]; home.sessionVariables = { diff --git a/home/kakoune/kak.nix b/home/kakoune/kak.nix index aad934c..9a132ac 100644 --- a/home/kakoune/kak.nix +++ b/home/kakoune/kak.nix @@ -1,67 +1,9 @@ { pkgs, lib, ... }: - let - kak-lsp-frontend = { pkgs, lib, ... }: - let - langserver = name: { - name = "vscode-${name}-language-server"; - value = { - args = [ "--stdio" ]; - command = "vscode-${name}-language-server"; - filetypes = [ name ]; - roots = [ "package.json" ".git" ]; - }; - package = pkgs.nodePackages.vscode-langservers-extracted; - }; - - tailwind = { - command = "tailwindcss-language-server"; - args = [ "--stdio" ]; - filetypes = [ "html" "css" "javascript" "typescript" "templ" ]; - roots = [ "tailwind.config.{js,cjs,mjs,ts}" "package.json" ".git" ]; - settings_section = "tailwindCSS"; - settings.tailwindCSS = { - validate = "warning"; - userLanguages.templ = "html"; - }; - package = pkgs.tailwindcss-language-server; - }; - - templModule = { pkgs, lib, ... }: { - programs.kak-lsp.languageServers."vscode-html-language-server".filetypes = [ "templ" ]; - programs.kak-lsp.languageServers."tailwindcss-language-server".filetypes = [ "templ" ]; - programs.kak-lsp.languageServers.templ = { - command = "templ"; - args = [ "lsp" ]; - filetypes = [ "templ" ]; - roots = [ "go.mod" ".git" ]; - package = pkgs.unstable.templ; - }; - - }; - - in - { - imports = [ templModule ]; - - programs.kak-lsp.languageServers = (builtins.listToAttrs (map langserver [ "html" "css" "json" ])) // { - tailwindcss-language-server = tailwind; - }; - }; - - ltexLsp = { pkgs, lib, ... }: { - programs.kak-lsp.languageServers.ltex-ls = { - command = "ltex-ls"; - args = [ "--log-file=/tmp" ]; - filetypes = [ "latex" "typst" ]; - roots = [ "main.tex" "main.typ" ".git" ]; - package = pkgs.ltex-ls; - }; - }; in { - imports = [ ../modules/programs/my-kakoune ./kaktex.nix kak-lsp-frontend ltexLsp ]; + imports = [ ../modules/programs/my-kakoune ./kaktex.nix ]; home.packages = with pkgs; [ # ctags for peneira @@ -75,110 +17,6 @@ in # Enable the kakoune package. programs.my-kakoune.enable = true; programs.my-kakoune.enable-fish-session = true; - programs.kak-lsp.enable = true; - programs.kak-lsp.semanticTokens.additionalFaces = [ - # Typst - { face = "header"; token = "heading"; } - { face = "ts_markup_link_url"; token = "link"; } - { face = "ts_markup_link_uri"; token = "ref"; } - { face = "ts_markup_link_label"; token = "label"; } - { face = "ts_property"; token = "pol"; } - { face = "ts_markup_list_checked"; token = "marker"; } - { face = "ts_constant_builtin_boolean"; token = "bool"; } - { face = "ts_keyword_control"; token = "delim"; } - { face = "ts_number"; token = "text"; modifiers = [ "math" ]; } - { face = "ts_markup_bold"; token = "text"; modifiers = [ "strong" ]; } - { face = "ts_markup_italic"; token = "text"; modifiers = [ "emph" ]; } - ]; - - programs.kak-lsp.languageServers.elixir-ls = { - args = [ ]; - command = "elixir-ls"; - filetypes = [ "elixir" ]; - roots = [ "mix.exs" ]; - }; - programs.kak-lsp.languageServers.typescript-language-server = { - args = [ "--stdio" ]; - command = "typescript-language-server"; - filetypes = [ "typescript" "javascript" ]; - roots = [ "package.json" ]; - package = pkgs.nodePackages.typescript-language-server; - }; - programs.kak-lsp.languageServers.fsautocomplete = { - args = [ "--adaptive-lsp-server-enabled" "--project-graph-enabled" "--source-text-factory" "RoslynSourceText" ]; - command = "fsautocomplete"; - filetypes = [ "fsharp" ]; - roots = [ "*.fsproj" ]; - settings_section = "FSharp"; - settings.FSharp = { - AutomaticWorkspaceInit = true; - }; - }; - programs.kak-lsp.languageServers.metals = { - command = "metals"; - filetypes = [ "scala" ]; - roots = [ "build.sbt" "build.sc" "build.mill" ]; - settings_section = "metals"; - settings.metals = { - enableSemanticHighlighting = true; - showInferredType = true; - decorationProvider = true; - inlineDecorationProvider = true; - # From kakoune-lsp's own options - icons = "unicode"; - isHttpEnabled = true; - statusBarProvider = "log-message"; - compilerOptions = { overrideDefFormat = "unicode"; }; - }; - package = pkgs.metals; - }; - programs.kak-lsp.languageServers.texlab = { - command = "texlab"; - filetypes = [ "latex" ]; - roots = [ "main.tex" "all.tex" ".git" ]; - settings_section = "texlab"; - settings.texlab = { - build.executable = "latexmk"; - build.args = [ "-pdf" "-shell-escape" "-interaction=nonstopmode" "-synctex=1" "%f" ]; - - build.forwardSearchAfter = true; - build.onSave = true; - - forwardSearch = - (if pkgs.stdenv.isDarwin then { - executable = "/Applications/Skim.app/Contents/SharedSupport/displayline"; - args = [ "-r" "-g" "%l" "%p" "%f" ]; - } else - { - executable = "${pkgs.zathura}/bin/zathura"; - args = [ "--synctex-forward" "%l:1:%f" "%p" "-x" "${./kaktex} jump %%{input} %%{line} %%{column}" ]; - }); - }; - package = pkgs.texlab; - }; - programs.kak-lsp.languageServers.typst-lsp = { - command = "typst-lsp"; - filetypes = [ "typst" ]; - roots = [ "main.typ" ".git" ]; - settings_section = "typst-lsp"; - settings.typst-lsp = { - experimentalFormatterMode = "on"; - }; - }; - programs.kak-lsp.languageServers.marksman = { - command = "marksman"; - filetypes = [ "markdown" ]; - roots = [ ".marksman.toml" ".git" ]; - package = pkgs.marksman; - }; - programs.kak-lsp.languageServers.rust-analyzer = { - args = [ ]; - command = "rust-analyzer"; - filetypes = [ "rust" ]; - roots = [ "Cargo.toml" ]; - package = pkgs.rust-analyzer; - }; - programs.my-kakoune.tree-sitter.extraAliases = { # Scala stuff method = "function"; @@ -300,216 +138,5 @@ in queries.path = "queries"; }; }; - - programs.my-kakoune.package = pkgs.kakoune; - programs.my-kakoune.rc = - builtins.readFile ./kakrc + '' - - # Source any settings in the current working directory, - # recursive upwards - evaluate-commands %sh{ - ${pkgs.writeScript "source-pwd" (builtins.readFile ./source-pwd)} - } - ''; - - programs.my-kakoune.extraFaces = { - Default = "%opt{text},%opt{base}"; - BufferPadding = "%opt{base},%opt{base}"; - MenuForeground = "%opt{blue},white+bF"; - MenuBackground = "%opt{sky},white+F"; - Information = "%opt{sky},white"; - # Markdown help color scheme - InfoDefault = "Information"; - InfoBlock = "@block"; - InfoBlockQuote = "+i@block"; - InfoBullet = "@bullet"; - InfoHeader = "@header"; - InfoLink = "@link"; - InfoLinkMono = "+b@mono"; - InfoMono = "@mono"; - InfoRule = "+b@Information"; - InfoDiagnosticError = "@DiagnosticError"; - InfoDiagnosticHint = "@DiagnosticHint"; - InfoDiagnosticInformation = "@Information"; - InfoDiagnosticWarning = "@DiagnosticWarning"; - # Extra faces - macro = "+u@function"; - method = "@function"; - format_specifier = "+i@string"; - mutable_variable = "+i@variable"; - class = "+b@variable"; - }; - programs.my-kakoune.autoload = [ - # My own scripts - { - name = "latex.kak"; - src = ./autoload/latex.kak; - } - { - name = "markdown.kak"; - src = ./autoload/markdown.kak; - } - - # Plugins - { - name = "luar"; - src = pkgs.fetchFromGitHub { - owner = "gustavo-hms"; - repo = "luar"; - rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; - sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; - }; - activationScript = '' - # Enable luar - require-module luar - # Use luajit - set-option global luar_interpreter ${pkgs.luajit}/bin/luajit - ''; - } - { - name = "peneira"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "peneira"; - rev = "743b9971472853a752475e7c070ce99089c6840c"; - sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; - }; - activationScript = '' - require-module peneira - - # Change selection color - set-face global PeneiraSelected @PrimarySelection - - # Buffers list - define-command -hidden peneira-buffers %{ - peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ - buffer %arg{1} - } - } - - # Grep in the current location - define-command peneira-grep %{ - peneira 'line: ' "rg -n ." %{ - lua %arg{1} %{ - local file, line = arg[1]:match("([^:]+):(%d+):") - kak.edit(file, line) - } - } - } - - # A peneira menu - declare-user-mode fuzzy-match-menu - - map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" - map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" - map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" - map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" - map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" - map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" - - # Bind menu to user mode - map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" - ''; - } - { - name = "kakoune-focus"; - src = pkgs.fetchFromGitHub { - owner = "caksoylar"; - repo = "kakoune-focus"; - rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; - sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; - }; - activationScript = '' - map global user ': focus-toggle' -docstring "toggle selections focus" - ''; - } - { - name = "kakoune-inc-dec"; - src = pkgs.fetchFromGitLab { - owner = "Screwtapello"; - repo = "kakoune-inc-dec"; - rev = "7bfe9c51"; - sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; - }; - } - { - name = "racket.kak"; - src = (builtins.fetchTree { - type = "git"; - url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; - rev = "e397042009b46916ff089d79166ec0e8ca813a18"; - narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; - }) + "/rc"; - } - # { - # name = "kakoune-discord"; - # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; - # } - rec { - name = "kakoune-mirror"; - src = pkgs.fetchFromGitHub - { - owner = "Delapouite"; - repo = "kakoune-mirror"; - rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; - sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; - } + "/mirror.kak"; - wrapAsModule = true; - activationScript = '' - require-module ${name} - - # Bind to ${name} - map global normal ': enter-user-mode -lock mirror' - ''; - } - { - name = "unicode-math"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "kakoune-unicode-math"; - rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; - # sha256 = lib.fakeSha256; - sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; - fetchSubmodules = true; - }; - activationScript = '' - require-module unicode-math - - # Bind to the menu - map global insert ': insert-unicode ' - ''; - } - { - name = "kakoune-buffers"; - src = pkgs.fetchFromGitHub { - owner = "Delapouite"; - repo = "kakoune-buffers"; - rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; - sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; - }; - activationScript = '' - # Suggested hook - - hook global WinDisplay .* info-buffers - - # Suggested mappings - - map global user b ':enter-buffers-mode' -docstring 'buffers…' - map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' - map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' - - # Suggested aliases - - alias global bd delete-buffer - alias global bf buffer-first - alias global bl buffer-last - alias global bo buffer-only - alias global bo! buffer-only-force - ''; - } - ]; - programs.my-kakoune.themes = { - catppuccin-latte = ./catppuccin-latte.kak; - }; } diff --git a/home/modules/programs/my-kakoune/default.nix b/home/modules/programs/my-kakoune/default.nix index 125484a..62a9cb1 100644 --- a/home/modules/programs/my-kakoune/default.nix +++ b/home/modules/programs/my-kakoune/default.nix @@ -1,40 +1,17 @@ -{ config, pkgs, lib, ... }: +{ config, options, pkgs, lib, ... }: with lib; let cfg = config.programs.my-kakoune; - - autoloadModule = types.submodule { - options = { - name = mkOption { - type = types.str; - description = "Name of the autoload script/folder. It might affect kakoune's load order."; - }; - src = mkOption { - type = types.path; - description = "Path to the autoload script/folder."; - }; - wrapAsModule = mkOption { - type = types.bool; - default = false; - description = "Wrap the given source file in a `provide-module` command. Fails if the `src` is not a single file."; - }; - activationScript = mkOption { - type = types.nullOr types.lines; - default = null; - description = "Add an activation script to the module. It will be wrapped in a `hook global KakBegin .*` wrapper."; - }; - }; - }; in { - imports = [ ./kak-lsp.nix ./fish-session.nix ./tree-sitter.nix ]; + imports = [ ./fish-session.nix ./tree-sitter.nix ]; options.programs.my-kakoune = { enable = mkEnableOption "My version of the kakoune configuration"; package = mkOption { type = types.package; - default = pkgs.kakoune; + default = pkgs.nki-kakoune; description = "The kakoune package to be installed"; }; rc = mkOption { @@ -42,22 +19,16 @@ in default = ""; description = "Content of the kakrc file. A line-concatenated string"; }; - autoload = mkOption { - type = types.listOf autoloadModule; - default = [ ]; - description = "Sources to autoload"; - }; - themes = mkOption { - type = types.attrsOf types.path; - default = { }; - description = "Themes to load"; - }; - extraFaces = mkOption { type = types.attrsOf types.str; default = { }; description = "Extra faces to include"; }; + autoloadFile = mkOption { + type = options.xdg.configFile.type; + default = { }; + description = "Extra autoload files"; + }; }; config = mkIf cfg.enable { @@ -65,37 +36,6 @@ in xdg.configFile = let - kakouneAutoload = { name, src, wrapAsModule ? false, activationScript ? null }: - [ - (if !wrapAsModule then { - name = "kak/autoload/${name}"; - value.source = src; - } else { - name = "kak/autoload/${name}/module.kak"; - value.text = '' - provide-module ${name} %◍ - ${readFile src} - ◍ - ''; - }) - ] ++ (if activationScript == null then [ ] else [{ - name = "kak/autoload/on-load/${name}.kak"; - value.text = '' - hook global KakBegin .* %{ - ${activationScript} - } - ''; - }]); - - kakouneThemes = builtins.listToAttrs (builtins.attrValues ( - builtins.mapAttrs - (name: src: { - name = "kak/colors/${name}.kak"; - value.source = src; - }) - cfg.themes - )); - kakouneFaces = let txt = strings.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") cfg.extraFaces)); @@ -103,6 +43,7 @@ in pkgs.writeText "faces.kak" txt; in { + "kak/autoload/builtin".source = "${cfg.package}/share/kak/autoload"; # kakrc "kak/kakrc".text = '' ${cfg.rc} @@ -110,15 +51,14 @@ in # Load faces source ${kakouneFaces} ''; - } // - (builtins.listToAttrs (lib.lists.flatten (map kakouneAutoload ([ - # include the original autoload files - { - name = "rc"; - src = "${cfg.package}/share/kak/autoload/rc"; - } - ] ++ cfg.autoload)))) - // kakouneThemes; + } // lib.mapAttrs' + (name: attrs: { + name = "kak/autoload/${name}"; + value = attrs // { + target = "kak/autoload/${name}"; + }; + }) + cfg.autoloadFile; }; } diff --git a/home/modules/programs/my-kakoune/kak-lsp.nix b/home/modules/programs/my-kakoune/kak-lsp.nix deleted file mode 100644 index eaf3b6b..0000000 --- a/home/modules/programs/my-kakoune/kak-lsp.nix +++ /dev/null @@ -1,213 +0,0 @@ -{ config, pkgs, lib, ... }: - -with lib; -let - lspConfig = - { - language_ids = { - c = "c_cpp"; - cpp = "c_cpp"; - javascript = "javascriptreact"; - typescript = "typescriptreact"; - protobuf = "proto"; - sh = "shellscript"; - }; - - language_servers = { - ccls = { - args = [ "-v=2" "-log-file=/tmp/ccls.log" ]; - command = "ccls"; - filetypes = [ "c" "cpp" ]; - roots = [ "compile_commands.json" ".cquery" ".git" ]; - }; - gopls = { - command = "gopls"; - filetypes = [ "go" ]; - offset_encoding = "utf-8"; - roots = [ "Gopkg.toml" "go.mod" ".git" ".hg" ]; - settings = { gopls = { hoverKind = "SynopsisDocumentation"; semanticTokens = true; }; }; - settings_section = "gopls"; - }; - haskell-language-server = { - args = [ "--lsp" ]; - command = "haskell-language-server-wrapper"; - filetypes = [ "haskell" ]; - roots = [ "Setup.hs" "stack.yaml" "*.cabal" "package.yaml" ]; - settings_section = "haskell"; - }; - nil = { - command = "${pkgs.nil}/bin/nil"; - filetypes = [ "nix" ]; - roots = [ "flake.nix" "shell.nix" ".git" ]; - settings.nil = { - formatting.command = [ "${getExe pkgs.nixpkgs-fmt}" ]; - }; - }; - pyls = { - command = "pyls"; - filetypes = [ "python" ]; - offset_encoding = "utf-8"; - roots = [ "requirements.txt" "setup.py" ".git" ".hg" ]; - }; - }; - semantic_tokens.faces = [ - ## Items - # (Rust) Macros - { face = "attribute"; token = "attribute"; } - { face = "attribute"; token = "derive"; } - { face = "macro"; token = "macro"; } # Function-like Macro - # Keyword and Fixed Tokens - { face = "keyword"; token = "keyword"; } - { face = "operator"; token = "operator"; } - # Functions and Methods - { face = "function"; token = "function"; } - { face = "method"; token = "method"; } - # Constants - { face = "string"; token = "string"; } - { face = "format_specifier"; token = "formatSpecifier"; } - # Variables - { face = "variable"; token = "variable"; modifiers = [ "readonly" ]; } - { face = "mutable_variable"; token = "variable"; } - { face = "module"; token = "namespace"; } - { face = "variable"; token = "type_parameter"; } - { face = "class"; token = "enum"; } - { face = "class"; token = "struct"; } - { face = "class"; token = "trait"; } - { face = "class"; token = "union"; } - { face = "class"; token = "class"; } - - ## Comments - { face = "documentation"; token = "comment"; modifiers = [ "documentation" ]; } - { face = "comment"; token = "comment"; } - ]; - server = { timeout = 1800; }; - snippet_support = false; - verbosity = 255; - }; - - languageServerOption = types.submodule { - options = { - filetypes = mkOption { - type = types.listOf types.str; - description = "The list of filetypes to assign the language to"; - }; - roots = mkOption { - type = types.listOf types.str; - description = "The list of root filenames that are used to determine the project root"; - }; - command = mkOption { - type = types.str; - description = "The LSP server command to be called."; - }; - args = mkOption { - type = types.listOf types.str; - default = [ ]; - description = "The arguments passed onto the LSP server."; - }; - offset_encoding = mkOption { - type = types.nullOr (types.enum [ "utf-8" ]); - default = null; - description = "The offset encoding used by the LSP server."; - }; - settings_section = mkOption { - type = types.nullOr types.str; - default = null; - description = "The settings section to be sent to LSP server."; - }; - settings = mkOption { - type = types.nullOr (types.attrsOf types.anything); - default = null; - description = "Additional settings to be passed to the LSP server."; - }; - package = mkOption { - type = types.nullOr types.package; - default = null; - description = "The default package of the language server. Will be appended as the ending segments of the PATH to kak-lsp"; - }; - }; - }; - - cfg = config.programs.kak-lsp; - - serverPackages = - filter (v: v != null) - (lib.mapAttrsToList (_: serv: serv.package) cfg.languageServers); - - wrappedPackage = pkgs.symlinkJoin { - name = "kak-lsp-wrapped"; - nativeBuildInputs = [ pkgs.makeWrapper ]; - paths = [ cfg.package ]; - postBuild = '' - wrapProgram $out/bin/kak-lsp --suffix PATH ":" ${lib.makeBinPath serverPackages} - ''; - }; -in -{ - options.programs.kak-lsp = { - enable = mkEnableOption "Enable kak-lsp support"; - - package = mkOption { - type = types.package; - default = pkgs.kak-lsp; - }; - - enableSnippets = mkOption { - type = types.bool; - default = false; - description = "Enable snippet support"; - }; - - semanticTokens.faces = mkOption { - type = types.listOf types.anything; - default = lspConfig.semantic_tokens.faces; - description = "The semantic tokens faces mapping given to kak"; - }; - semanticTokens.additionalFaces = mkOption { - type = types.listOf types.anything; - default = [ ]; - description = "The semantic tokens faces mapping given to kak"; - }; - - serverTimeout = mkOption { - type = types.int; - default = 1000; - description = "Server timeout"; - }; - - languageServers = mkOption { - type = types.attrsOf languageServerOption; - default = { }; - description = "The language options"; - }; - - languageIds = mkOption { - type = types.attrsOf types.str; - default = { }; - description = "Language IDs to be sent to the LSP"; - }; - }; - - config = mkIf cfg.enable - { - home.packages = [ wrappedPackage ]; - - # Configurations - xdg.configFile."kak-lsp/kak-lsp.toml" = - let - toml = pkgs.formats.toml { }; - toLspConfig = lib.filterAttrsRecursive (n: v: n != "package" && v != null); - in - { - source = toml.generate "config.toml" - { - semantic_tokens.faces = cfg.semanticTokens.faces ++ cfg.semanticTokens.additionalFaces; - server.timeout = cfg.serverTimeout; - snippet_support = cfg.enableSnippets; - verbosity = 255; - language_server = toLspConfig (lspConfig.language_servers // cfg.languageServers); - language_ids = lspConfig.language_ids // cfg.languageIds; - }; - }; - }; -} - diff --git a/home/modules/programs/my-kakoune/tree-sitter.nix b/home/modules/programs/my-kakoune/tree-sitter.nix index 4304ca5..07f12cf 100644 --- a/home/modules/programs/my-kakoune/tree-sitter.nix +++ b/home/modules/programs/my-kakoune/tree-sitter.nix @@ -33,6 +33,27 @@ let }; }; }; + mkGrammarPackage = + { name + , src + , grammarPath ? "src" + , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] + , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] + }: pkgs.stdenv.mkDerivation { + inherit src; + name = "kak-tree-sitter-grammar-${name}.so"; + version = "latest"; + buildPhase = '' + mkdir ${grammarPath}/build + cd ${grammarPath}/build + $CC ${lib.concatStringsSep " " grammarCompileArgs} + $CC ${lib.concatStringsSep " " grammarLinkArgs} -o ${name}.so + ''; + installPhase = '' + cp ${name}.so $out + ''; + }; + in { options.programs.my-kakoune.tree-sitter = { @@ -200,24 +221,15 @@ in toml = pkgs.formats.toml { }; - srcName = src: lib.removePrefix "/nix/store/" src.outPath; - mkGitRepo = src: pkgs.runCommandLocal "${src.name}-git" { } '' - cp -r --no-preserve=all ${src} $out - cd $out - if ! test -d $out/.git; then - ${lib.getExe pkgs.git} init -b ${srcName src} - ${lib.getExe pkgs.git} config user.email "a@b.com" - ${lib.getExe pkgs.git} config user.name "a" - ${lib.getExe pkgs.git} add . - ${lib.getExe pkgs.git} commit -m "Just making a git commit" - fi - ''; - toLanguageConf = name: lang: with lang; { grammar = { - inherit (grammar) path; - source.git.url = "${mkGitRepo grammar.src}"; - source.git.pin = "${srcName grammar.src}"; + source.local.path = mkGrammarPackage { + inherit name; + src = grammar.src; + grammarPath = grammar.path; + grammarCompileArgs = grammar.compile.flags ++ grammar.compile.args; + grammarLinkArgs = grammar.link.flags ++ grammar.link.args; + }; compile = grammar.compile.command; compile_args = grammar.compile.args; compile_flags = grammar.compile.flags; @@ -225,10 +237,9 @@ in link_args = grammar.link.args ++ [ "-o" "${name}.so" ]; link_flags = grammar.link.flags; }; - queries = { - source.git.url = "${mkGitRepo queries.src}"; - source.git.pin = "${srcName queries.src}"; + queries = rec { path = if queries.path == null then "runtime/queries/${name}" else queries.path; + source.local.path = "${queries.src}/${path}"; }; }; in @@ -249,14 +260,14 @@ in features = cfg.features; language = builtins.mapAttrs toLanguageConf cfg.languages; }; - - onChange = '' - export PATH=$PATH:${lib.getBin pkgs.gcc} - ${cfg.package}/bin/ktsctl sync -a - ''; }; programs.my-kakoune.extraFaces = faces; + programs.my-kakoune.autoloadFile."kak-tree-sitter.kak".text = '' + # Enable kak-tree-sitter + eval %sh{kak-tree-sitter --kakoune -d --server --init $kak_session} + map global normal ": enter-user-mode tree-sitter" + ''; }; } diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 4cb34c7..c7d4324 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,9 +1,8 @@ { callPackage, kakoune, kakoune-unwrapped, ... }: let lsp = callPackage ./lsp.nix { }; - tree-sitter = callPackage ./tree-sitter { }; rc = (callPackage ./rc.nix { - prependRc = tree-sitter.rc; + # prependRc = tree-sitter.rc; }); in (kakoune.override { @@ -13,7 +12,7 @@ in (callPackage ./kaktex { }) (callPackage ./faces.nix { }) rc - tree-sitter.plugin + # tree-sitter.plugin lsp.plugin ]; }).overrideAttrs (attrs: { @@ -24,7 +23,6 @@ in rm "$out/bin/kak" makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \ --set KAKOUNE_RUNTIME "$out/share/kak" \ - --suffix PATH ":" "${lsp.extraPaths}" \ - --suffix PATH ":" "${tree-sitter.extraPaths}" + --suffix PATH ":" "${lsp.extraPaths}" ''; }) diff --git a/packages/common/nki-kakoune/kakrc b/packages/common/nki-kakoune/kakrc index dc06ca3..0bc3dc0 100644 --- a/packages/common/nki-kakoune/kakrc +++ b/packages/common/nki-kakoune/kakrc @@ -5,6 +5,7 @@ # set global kts_sky "rgb:6aa622" # Color scheme colorscheme catppuccin-latte +set-face global module "%opt{sapphire}" set global base "default" # Set indentation guides diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix index 6511ee9..47e8259 100644 --- a/packages/common/nki-kakoune/lsp.nix +++ b/packages/common/nki-kakoune/lsp.nix @@ -130,7 +130,7 @@ let metals = { command = "metals"; filetypes = [ "scala" ]; - roots = [ "build.sbt" "build.sc" ]; + roots = [ "build.sbt" "build.sc" "build.mill" ]; settings_section = "metals"; settings.metals = { enableSemanticHighlighting = true; -- 2.47.2 From 0f0c1649a290f49b3f89057e3cde19a118759719 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 22:26:49 +0200 Subject: [PATCH 08/41] Revert tree-sitter --- packages/common/kak-tree-sitter/default.nix | 1 - .../common/kak-tree-sitter/user_config.patch | 129 -------------- packages/common/nki-kakoune/default.nix | 5 +- .../nki-kakoune/tree-sitter/default.nix | 167 ------------------ .../nki-kakoune/tree-sitter/grammars.nix | 120 ------------- 5 files changed, 1 insertion(+), 421 deletions(-) delete mode 100644 packages/common/kak-tree-sitter/user_config.patch delete mode 100644 packages/common/nki-kakoune/tree-sitter/default.nix delete mode 100644 packages/common/nki-kakoune/tree-sitter/grammars.nix diff --git a/packages/common/kak-tree-sitter/default.nix b/packages/common/kak-tree-sitter/default.nix index 69da116..9819e3a 100644 --- a/packages/common/kak-tree-sitter/default.nix +++ b/packages/common/kak-tree-sitter/default.nix @@ -34,7 +34,6 @@ let self.runtime_dir.join("sources").join(url_dir) '') - ./user_config.patch ]; meta.mainProgram = "kak-tree-sitter"; diff --git a/packages/common/kak-tree-sitter/user_config.patch b/packages/common/kak-tree-sitter/user_config.patch deleted file mode 100644 index b2b1b6a..0000000 --- a/packages/common/kak-tree-sitter/user_config.patch +++ /dev/null @@ -1,129 +0,0 @@ -diff --git a/kak-tree-sitter-config/src/lib.rs b/kak-tree-sitter-config/src/lib.rs -index e4edc42..a9c92cb 100644 ---- a/kak-tree-sitter-config/src/lib.rs -+++ b/kak-tree-sitter-config/src/lib.rs -@@ -52,9 +52,13 @@ impl Config { - } - - /// Load the default configuration, the user configuration, and merge both. -- pub fn load_default_user() -> Result { -+ pub fn load_default_user(path: Option>) -> Result { - let mut config = Self::load_default_config()?; -- match UserConfig::load_from_xdg() { -+ let user_config = match path { -+ Some(p) => UserConfig::load(p), -+ None => UserConfig::load_from_xdg(), -+ }; -+ match user_config { - Ok(user_config) => { - config.merge_user_config(user_config)?; - } -@@ -448,7 +452,7 @@ impl UserConfig { - } - - /// Load the configuration from a given path. -- fn load(path: impl AsRef) -> Result { -+ pub fn load(path: impl AsRef) -> Result { - let path = path.as_ref(); - - log::debug!("loading configuration at {path}", path = path.display()); -diff --git a/kak-tree-sitter/src/cli.rs b/kak-tree-sitter/src/cli.rs -index b8102cd..923312c 100644 ---- a/kak-tree-sitter/src/cli.rs -+++ b/kak-tree-sitter/src/cli.rs -@@ -22,6 +22,10 @@ pub struct Cli { - #[clap(short, long)] - pub server: bool, - -+ /// Specify a custom path for the user config. -+ #[clap(short, long)] -+ pub user_config: Option, -+ - /// Try to daemonize, if not already done. - #[clap(short, long)] - pub daemonize: bool, -diff --git a/kak-tree-sitter/src/main.rs b/kak-tree-sitter/src/main.rs -index bee9698..cbd7b39 100644 ---- a/kak-tree-sitter/src/main.rs -+++ b/kak-tree-sitter/src/main.rs -@@ -43,7 +43,7 @@ fn start() -> Result<(), OhNo> { - } - } - -- let config = Config::load_default_user()?; -+ let config = Config::load_default_user(cli.user_config.as_ref())?; - - // inject rc if we start from Kakoune - if cli.kakoune && cli.init.is_some() { -diff --git a/kak-tree-sitter/src/server.rs b/kak-tree-sitter/src/server.rs -index f3b7723..000c81d 100644 ---- a/kak-tree-sitter/src/server.rs -+++ b/kak-tree-sitter/src/server.rs -@@ -73,6 +73,7 @@ impl Server { - log::debug!("creating IO handler"); - let io_handler = IOHandler::new( - config, -+ cli.user_config.clone(), - cli.is_standalone(), - cli.with_highlighting || config.features.highlighting, - resources, -@@ -165,6 +166,7 @@ struct IOHandler { - connections: HashMap, - enqueue_response: EnqueueResponse, - handler: Handler, -+ user_config_path: Option, - } - - impl IOHandler { -@@ -173,6 +175,7 @@ impl IOHandler { - - fn new( - config: &Config, -+ user_config_path: Option, - is_standalone: bool, - with_highlighting: bool, - resources: ServerResources, -@@ -203,6 +206,7 @@ impl IOHandler { - connections, - enqueue_response, - handler, -+ user_config_path, - }) - } - -@@ -450,7 +454,7 @@ impl IOHandler { - } - - fn reload(&mut self) { -- let config = match Config::load_default_user() { -+ let config = match Config::load_default_user(self.user_config_path.as_ref()) { - Ok(config) => config, - Err(err) => { - log::error!("reloading config failed: {err}"); -diff --git a/ktsctl/src/cli.rs b/ktsctl/src/cli.rs -index dfac5c3..09f86f3 100644 ---- a/ktsctl/src/cli.rs -+++ b/ktsctl/src/cli.rs -@@ -11,6 +11,9 @@ pub struct Cli { - #[clap(long)] - pub verbose: bool, - -+ #[clap(short, long)] -+ pub user_config: Option, -+ - #[clap(subcommand)] - pub cmd: Cmd, - } -diff --git a/ktsctl/src/main.rs b/ktsctl/src/main.rs -index f9a3499..f823633 100644 ---- a/ktsctl/src/main.rs -+++ b/ktsctl/src/main.rs -@@ -37,7 +37,7 @@ fn start() -> Result<(), HellNo> { - simple_logger::init_with_level(log::Level::Debug)?; - } - -- let config = Config::load_default_user()?; -+ let config = Config::load_default_user(cli.user_config.as_ref())?; - log::debug!("ktsctl configuration:\n{config:#?}"); - - match cli.cmd { diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index c7d4324..f4851af 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,9 +1,7 @@ { callPackage, kakoune, kakoune-unwrapped, ... }: let lsp = callPackage ./lsp.nix { }; - rc = (callPackage ./rc.nix { - # prependRc = tree-sitter.rc; - }); + rc = (callPackage ./rc.nix { }); in (kakoune.override { plugins = callPackage ./plugins.nix { } @@ -12,7 +10,6 @@ in (callPackage ./kaktex { }) (callPackage ./faces.nix { }) rc - # tree-sitter.plugin lsp.plugin ]; }).overrideAttrs (attrs: { diff --git a/packages/common/nki-kakoune/tree-sitter/default.nix b/packages/common/nki-kakoune/tree-sitter/default.nix deleted file mode 100644 index b94a771..0000000 --- a/packages/common/nki-kakoune/tree-sitter/default.nix +++ /dev/null @@ -1,167 +0,0 @@ -{ lib -, callPackage -, formats -, runCommandLocal -, kak-tree-sitter -, ... -}: -let - utils = callPackage ../utils.nix { }; - grammars = (callPackage ./grammars.nix { }).grammars; - # Highlighter groups to add to the `highlighterGroups`. Maps from group names to face names. - highlighterGroups = { - attribute = "@attribute"; - comment = "@comment"; - conceal = "%opt{mauve}+i"; - constant = "%opt{peach}"; - constant_builtin_boolean = "%opt{sky}"; - constant_character = "%opt{yellow}"; - constant_macro = "%opt{mauve}"; - constant_numeric = "%opt{peach}"; - constructor = "%opt{sapphire}"; - diff_plus = "%opt{green}"; - diff_minus = "%opt{red}"; - diff_delta = "%opt{blue}"; - diff_delta_moved = "%opt{mauve}"; - error = "%opt{red}+b"; - function = "@function"; - function_builtin = "@builtin"; - function_macro = "+i@ts_function"; - hint = "%opt{blue}+b"; - info = "%opt{green}+b"; - keyword = "keyword"; - keyword_conditional = "+i@ts_keyword"; - keyword_control_conditional = "+i@ts_keyword"; - keyword_control_directive = "+i@ts_keyword"; - keyword_control_import = "+i@ts_keyword"; - keyword_directive = "+i@ts_keyword"; - label = "%opt{sapphire}+i"; - markup_bold = "%opt{peach}+b"; - markup_heading = "%opt{red}"; - markup_heading_1 = "%opt{red}"; - markup_heading_2 = "%opt{mauve}"; - markup_heading_3 = "%opt{green}"; - markup_heading_4 = "%opt{yellow}"; - markup_heading_5 = "%opt{pink}"; - markup_heading_6 = "%opt{teal}"; - markup_heading_marker = "%opt{peach}+b"; - markup_italic = "%opt{pink}+i"; - markup_list_checked = "%opt{green}"; - markup_list_numbered = "%opt{blue}+i"; - markup_list_unchecked = "%opt{teal}"; - markup_list_unnumbered = "%opt{mauve}"; - markup_link_label = "%opt{blue}"; - markup_link_url = "%opt{teal}+u"; - markup_link_uri = "%opt{teal}+u"; - markup_link_text = "%opt{blue}"; - markup_quote = "%opt{crust}"; - markup_raw = "%opt{sky}"; - markup_raw_block = "%opt{sky}"; - markup_raw_inline = "%opt{green}"; - markup_strikethrough = "%opt{crust}+s"; - namespace = "@module"; - operator = "@operator"; - property = "%opt{sky}"; - punctuation = "%opt{overlay2}"; - punctuation_special = "%opt{sky}"; - special = "%opt{blue}"; - spell = "%opt{mauve}"; - string = "%opt{green}"; - string_regex = "%opt{peach}"; - string_regexp = "%opt{peach}"; - string_escape = "%opt{mauve}"; - string_special = "%opt{blue}"; - string_special_path = "%opt{green}"; - string_special_symbol = "%opt{mauve}"; - string_symbol = "%opt{red}"; - tag = "%opt{teal}"; - tag_error = "%opt{red}"; - text_title = "%opt{mauve}"; - type = "@type"; - type_enum_variant = "+i@ts_type"; - variable = "@variable"; - variable_builtin = "@builtin"; - variable_other_member = "%opt{teal}"; - variable_parameter = "+i@variable"; - warning = "%opt{peach}+b"; - }; - - # Highlighter groups to be aliased by other groups - aliases = { - comment_block = "comment"; - comment_line = "comment"; - constant_character_escape = "constant_character"; - constant_numeric_float = "constant_numeric"; - constant_numeric_integer = "constant_numeric"; - function_method = "function"; - function_special = "function"; - keyword_control = "keyword"; - keyword_control_repeat = "keyword"; - keyword_control_return = "keyword"; - keyword_control_except = "keyword"; - keyword_control_exception = "keyword"; - keyword_function = "keyword"; - keyword_operator = "keyword"; - keyword_special = "keyword"; - keyword_storage = "keyword"; - keyword_storage_modifier = "keyword"; - keyword_storage_modifier_mut = "keyword"; - keyword_storage_modifier_ref = "keyword"; - keyword_storage_type = "keyword"; - punctuation_bracket = "punctuation"; - punctuation_delimiter = "punctuation"; - text = "string"; - type_builtin = "type"; - - # Scala stuff - method = "function"; - module = "namespace"; - function_call = "function"; - method_call = "method"; - - boolean = "constant_builtin_boolean"; - number = "constant_numeric"; - float = "constant_numeric_float"; - - type_qualifier = "keyword_special"; - storageclass = "keyword_storage_modifier"; - conditional = "keyword_conditional"; - include = "keyword_control_import"; - }; - - configFile = - let - toScm = name: lib.concatStringsSep "." (lib.splitString "_" name); - toml = formats.toml { }; - in - toml.generate "config.toml" { - highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); - features = { - highlighting = true; - text_objects = true; - }; - language = grammars; - }; - - extraFaces = - let - toTs = name: "ts_${lib.concatStringsSep "_" (lib.splitString "." name)}"; - - definedFaces = lib.mapAttrs' (name: value: { inherit value; name = toTs name; }) highlighterGroups; - aliasFaces = lib.mapAttrs' (name: value: { name = toTs name; value = "@${toTs value}"; }) aliases; - faces = lib.recursiveUpdate definedFaces aliasFaces; - in - faces; -in -{ - rc = '' - # Enable kak-tree-sitter - eval %sh{kak-tree-sitter --kakoune -d --server --init $kak_session --user-config ${configFile}} - map global normal ": enter-user-mode tree-sitter" - ''; - - extraPaths = "${kak-tree-sitter}/bin"; - - plugin = utils.mkFacesScript "kak-tree-sitter" extraFaces; -} - diff --git a/packages/common/nki-kakoune/tree-sitter/grammars.nix b/packages/common/nki-kakoune/tree-sitter/grammars.nix deleted file mode 100644 index d1f6417..0000000 --- a/packages/common/nki-kakoune/tree-sitter/grammars.nix +++ /dev/null @@ -1,120 +0,0 @@ -{ lib, stdenv, fetchFromGitHub, runCommandLocal, ... }: -let - mkGrammarPackage = - { name - , src - , grammarPath ? "src" - , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] - , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] - , ... - }: stdenv.mkDerivation { - inherit src; - name = "kak-tree-sitter-grammar-${name}"; - version = "latest"; - buildPhase = '' - mkdir ${grammarPath}/build - cd ${grammarPath}/build - $CC ${lib.concatStringsSep " " grammarCompileArgs} - $CC ${lib.concatStringsSep " " grammarLinkArgs} -o ${name}.so - ''; - installPhase = '' - mkdir $out - cp ${name}.so $out - ''; - }; - mkGrammar = - args @ { name - , src - , grammarPath ? "src" - , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] - , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] - , querySrc ? src - , queryPath ? "runtime/queries/${name}" - , - }: { - grammar.source.local.path = "${mkGrammarPackage args}"; - grammar.link_args = grammarLinkArgs ++ [ "-o" "${name}.so" ]; - queries.source.local.path = querySrc; - queries.path = queryPath; - }; - - tree-sitter-go = fetchFromGitHub { - owner = "tree-sitter"; - repo = "tree-sitter-go"; - rev = "v0.20.0"; - hash = "sha256-G7d8CHCyKDAb9j6ijRfHk/HlgPqSI+uvkuRIRRvjkHI="; - }; -in -{ - grammars = builtins.mapAttrs (name: value: mkGrammar ({ inherit name; } // value)) { - scala = { - src = fetchFromGitHub { - owner = "tree-sitter"; - repo = "tree-sitter-scala"; - rev = "70afdd5632d57dd63a960972ab25945e353a52f6"; - hash = "sha256-bi0Lqo/Zs2Uaz1efuKAARpEDg5Hm59oUe7eSXgL1Wow="; - }; - queryPath = "queries/scala"; - }; - haskell = { - src = fetchFromGitHub { - owner = "tree-sitter"; - repo = "tree-sitter-haskell"; - rev = "ba0bfb0e5d8e9e31c160d287878c6f26add3ec08"; - hash = "sha256-ZSOF0CLOn82GwU3xgvFefmh/AD2j5zz8I0t5YPwfan0="; - }; - grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "../unicode.h" "-I" ".." ]; - queryPath = "queries"; - }; - yaml = { - src = fetchFromGitHub { - owner = "ikatyang"; - repo = "tree-sitter-yaml"; - rev = "0e36bed171768908f331ff7dff9d956bae016efb"; - hash = "sha256-bpiT3FraOZhJaoiFWAoVJX1O+plnIi8aXOW2LwyU23M="; - }; - grammarCompileArgs = [ "-c" "-fpic" "../scanner.cc" "../parser.c" "-I" ".." ]; - grammarLinkArgs = [ "-lstdc++" "-shared" "-fpic" "scanner.o" "parser.o" ]; - querySrc = fetchFromGitHub { - owner = "helix-editor"; - repo = "helix"; - rev = "dbd248fdfa680373d94fbc10094a160aafa0f7a7"; - hash = "sha256-wk8qVUDFXhAOi1Ibc6iBMzDCXb6t+YiWZcTd0IJybqc="; - }; - }; - templ = rec { - src = fetchFromGitHub { - owner = "vrischmann"; - repo = "tree-sitter-templ"; - rev = "044ad200092170727650fa6d368df66a8da98f9d"; - hash = "sha256-hJuB3h5pp+LLfP0/7bAYH0uLVo+OQk5jpzJb3J9BNkY="; - }; - querySrc = runCommandLocal "templ-tree-sitter-queries" { } '' - mkdir -p $out/queries - # copy most stuff from tree-sitter-templ - install -m644 ${src}/queries/templ/* $out/queries - # override inherited files - cat ${tree-sitter-go}/queries/highlights.scm ${src}/queries/templ/highlights.scm > $out/queries/highlights.scm - ''; - queryPath = "queries"; - }; - go = { - src = tree-sitter-go; - grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; - grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; - queryPath = "queries"; - }; - hylo = { - src = fetchFromGitHub { - owner = "natsukagami"; - repo = "tree-sitter-hylo"; - rev = "494cbdff0d13cbc67348316af2efa0286dbddf6f"; - hash = "sha256-R5UeoglCTl0do3VDJ/liCTeqbxU9slvmVKNRA/el2VY="; - }; - grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; - grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; - queryPath = "queries"; - }; - }; -} - -- 2.47.2 From c6724e382be5720ef1226c8f881408ef542fb49f Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 22:30:13 +0200 Subject: [PATCH 09/41] Further cleanup --- home/common.nix | 2 +- home/{kakoune/kak.nix => kakoune.nix} | 2 +- home/kakoune/autoload/latex.kak | 133 --------------- home/kakoune/autoload/markdown.kak | 29 ---- home/kakoune/catppuccin-latte.kak | 79 --------- home/kakoune/kakrc | 233 -------------------------- home/kakoune/kaktex | 28 ---- home/kakoune/kaktex.nix | 14 -- home/kakoune/source-pwd | 16 -- packages/common/nki-kakoune/kakrc | 2 +- 10 files changed, 3 insertions(+), 535 deletions(-) rename home/{kakoune/kak.nix => kakoune.nix} (98%) delete mode 100644 home/kakoune/autoload/latex.kak delete mode 100644 home/kakoune/autoload/markdown.kak delete mode 100644 home/kakoune/catppuccin-latte.kak delete mode 100644 home/kakoune/kakrc delete mode 100755 home/kakoune/kaktex delete mode 100644 home/kakoune/kaktex.nix delete mode 100755 home/kakoune/source-pwd diff --git a/home/common.nix b/home/common.nix index 2034fce..99f3511 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 9a132ac..879b2b1 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 7502c2a..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|mill) %{ - 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 diff --git a/packages/common/nki-kakoune/kakrc b/packages/common/nki-kakoune/kakrc index 0bc3dc0..878869c 100644 --- a/packages/common/nki-kakoune/kakrc +++ b/packages/common/nki-kakoune/kakrc @@ -162,7 +162,7 @@ hook global BufCreate .*[.]md %{ add-highlighter buffer/ wrap } -hook global BufCreate .*[.](sc|sbt) %{ +hook global BufCreate .*[.](sc|sbt|mill) %{ set-option buffer filetype scala } -- 2.47.2 From 281fcad46f92959c2ab788228db48c8e7222702e Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 22 Oct 2024 15:36:22 +0200 Subject: [PATCH 10/41] podman: add slirp4netns to the wrapper --- modules/common/linux/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/common/linux/default.nix b/modules/common/linux/default.nix index 3b53a0d..15b72bb 100644 --- a/modules/common/linux/default.nix +++ b/modules/common/linux/default.nix @@ -69,6 +69,7 @@ let virtualisation = { pkgs, ... }: mkIf cfg.enable { virtualisation.podman = { enable = true; + extraPackages = [ pkgs.slirp4netns ]; dockerCompat = true; defaultNetwork.settings.dns_enabled = true; }; -- 2.47.2 From a6c34181b4cd1d55b813047daabd92c0b49f4fd5 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 4 Nov 2024 14:48:54 +0100 Subject: [PATCH 11/41] Update templ and vscode langservers --- home/kakoune.nix | 4 ++-- packages/common/nki-kakoune/lsp.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/home/kakoune.nix b/home/kakoune.nix index 879b2b1..09898c3 100644 --- a/home/kakoune.nix +++ b/home/kakoune.nix @@ -97,8 +97,8 @@ in src = pkgs.fetchFromGitHub { owner = "vrischmann"; repo = "tree-sitter-templ"; - rev = "044ad200092170727650fa6d368df66a8da98f9d"; - hash = "sha256-hJuB3h5pp+LLfP0/7bAYH0uLVo+OQk5jpzJb3J9BNkY="; + rev = "4519e3ec9ca92754ca25659bb1fd410d5e0f8d88"; + hash = "sha256-ic5SlqDEZoYakrJFe0H9GdzravqovlL5sTaHjyhe74M="; }; in { diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix index 47e8259..92dca5a 100644 --- a/packages/common/nki-kakoune/lsp.nix +++ b/packages/common/nki-kakoune/lsp.nix @@ -39,8 +39,8 @@ let command = "vscode-${name}-language-server"; filetypes = [ name "templ" ]; roots = [ "package.json" ".git" ]; + package = nodePackages.vscode-langservers-extracted; }; - package = nodePackages.vscode-langservers-extracted; }; in { -- 2.47.2 From 546d8fffb5b6406964e3c0343e5811d28a3c5980 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 30 Dec 2024 13:50:29 +0100 Subject: [PATCH 12/41] Use latest kernel on framework --- nki-framework/hardware-configuration.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/nki-framework/hardware-configuration.nix b/nki-framework/hardware-configuration.nix index e88c852..c814573 100644 --- a/nki-framework/hardware-configuration.nix +++ b/nki-framework/hardware-configuration.nix @@ -12,7 +12,6 @@ boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "sd_mod" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; - boot.kernelPackages = pkgs.linuxPackages; # until mesa fixed boot.kernelParams = [ # Hibernation "resume=UUID=fa8aaf51-b99f-4fb4-9230-8c0957d8af3f" -- 2.47.2 From cb800c9fa49af40ab84a2d27f92d2028f5c444d0 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 30 Dec 2024 13:52:43 +0100 Subject: [PATCH 13/41] Add associations for telegram --- home/modules/linux/graphical/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/home/modules/linux/graphical/default.nix b/home/modules/linux/graphical/default.nix index 35a29eb..499088a 100644 --- a/home/modules/linux/graphical/default.nix +++ b/home/modules/linux/graphical/default.nix @@ -131,6 +131,8 @@ in "x-scheme-handler/feed" = [ "thunderbird.desktop" ]; "application/rss+xml" = [ "thunderbird.desktop" ]; "application/x-extension-rss" = [ "thunderbird.desktop" ]; + "x-scheme-handler/tg2" = [ "org.telegram.desktop.desktop" ]; + "x-scheme-handler/tonsite2" = [ "org.telegram.desktop.desktop" ]; }; xdg.mimeApps.defaultApplications = { # Email @@ -167,6 +169,10 @@ in # Files "inode/directory" = [ "dolphin.desktop" ]; + + # Telegram + "x-scheme-handler/tg2" = "org.telegram.desktop.desktop"; + "x-scheme-handler/tonsite2" = "org.telegram.desktop.desktop"; }; # Add one for kakoune -- 2.47.2 From 5ff48d63c6eaf53d3bbe7eb4ab585d5b5dc8f3f8 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 4 Jan 2025 15:48:03 +0100 Subject: [PATCH 14/41] Set diff conflictStyle to zdiff3 https://github.blog/open-source/git/highlights-from-git-2-35/ https://git-scm.com/docs/git-config#Documentation/git-config.txt-mergeconflictStyle --- home/common.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/common.nix b/home/common.nix index 99f3511..2832a6e 100644 --- a/home/common.nix +++ b/home/common.nix @@ -106,7 +106,7 @@ .kakrc ''}"; safe.directory = "*"; - merge.conflictstyle = "diff3"; + merge.conflictstyle = "zdiff3"; }; }; -- 2.47.2 From 331e17df534ece38f2d3cfaea1960b2ea2909247 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 17 Jan 2025 12:07:27 +0100 Subject: [PATCH 15/41] Update kak-lsp to v18.1.1 --- flake.lock | 7 ++++--- flake.nix | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index 0f1eb63..1ff9f9e 100644 --- a/flake.lock +++ b/flake.lock @@ -740,15 +740,16 @@ "kak-lsp": { "flake": false, "locked": { - "lastModified": 1723206901, - "narHash": "sha256-wPCu/VxAMIB+zI0+eDq7lJ/rHJZfe0whYzdoiwrixCc=", + "lastModified": 1734533380, + "narHash": "sha256-7ULohcCpIKOb7CtsF2dIkiRt94uBIrGD5pQ2AEfrNrY=", "owner": "kakoune-lsp", "repo": "kakoune-lsp", - "rev": "ebd370f43cb6e7af634e5f8cadb99cc8c16e1efe", + "rev": "dc348f04038f7286d606e99719509d6dbd2469da", "type": "github" }, "original": { "owner": "kakoune-lsp", + "ref": "v18.1.1", "repo": "kakoune-lsp", "type": "github" } diff --git a/flake.nix b/flake.nix index 19e21d2..babfc3d 100644 --- a/flake.nix +++ b/flake.nix @@ -55,7 +55,7 @@ # --- Sources kakoune.url = github:mawww/kakoune; kakoune.flake = false; - kak-lsp.url = github:kakoune-lsp/kakoune-lsp; + kak-lsp.url = "github:kakoune-lsp/kakoune-lsp/v18.1.1"; kak-lsp.flake = false; nixos-m1.url = github:tpwrules/nixos-apple-silicon; nixos-m1.inputs.nixpkgs.follows = "nixpkgs"; -- 2.47.2 From 1d2505253f64ba5febbd1abf1d80f5b0217159bc Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 17 Jan 2025 15:53:08 +0100 Subject: [PATCH 16/41] niri: make workspace bindings only if the workspaces are fixed --- home/modules/programs/my-niri.nix | 40 +++++++++++++++---------------- home/nki-framework.nix | 3 +++ 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/home/modules/programs/my-niri.nix b/home/modules/programs/my-niri.nix index d62a175..ea8f0e5 100644 --- a/home/modules/programs/my-niri.nix +++ b/home/modules/programs/my-niri.nix @@ -331,26 +331,26 @@ in # # For example, with 2 workspaces + 1 empty, indices 3, 4, 5 and so on # will all refer to the 3rd workspace. - "Mod+1".action = focus-workspace (cfg.workspaces."01".name); - "Mod+2".action = focus-workspace (cfg.workspaces."02".name); - "Mod+3".action = focus-workspace (cfg.workspaces."03".name); - "Mod+4".action = focus-workspace (cfg.workspaces."04".name); - "Mod+5".action = focus-workspace (cfg.workspaces."05".name); - "Mod+6".action = focus-workspace (cfg.workspaces."06".name); - "Mod+7".action = focus-workspace (cfg.workspaces."07".name); - "Mod+8".action = focus-workspace (cfg.workspaces."08".name); - "Mod+9".action = focus-workspace (cfg.workspaces."09".name); - "Mod+0".action = focus-workspace (cfg.workspaces."10".name); - "Mod+Shift+1".action = move-column-to-workspace (cfg.workspaces."01".name); - "Mod+Shift+2".action = move-column-to-workspace (cfg.workspaces."02".name); - "Mod+Shift+3".action = move-column-to-workspace (cfg.workspaces."03".name); - "Mod+Shift+4".action = move-column-to-workspace (cfg.workspaces."04".name); - "Mod+Shift+5".action = move-column-to-workspace (cfg.workspaces."05".name); - "Mod+Shift+6".action = move-column-to-workspace (cfg.workspaces."06".name); - "Mod+Shift+7".action = move-column-to-workspace (cfg.workspaces."07".name); - "Mod+Shift+8".action = move-column-to-workspace (cfg.workspaces."08".name); - "Mod+Shift+9".action = move-column-to-workspace (cfg.workspaces."09".name); - "Mod+Shift+0".action = move-column-to-workspace (cfg.workspaces."10".name); + "Mod+1" = lib.mkIf cfg.workspaces."01".fixed { action = focus-workspace (cfg.workspaces."01".name); }; + "Mod+2" = lib.mkIf cfg.workspaces."02".fixed { action = focus-workspace (cfg.workspaces."02".name); }; + "Mod+3" = lib.mkIf cfg.workspaces."03".fixed { action = focus-workspace (cfg.workspaces."03".name); }; + "Mod+4" = lib.mkIf cfg.workspaces."04".fixed { action = focus-workspace (cfg.workspaces."04".name); }; + "Mod+5" = lib.mkIf cfg.workspaces."05".fixed { action = focus-workspace (cfg.workspaces."05".name); }; + "Mod+6" = lib.mkIf cfg.workspaces."06".fixed { action = focus-workspace (cfg.workspaces."06".name); }; + "Mod+7" = lib.mkIf cfg.workspaces."07".fixed { action = focus-workspace (cfg.workspaces."07".name); }; + "Mod+8" = lib.mkIf cfg.workspaces."08".fixed { action = focus-workspace (cfg.workspaces."08".name); }; + "Mod+9" = lib.mkIf cfg.workspaces."09".fixed { action = focus-workspace (cfg.workspaces."09".name); }; + "Mod+0" = lib.mkIf cfg.workspaces."10".fixed { action = focus-workspace (cfg.workspaces."10".name); }; + "Mod+Shift+1" = lib.mkIf cfg.workspaces."01".fixed { action = move-column-to-workspace (cfg.workspaces."01".name); }; + "Mod+Shift+2" = lib.mkIf cfg.workspaces."02".fixed { action = move-column-to-workspace (cfg.workspaces."02".name); }; + "Mod+Shift+3" = lib.mkIf cfg.workspaces."03".fixed { action = move-column-to-workspace (cfg.workspaces."03".name); }; + "Mod+Shift+4" = lib.mkIf cfg.workspaces."04".fixed { action = move-column-to-workspace (cfg.workspaces."04".name); }; + "Mod+Shift+5" = lib.mkIf cfg.workspaces."05".fixed { action = move-column-to-workspace (cfg.workspaces."05".name); }; + "Mod+Shift+6" = lib.mkIf cfg.workspaces."06".fixed { action = move-column-to-workspace (cfg.workspaces."06".name); }; + "Mod+Shift+7" = lib.mkIf cfg.workspaces."07".fixed { action = move-column-to-workspace (cfg.workspaces."07".name); }; + "Mod+Shift+8" = lib.mkIf cfg.workspaces."08".fixed { action = move-column-to-workspace (cfg.workspaces."08".name); }; + "Mod+Shift+9" = lib.mkIf cfg.workspaces."09".fixed { action = move-column-to-workspace (cfg.workspaces."09".name); }; + "Mod+Shift+0" = lib.mkIf cfg.workspaces."10".fixed { action = move-column-to-workspace (cfg.workspaces."10".name); }; "Mod+asciicircum".action = focus-workspace (cfg.workspaces."99".name); "Mod+Shift+asciicircum".action = move-column-to-workspace (cfg.workspaces."99".name); diff --git a/home/nki-framework.nix b/home/nki-framework.nix index 3c995eb..bddea4a 100644 --- a/home/nki-framework.nix +++ b/home/nki-framework.nix @@ -47,6 +47,9 @@ }; }; programs.my-niri.enable = true; + programs.my-niri.workspaces = lib.genAttrs [ "04" "05" "06" "07" "08" "09" ] (_: { + fixed = false; + }); programs.niri.settings = { input.keyboard.xkb.options = "ctrl:swapcaps"; }; -- 2.47.2 From b96dd59552f58856371ca8b068224ca4c72d2c44 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 17 Jan 2025 15:53:24 +0100 Subject: [PATCH 17/41] kak: make kak-lsp binary overridable --- packages/common/nki-kakoune/lsp.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix index 01503cc..eb62e0c 100644 --- a/packages/common/nki-kakoune/lsp.nix +++ b/packages/common/nki-kakoune/lsp.nix @@ -264,11 +264,11 @@ let (lib.mapAttrsToList (_: serv: serv.package or null) config.languageServers); in { - extraPaths = lib.makeBinPath serverPackages; + extraPaths = lib.makeBinPath (serverPackages ++ [ kak-lsp ]); plugin = writeTextDir "share/kak/autoload/kak-lsp.kak" '' hook global KakBegin .* %{ try %{ - eval %sh{${lib.getExe kak-lsp} --kakoune --config ${kak-lsp-config} -s $kak_session} + eval %sh{kak-lsp --kakoune --config ${kak-lsp-config} -s $kak_session} } lsp-enable -- 2.47.2 From 0113e656a267788a284b7e75051f21dc7f4c91b5 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 17 Jan 2025 16:18:56 +0100 Subject: [PATCH 18/41] Add niri and sway explicitly to swaync's WantedBy --- home/modules/linux/graphical/wayland.nix | 2 -- home/modules/programs/my-sway/default.nix | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/home/modules/linux/graphical/wayland.nix b/home/modules/linux/graphical/wayland.nix index d44d534..785e0f6 100644 --- a/home/modules/linux/graphical/wayland.nix +++ b/home/modules/linux/graphical/wayland.nix @@ -10,8 +10,6 @@ let settings.widgets = [ "inhibitors" "title" "dnd" "mpris" "notifications" ]; style = ./swaync.css; }; - systemd.user.services.swaync.Install.WantedBy = lib.mkForce [ "sway-session.target" ]; - systemd.user.services.swaync.Unit.PartOf = lib.mkForce [ "graphical-session.target" ]; programs.my-waybar = { extraSettings = [{ diff --git a/home/modules/programs/my-sway/default.nix b/home/modules/programs/my-sway/default.nix index e073abf..1bf6ed3 100644 --- a/home/modules/programs/my-sway/default.nix +++ b/home/modules/programs/my-sway/default.nix @@ -104,6 +104,7 @@ in enableLaptopBars = mkDefault cfg.enableLaptop; terminal = mkDefault cfg.terminal; }; + config.systemd.user.services.swaync.Install.WantedBy = mkIf cfg.enable [ "sway-session.target" ]; config.wayland.windowManager.sway = mkIf cfg.enable { enable = true; -- 2.47.2 From 381f54e0e1d1773b99c60c7d7b101b4afd1bd97a Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sun, 19 Jan 2025 22:21:06 +0100 Subject: [PATCH 19/41] Make owncloud start *after* graphical-session --- home/common-linux.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/home/common-linux.nix b/home/common-linux.nix index 61302be..89d6699 100644 --- a/home/common-linux.nix +++ b/home/common-linux.nix @@ -49,6 +49,7 @@ in services.owncloud-client.package = pkgs.owncloud-client.overrideAttrs (attrs: { buildInputs = attrs.buildInputs ++ [ pkgs.qt6.qtwayland ]; }); + systemd.user.services.owncloud-client.Unit.After = [ "graphical-session.target" ]; # UDisks automounter services.udiskie.enable = true; -- 2.47.2 From a3ecb0016082c86538212587a5ead52f574c2f42 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sun, 19 Jan 2025 22:21:19 +0100 Subject: [PATCH 20/41] Make wlsunset start *after* graphical-session --- home/modules/linux/graphical/wayland.nix | 1 + home/modules/programs/my-niri.nix | 2 ++ 2 files changed, 3 insertions(+) diff --git a/home/modules/linux/graphical/wayland.nix b/home/modules/linux/graphical/wayland.nix index 785e0f6..26776b8 100644 --- a/home/modules/linux/graphical/wayland.nix +++ b/home/modules/linux/graphical/wayland.nix @@ -107,6 +107,7 @@ with lib; latitude = "46.31"; longitude = "6.38"; }; + systemd.user.services.wlsunset.Unit.After = "graphical-session.target"; # Notification system diff --git a/home/modules/programs/my-niri.nix b/home/modules/programs/my-niri.nix index ea8f0e5..2149419 100644 --- a/home/modules/programs/my-niri.nix +++ b/home/modules/programs/my-niri.nix @@ -86,6 +86,8 @@ in Service.Slice = "session.slice"; Service.Type = "notify"; Service.ExecStart = "${lib.getExe pkgs.xwayland-satellite} ${xwayland-display}"; + Service.ExecStartPost = [ "systemctl --user set-environment DISPLAY=${xwayland-display}" ]; + Service.ExecStopPre = [ "systemctl --user unset-environment" ]; }; programs.niri.settings = { -- 2.47.2 From 448e8e11e343d77ed7b091ed12bf3873a0240bdf Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 21 Jan 2025 15:27:34 +0100 Subject: [PATCH 21/41] Make systemd arguments compatible with old home-manager --- home/modules/programs/my-niri.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/home/modules/programs/my-niri.nix b/home/modules/programs/my-niri.nix index 2149419..0e4ed22 100644 --- a/home/modules/programs/my-niri.nix +++ b/home/modules/programs/my-niri.nix @@ -82,12 +82,13 @@ in Before = [ "xwayland.target" "xdg-desktop-autostart.target" ]; After = [ "niri.service" ]; }; + Install.WantedBy = [ "niri.service" ]; Install.UpheldBy = [ "niri.service" ]; Service.Slice = "session.slice"; Service.Type = "notify"; Service.ExecStart = "${lib.getExe pkgs.xwayland-satellite} ${xwayland-display}"; Service.ExecStartPost = [ "systemctl --user set-environment DISPLAY=${xwayland-display}" ]; - Service.ExecStopPre = [ "systemctl --user unset-environment" ]; + Service.ExecStopPost = [ "systemctl --user unset-environment" ]; }; programs.niri.settings = { -- 2.47.2 From b42b7b2755311992534e644269857dee12409bb5 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 21 Jan 2025 22:16:20 +0100 Subject: [PATCH 22/41] Make vesktop run in wayland mode --- overlay.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/overlay.nix b/overlay.nix index a3d5f70..f2a3322 100644 --- a/overlay.nix +++ b/overlay.nix @@ -83,6 +83,10 @@ let glib-compile-schemas $out/share/glib-2.0/schemas ''; }); + + vesktop = prev.vesktop.overrideAttrs (attrs: { + postFixup = builtins.replaceStrings [ "NIXOS_OZONE_WL" "--enable-wayland-ime=true" ] [ "WAYLAND_DISPLAY" "--enable-wayland-ime=true --wayland-text-input-version=3" ] attrs.postFixup; + }); }; overlay-libs = final: prev: { @@ -135,6 +139,3 @@ in # Bug fixes ] # we assign the overlay created before to the overlays of nixpkgs. - - - -- 2.47.2 From cf0e90cb5961d9122aaa34fd3060c3fbfdfca6ae Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 21 Jan 2025 23:06:24 +0100 Subject: [PATCH 23/41] Remove GTK_IM_MODULE so it uses wayland --- home/modules/programs/my-niri.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/home/modules/programs/my-niri.nix b/home/modules/programs/my-niri.nix index 0e4ed22..d8efd36 100644 --- a/home/modules/programs/my-niri.nix +++ b/home/modules/programs/my-niri.nix @@ -96,7 +96,6 @@ in QT_QPA_PLATFORM = "wayland"; QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; QT_IM_MODULE = "fcitx"; - GTK_IM_MODULE = "fcitx"; # Til text-input is merged # export NIXOS_OZONE_WL=1 # Until text-input is merged DISPLAY = xwayland-display; } // lib.optionalAttrs osConfig.services.desktopManager.plasma6.enable { -- 2.47.2 From 357866e46bf176d30107ad70cb4af600d858947b Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 21 Jan 2025 22:16:28 +0100 Subject: [PATCH 24/41] Update nix-gaming --- flake.lock | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index 1ff9f9e..f51006d 100644 --- a/flake.lock +++ b/flake.lock @@ -416,11 +416,11 @@ "nixpkgs-lib": "nixpkgs-lib_2" }, "locked": { - "lastModified": 1722555600, - "narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=", + "lastModified": 1736143030, + "narHash": "sha256-+hu54pAoLDEZT9pjHlqL9DNzWz0NbUn8NEAHP7PQPzU=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "8471fe90ad337a8074e957b69ca4d0089218391d", + "rev": "b905f6fc23a9051a6e1b741e1438dbfc0634c6de", "type": "github" }, "original": { @@ -931,11 +931,11 @@ "umu": "umu" }, "locked": { - "lastModified": 1723945279, - "narHash": "sha256-3W+/u3v/e0dTOxht6wW6pL+kr44e8Amb8A1Z3Bx8BUE=", + "lastModified": 1737337163, + "narHash": "sha256-Z9hc25iV+jhH0AlvsrG65KqLEd726/HVvalSiqNQLqA=", "owner": "fufexan", "repo": "nix-gaming", - "rev": "bcf8116981cc332c2734d4c82a034f115780853d", + "rev": "e5559b3a91433c21eb64792b78134582b3bd77f2", "type": "github" }, "original": { @@ -1017,14 +1017,14 @@ }, "nixpkgs-lib_2": { "locked": { - "lastModified": 1722555339, - "narHash": "sha256-uFf2QeW7eAHlYXuDktm9c25OxOyCoUOQmh5SZ9amE5Q=", + "lastModified": 1735774519, + "narHash": "sha256-CewEm1o2eVAnoqb6Ml+Qi9Gg/EfNAxbRx1lANGVyoLI=", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/e9b51731911566bbf7e4895475a87fe06961de0b.tar.gz" }, "original": { "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/e9b51731911566bbf7e4895475a87fe06961de0b.tar.gz" } }, "nixpkgs-stable": { @@ -1253,16 +1253,16 @@ }, "nixpkgs_9": { "locked": { - "lastModified": 1736549401, - "narHash": "sha256-ibkQrMHxF/7TqAYcQE+tOnIsSEzXmMegzyBWza6uHKM=", - "owner": "nixos", + "lastModified": 1737003892, + "narHash": "sha256-RCzJE9wKByLCXmRBp+z8LK9EgdW+K+W/DXnJS4S/NVo=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "1dab772dd4a68a7bba5d9460685547ff8e17d899", + "rev": "ae06b9c2d83cb5c8b12d7d0e32692e93d1379713", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-24.11", + "owner": "NixOS", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -1592,11 +1592,11 @@ }, "locked": { "dir": "packaging/nix", - "lastModified": 1723697867, - "narHash": "sha256-LTfbJXR8x35oZ8Mo3R0WTVEp9toWpVfzD21xCSr64IM=", + "lastModified": 1737484151, + "narHash": "sha256-pONHsVIyIHbjyv51JQW3Nv9JeuqiVEuINyH+HnN4f8Q=", "ref": "refs/heads/main", - "rev": "c71a45ad53036f4c668bcbe1be7a49f9d3460151", - "revCount": 699, + "rev": "0cac244cc89ee69bf33ad60a3953cfde188ee8a6", + "revCount": 907, "submodules": true, "type": "git", "url": "https://github.com/Open-Wine-Components/umu-launcher/" -- 2.47.2 From 0e4c25aa67103dbf1b08cf31a0dbfc2b1a19f413 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 23 Jan 2025 00:07:50 +0100 Subject: [PATCH 25/41] Mount steam --- modules/common/linux/default.nix | 7 ++++++- nki-home/hardware-configuration.nix | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/common/linux/default.nix b/modules/common/linux/default.nix index 72413f4..2c2186b 100644 --- a/modules/common/linux/default.nix +++ b/modules/common/linux/default.nix @@ -331,7 +331,12 @@ in # DConf for GNOME configurations programs.dconf.enable = true; # Gaming! (not for ARM64) - programs.steam.enable = !pkgs.stdenv.isAarch64; + programs.steam.enable = true; + programs.gamescope = { + enable = true; + # capSysNice = true; # https://github.com/NixOS/nixpkgs/issues/351516 + args = [ "--adaptive-sync" "--rt" ]; + }; ## Services # OpenSSH so you can SSH to me diff --git a/nki-home/hardware-configuration.nix b/nki-home/hardware-configuration.nix index 7b695ed..35a97ec 100644 --- a/nki-home/hardware-configuration.nix +++ b/nki-home/hardware-configuration.nix @@ -33,6 +33,18 @@ fsType = "vfat"; }; + fileSystems."/mnt/steam" = { + device = "/dev/disk/by-uuid/d1db9f65-6add-4714-b9d7-16e16f687396"; + fsType = "btrfs"; + options = [ "compress=zstd" "subvol=steam" ]; + encrypted = { + enable = true; + label = "encdata"; + blkDev = "/dev/disk/by-uuid/6544f506-9a22-479c-8bfc-aee1b9e0deda"; + keyFile = "/sysroot/var/crypto/key_data"; + }; + }; + swapDevices = [{ device = "/dev/disk/by-uuid/561f6441-1915-4059-a5e1-76a449b0c9bf"; }]; -- 2.47.2 From 465a89fef949ee6ea43ca31297655ee9238ad6cc Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 3 Feb 2025 14:53:12 +0100 Subject: [PATCH 26/41] Flake update --- flake.lock | 88 ++++++++++++++-------------------------------------- flake.nix | 18 +++++------ home/osu.nix | 42 ++++++++++++------------- 3 files changed, 53 insertions(+), 95 deletions(-) diff --git a/flake.lock b/flake.lock index f51006d..d989f8a 100644 --- a/flake.lock +++ b/flake.lock @@ -724,11 +724,11 @@ ] }, "locked": { - "lastModified": 1736785676, - "narHash": "sha256-TY0jUwR3EW0fnS0X5wXMAVy6h4Z7Y6a3m+Yq++C9AyE=", + "lastModified": 1738448366, + "narHash": "sha256-4ATtQqBlgsGqkHTemta0ydY6f7JBRXz4Hf574NHQpkg=", "owner": "nix-community", "repo": "home-manager", - "rev": "fc52a210b60f2f52c74eac41a8647c1573d2071d", + "rev": "18fa9f323d8adbb0b7b8b98a8488db308210ed93", "type": "github" }, "original": { @@ -800,15 +800,15 @@ "lix": { "flake": false, "locked": { - "lastModified": 1729298361, - "narHash": "sha256-hiGtfzxFkDc9TSYsb96Whg0vnqBVV7CUxyscZNhed0U=", - "rev": "ad9d06f7838a25beec425ff406fe68721fef73be", + "lastModified": 1737234286, + "narHash": "sha256-CCKIAE84dzkrnlxJCKFyffAxP3yfsOAbdvydUGqq24g=", + "rev": "2837da71ec1588c1187d2e554719b15904a46c8b", "type": "tarball", - "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/ad9d06f7838a25beec425ff406fe68721fef73be.tar.gz?rev=ad9d06f7838a25beec425ff406fe68721fef73be" + "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/2837da71ec1588c1187d2e554719b15904a46c8b.tar.gz?rev=2837da71ec1588c1187d2e554719b15904a46c8b" }, "original": { "type": "tarball", - "url": "https://git.lix.systems/lix-project/lix/archive/2.91.1.tar.gz" + "url": "https://git.lix.systems/lix-project/lix/archive/2.92.0.tar.gz" } }, "lix-module": { @@ -821,15 +821,15 @@ ] }, "locked": { - "lastModified": 1729360442, - "narHash": "sha256-6U0CyPycIBc04hbYy2hBINnVso58n/ZyywY2BD3hu+s=", - "rev": "9098ac95768f7006d7e070b88bae76939f6034e6", + "lastModified": 1737237494, + "narHash": "sha256-YMLrcBpf0TR5r/eaqm8lxzFPap2TxCor0ZGcK3a7+b8=", + "rev": "b90bf629bbd835e61f1317b99e12f8c831017006", "type": "tarball", - "url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/9098ac95768f7006d7e070b88bae76939f6034e6.tar.gz?rev=9098ac95768f7006d7e070b88bae76939f6034e6" + "url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/b90bf629bbd835e61f1317b99e12f8c831017006.tar.gz?rev=b90bf629bbd835e61f1317b99e12f8c831017006" }, "original": { "type": "tarball", - "url": "https://git.lix.systems/lix-project/nixos-module/archive/2.91.1-1.tar.gz" + "url": "https://git.lix.systems/lix-project/nixos-module/archive/2.92.0.tar.gz" } }, "mpd-mpris": { @@ -1077,11 +1077,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1736755442, - "narHash": "sha256-a3MMEY7i/wdF0gb7WFNTn6onzaiMOvwj7OerRVenA8o=", + "lastModified": 1738452225, + "narHash": "sha256-Qmwx3FXM0x0pdjibwTk/uRbayqDrs3EwmRJe7tQWu48=", "owner": "nixos", "repo": "nixpkgs", - "rev": "ef56e777fedaa4da8c66a150081523c5de1e0171", + "rev": "6c4e0724e0a785a20679b1bca3a46bfce60f05b6", "type": "github" }, "original": { @@ -1125,11 +1125,11 @@ }, "nixpkgs_12": { "locked": { - "lastModified": 1734424634, - "narHash": "sha256-cHar1vqHOOyC7f1+tVycPoWTfKIaqkoe1Q6TnKzuti4=", + "lastModified": 1738410390, + "narHash": "sha256-xvTo0Aw0+veek7hvEVLzErmJyQkEcRk6PSR4zsRQFEc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "d3c42f187194c26d9f0309a8ecc469d6c878ce33", + "rev": "3a228057f5b619feb3186e986dbe76278d707b6e", "type": "github" }, "original": { @@ -1683,17 +1683,14 @@ }, "zen-browser": { "inputs": { - "nixpkgs": "nixpkgs_12", - "zen-browser-aarch64": "zen-browser-aarch64", - "zen-browser-generic": "zen-browser-generic", - "zen-browser-specific": "zen-browser-specific" + "nixpkgs": "nixpkgs_12" }, "locked": { - "lastModified": 1734667644, - "narHash": "sha256-vluyzRt6RikEn78Yk0t7Qd96iZZfyRBt4+ESI0mtlhk=", + "lastModified": 1738469108, + "narHash": "sha256-AS4akOUGZP2ELHQKj1IiXuuzU9bpK20ks4dGaCrwOEk=", "owner": "youwen5", "repo": "zen-browser-flake", - "rev": "8c8af380bf45b42ae14b2f6d5252be3627332f23", + "rev": "f95fa7b1560b0f2ed8989e6f12f2c7e7e7ee9433", "type": "github" }, "original": { @@ -1701,45 +1698,6 @@ "repo": "zen-browser-flake", "type": "github" } - }, - "zen-browser-aarch64": { - "flake": false, - "locked": { - "lastModified": 1734641206, - "narHash": "sha256-F5FwGqAgL4kfEy5rNWvofRQl8SH0udQvEIMhysRMDgs=", - "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.3/zen.linux-aarch64.tar.bz2" - }, - "original": { - "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.3/zen.linux-aarch64.tar.bz2" - } - }, - "zen-browser-generic": { - "flake": false, - "locked": { - "lastModified": 1734646830, - "narHash": "sha256-slIWuEWSV9PK1JTr6UKKC+VP4oLNaczwkxkYiqcjZM8=", - "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.3/zen.linux-generic.tar.bz2" - }, - "original": { - "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.3/zen.linux-generic.tar.bz2" - } - }, - "zen-browser-specific": { - "flake": false, - "locked": { - "lastModified": 1734645803, - "narHash": "sha256-zAo93sHeB8cTW2JBAqxx0wo3CANcxCgjEcTQgbDeWT4=", - "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.3/zen.linux-specific.tar.bz2" - }, - "original": { - "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.3/zen.linux-specific.tar.bz2" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index babfc3d..95db841 100644 --- a/flake.nix +++ b/flake.nix @@ -18,20 +18,20 @@ # --- Secure boot lanzaboote = { - url = github:nix-community/lanzaboote/v0.4.1; + url = "github:nix-community/lanzaboote/v0.4.1"; inputs.nixpkgs.follows = "nixpkgs"; }; # --- Build tools - flake-utils.url = github:numtide/flake-utils; - crane.url = github:ipetkov/crane; + flake-utils.url = "github:numtide/flake-utils"; + crane.url = "github:ipetkov/crane"; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; - arion.url = github:hercules-ci/arion; + arion.url = "github:hercules-ci/arion"; lix-module = { - url = "https://git.lix.systems/lix-project/nixos-module/archive/2.91.1-1.tar.gz"; + url = "https://git.lix.systems/lix-project/nixos-module/archive/2.92.0.tar.gz"; inputs.nixpkgs.follows = "nixpkgs"; }; @@ -43,21 +43,21 @@ # inputs.nixpkgs.follows = "nixpkgs"; # }; mpd-mpris = { - url = github:natsukagami/mpd-mpris; + url = "github:natsukagami/mpd-mpris"; inputs.nixpkgs.follows = "nixpkgs"; }; dtth-phanpy.url = "git+ssh://gitea@git.dtth.ch/nki-dtth/phanpy?ref=dtth-fork"; conduit.url = "gitlab:famedly/conduit/v0.9.0"; - nix-gaming.url = github:fufexan/nix-gaming; + nix-gaming.url = "github:fufexan/nix-gaming"; zen-browser.url = "github:youwen5/zen-browser-flake"; niri.url = "github:sodiboo/niri-flake"; # --- Sources - kakoune.url = github:mawww/kakoune; + kakoune.url = "github:mawww/kakoune"; kakoune.flake = false; kak-lsp.url = "github:kakoune-lsp/kakoune-lsp/v18.1.1"; kak-lsp.flake = false; - nixos-m1.url = github:tpwrules/nixos-apple-silicon; + nixos-m1.url = "github:tpwrules/nixos-apple-silicon"; nixos-m1.inputs.nixpkgs.follows = "nixpkgs"; # --- diff --git a/home/osu.nix b/home/osu.nix index 07f4cf1..e64424a 100644 --- a/home/osu.nix +++ b/home/osu.nix @@ -1,28 +1,28 @@ { pkgs, lib, ... }: let - # osu-pkg = pkgs.unstable.osu-lazer-bin; - osu-pkg = with pkgs; with lib; - appimageTools.wrapType2 rec { - pname = "osu-lazer-bin"; - version = "2025.101.0"; - src = fetchurl { - url = "https://github.com/ppy/osu/releases/download/${version}/osu.AppImage"; - hash = "sha256-GsnTxVpNk2RXHLET6Ugv0/ZOlq8RUkw2ZXqRjkU+dzw="; - }; - extraPkgs = pkgs: with pkgs; [ icu ]; + osu-pkg = pkgs.unstable.osu-lazer-bin; + # osu-pkg = with pkgs; with lib; + # appimageTools.wrapType2 rec { + # pname = "osu-lazer-bin"; + # version = "2025.101.0"; + # src = fetchurl { + # url = "https://github.com/ppy/osu/releases/download/${version}/osu.AppImage"; + # hash = "sha256-GsnTxVpNk2RXHLET6Ugv0/ZOlq8RUkw2ZXqRjkU+dzw="; + # }; + # extraPkgs = pkgs: with pkgs; [ icu ]; - extraInstallCommands = - let contents = appimageTools.extract { inherit pname version src; }; - in - '' - mv -v $out/bin/${pname} $out/bin/osu\! - install -m 444 -D ${contents}/osu\!.desktop -t $out/share/applications - for i in 16 32 48 64 96 128 256 512 1024; do - install -D ${contents}/osu.png $out/share/icons/hicolor/''${i}x$i/apps/osu.png - done - ''; - }; + # extraInstallCommands = + # let contents = appimageTools.extract { inherit pname version src; }; + # in + # '' + # mv -v $out/bin/${pname} $out/bin/osu\! + # install -m 444 -D ${contents}/osu\!.desktop -t $out/share/applications + # for i in 16 32 48 64 96 128 256 512 1024; do + # install -D ${contents}/osu.png $out/share/icons/hicolor/''${i}x$i/apps/osu.png + # done + # ''; + # }; in { home.packages = [ osu-pkg ]; -- 2.47.2 From 2e6a70c5a9cec4f867697a61f0f1f95a9cd14c4d Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 3 Feb 2025 15:40:22 +0100 Subject: [PATCH 27/41] Make new zen-browser compile --- overlay.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/overlay.nix b/overlay.nix index f2a3322..e776500 100644 --- a/overlay.nix +++ b/overlay.nix @@ -110,13 +110,14 @@ let meta.mainProgram = "kak-lsp"; }; - zen-browser-bin = final.callPackage inputs.zen-browser.packages.${final.stdenv.system}.zen-browser.override { - wrap-firefox = opts: final.wrapFirefox (opts // { + zen-browser-bin = inputs.zen-browser.packages.${final.stdenv.system}.zen-browser.override { + inherit (inputs.zen-browser.packages.${final.stdenv.system}) zen-browser-unwrapped; + wrapFirefox = opts: final.wrapFirefox (opts // { nativeMessagingHosts = with final; [ kdePackages.plasma-browser-integration ]; }); - zen-browser-unwrapped = final.callPackage inputs.zen-browser.packages.${final.stdenv.system}.zen-browser-unwrapped.override { - sources = inputs.zen-browser.inputs; - }; + # zen-browser-unwrapped = final.callPackage inputs.zen-browser.packages.${final.stdenv.system}.zen-browser-unwrapped.override { + # sources = inputs.zen-browser.inputs; + # }; }; }; in -- 2.47.2 From 30c48b9340b1df5237601085356fb51a4d05bfae Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 3 Feb 2025 15:41:30 +0100 Subject: [PATCH 28/41] Update lanzaboote --- flake.lock | 87 ++++++++++++++++++++++++++++++------------------------ flake.nix | 2 +- 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/flake.lock b/flake.lock index d989f8a..73f497c 100644 --- a/flake.lock +++ b/flake.lock @@ -133,10 +133,7 @@ }, "crane_4": { "inputs": { - "nixpkgs": [ - "lanzaboote", - "nixpkgs" - ] + "nixpkgs": "nixpkgs_8" }, "locked": { "lastModified": 1717535930, @@ -503,11 +500,11 @@ "systems": "systems_5" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -775,7 +772,6 @@ "crane": "crane_4", "flake-compat": "flake-compat_4", "flake-parts": "flake-parts_4", - "flake-utils": "flake-utils_5", "nixpkgs": [ "nixpkgs" ], @@ -783,16 +779,16 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1718178907, - "narHash": "sha256-eSZyrQ9uoPB9iPQ8Y5H7gAmAgAvCw3InStmU3oEjqsE=", + "lastModified": 1737639419, + "narHash": "sha256-AEEDktApTEZ5PZXNDkry2YV2k6t0dTgLPEmAZbnigXU=", "owner": "nix-community", "repo": "lanzaboote", - "rev": "b627ccd97d0159214cee5c7db1412b75e4be6086", + "rev": "a65905a09e2c43ff63be8c0e86a93712361f871e", "type": "github" }, "original": { "owner": "nix-community", - "ref": "v0.4.1", + "ref": "v0.4.2", "repo": "lanzaboote", "type": "github" } @@ -857,7 +853,7 @@ "inputs": { "niri-stable": "niri-stable", "niri-unstable": "niri-unstable", - "nixpkgs": "nixpkgs_8", + "nixpkgs": "nixpkgs_9", "nixpkgs-stable": "nixpkgs-stable_3", "xwayland-satellite-stable": "xwayland-satellite-stable", "xwayland-satellite-unstable": "xwayland-satellite-unstable" @@ -927,7 +923,7 @@ "nix-gaming": { "inputs": { "flake-parts": "flake-parts_5", - "nixpkgs": "nixpkgs_9", + "nixpkgs": "nixpkgs_10", "umu": "umu" }, "locked": { @@ -1092,6 +1088,22 @@ } }, "nixpkgs_10": { + "locked": { + "lastModified": 1737003892, + "narHash": "sha256-RCzJE9wKByLCXmRBp+z8LK9EgdW+K+W/DXnJS4S/NVo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ae06b9c2d83cb5c8b12d7d0e32692e93d1379713", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_11": { "locked": { "lastModified": 1736916166, "narHash": "sha256-puPDoVKxkuNmYIGMpMQiK8bEjaACcCksolsG36gdaNQ=", @@ -1107,7 +1119,7 @@ "type": "github" } }, - "nixpkgs_11": { + "nixpkgs_12": { "locked": { "lastModified": 1734424634, "narHash": "sha256-cHar1vqHOOyC7f1+tVycPoWTfKIaqkoe1Q6TnKzuti4=", @@ -1123,7 +1135,7 @@ "type": "github" } }, - "nixpkgs_12": { + "nixpkgs_13": { "locked": { "lastModified": 1738410390, "narHash": "sha256-xvTo0Aw0+veek7hvEVLzErmJyQkEcRk6PSR4zsRQFEc=", @@ -1236,6 +1248,22 @@ } }, "nixpkgs_8": { + "locked": { + "lastModified": 1738452225, + "narHash": "sha256-Qmwx3FXM0x0pdjibwTk/uRbayqDrs3EwmRJe7tQWu48=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6c4e0724e0a785a20679b1bca3a46bfce60f05b6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_9": { "locked": { "lastModified": 1736798957, "narHash": "sha256-qwpCtZhSsSNQtK4xYGzMiyEDhkNzOCz/Vfu4oL2ETsQ=", @@ -1251,22 +1279,6 @@ "type": "github" } }, - "nixpkgs_9": { - "locked": { - "lastModified": 1737003892, - "narHash": "sha256-RCzJE9wKByLCXmRBp+z8LK9EgdW+K+W/DXnJS4S/NVo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "ae06b9c2d83cb5c8b12d7d0e32692e93d1379713", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "pre-commit-hooks-nix": { "inputs": { "flake-compat": [ @@ -1314,7 +1326,7 @@ "nix-gaming": "nix-gaming", "nixos-hardware": "nixos-hardware", "nixos-m1": "nixos-m1", - "nixpkgs": "nixpkgs_10", + "nixpkgs": "nixpkgs_11", "nixpkgs-unstable": "nixpkgs-unstable", "rust-overlay": "rust-overlay_3", "secrets": "secrets", @@ -1342,10 +1354,7 @@ }, "rust-overlay": { "inputs": { - "flake-utils": [ - "lanzaboote", - "flake-utils" - ], + "flake-utils": "flake-utils_5", "nixpkgs": [ "lanzaboote", "nixpkgs" @@ -1663,7 +1672,7 @@ "inputs": { "crane": "crane_5", "flake-utils": "flake-utils_9", - "nixpkgs": "nixpkgs_11", + "nixpkgs": "nixpkgs_12", "rust-overlay": "rust-overlay_4" }, "locked": { @@ -1683,7 +1692,7 @@ }, "zen-browser": { "inputs": { - "nixpkgs": "nixpkgs_12" + "nixpkgs": "nixpkgs_13" }, "locked": { "lastModified": 1738469108, diff --git a/flake.nix b/flake.nix index 95db841..2192d0b 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ # --- Secure boot lanzaboote = { - url = "github:nix-community/lanzaboote/v0.4.1"; + url = "github:nix-community/lanzaboote/v0.4.2"; inputs.nixpkgs.follows = "nixpkgs"; }; -- 2.47.2 From 8aa7c77fd05df00aa910e4422d1ad9485517d7d3 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 4 Feb 2025 04:24:29 +0100 Subject: [PATCH 29/41] Enable templ lsp --- packages/common/nki-kakoune/lsp.nix | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix index eb62e0c..297a449 100644 --- a/packages/common/nki-kakoune/lsp.nix +++ b/packages/common/nki-kakoune/lsp.nix @@ -16,6 +16,7 @@ , texlab , tinymist , marksman +, templ , rust-analyzer , ... }: @@ -33,12 +34,12 @@ let languageServers = let - vscodeServerOf = name: { + vscodeServerWith = { name, extraFileTypes ? [ ] }: { name = "vscode-${name}-language-server"; value = { args = [ "--stdio" ]; command = "vscode-${name}-language-server"; - filetypes = [ name "templ" ]; + filetypes = [ name ] ++ extraFileTypes; roots = [ "package.json" ".git" ]; package = nodePackages.vscode-langservers-extracted; }; @@ -187,6 +188,13 @@ let roots = [ ".marksman.toml" ".git" ]; package = marksman; }; + templ = { + command = "templ"; + args = [ "lsp" ]; + filetypes = [ "templ" ]; + roots = [ "go.mod" ".git" ]; + package = templ; + }; rust-analyzer = { args = [ ]; command = "rust-analyzer"; @@ -195,7 +203,11 @@ let package = rust-analyzer; }; - } // (builtins.listToAttrs (builtins.map vscodeServerOf [ "html" "css" "json" ])); + } // (builtins.listToAttrs (builtins.map + (ft: vscodeServerWith { + name = ft; + extraFileTypes = if ft == "json" then [ ] else [ "templ" ]; + }) [ "html" "css" "json" ])); faces = [ ## Items -- 2.47.2 From 32e723996b4d3bb0f2a3c57b697a0dba5559dd22 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 15 Feb 2025 13:46:23 +0100 Subject: [PATCH 30/41] kak-lsp: update to 18.1.2 --- flake.lock | 8 ++++---- flake.nix | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 73f497c..2d14814 100644 --- a/flake.lock +++ b/flake.lock @@ -737,16 +737,16 @@ "kak-lsp": { "flake": false, "locked": { - "lastModified": 1734533380, - "narHash": "sha256-7ULohcCpIKOb7CtsF2dIkiRt94uBIrGD5pQ2AEfrNrY=", + "lastModified": 1737458684, + "narHash": "sha256-wIKAChmD6gVfrRguywiAnpT3kbCbRk2k2u4ckd1CNOw=", "owner": "kakoune-lsp", "repo": "kakoune-lsp", - "rev": "dc348f04038f7286d606e99719509d6dbd2469da", + "rev": "d5db3de3b88a8a158e1bfa43f13d8766a6c6d522", "type": "github" }, "original": { "owner": "kakoune-lsp", - "ref": "v18.1.1", + "ref": "v18.1.2", "repo": "kakoune-lsp", "type": "github" } diff --git a/flake.nix b/flake.nix index 2192d0b..bb13c06 100644 --- a/flake.nix +++ b/flake.nix @@ -55,7 +55,7 @@ # --- Sources kakoune.url = "github:mawww/kakoune"; kakoune.flake = false; - kak-lsp.url = "github:kakoune-lsp/kakoune-lsp/v18.1.1"; + kak-lsp.url = "github:kakoune-lsp/kakoune-lsp/v18.1.2"; kak-lsp.flake = false; nixos-m1.url = "github:tpwrules/nixos-apple-silicon"; nixos-m1.inputs.nixpkgs.follows = "nixpkgs"; -- 2.47.2 From 718f44aa006cbd267b92fc1b244ba53f1d984ec9 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 21 Jan 2025 11:22:22 +0100 Subject: [PATCH 31/41] Temporary skip vikunja update --- flake.lock | 6 +++--- overlay.nix | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index 2d14814..995ebaf 100644 --- a/flake.lock +++ b/flake.lock @@ -1676,11 +1676,11 @@ "rust-overlay": "rust-overlay_4" }, "locked": { - "lastModified": 1735912896, - "narHash": "sha256-jJQfnP7XhTGlCvUIgxIKDipIkif/AmOk6SgSuD5qils=", + "lastModified": 1737051126, + "narHash": "sha256-RXdUcprutFE53CwSyimRsiodETsCz6nrarJlh1aMD/M=", "owner": "natsukagami", "repo": "youmubot", - "rev": "dde4a722a07ba6ad814b3792ae1361139be1e973", + "rev": "2f49f09a279f9cc20e2ea1dc312e213442cc7bf3", "type": "github" }, "original": { diff --git a/overlay.nix b/overlay.nix index e776500..cad74ce 100644 --- a/overlay.nix +++ b/overlay.nix @@ -72,9 +72,9 @@ let }); vikunja = - builtins.seq - (final.lib.assertMsg (prev.vikunja.version == "0.24.5") "Vikunja probably doesn't need custom versions anymore") - (final.callPackage ./packages/common/vikunja.nix { }); + # builtins.seq + # (final.lib.assertMsg (prev.vikunja.version == "0.24.5") "Vikunja probably doesn't need custom versions anymore") + (final.callPackage ./packages/common/vikunja.nix { }); luminance = prev.luminance.overrideAttrs (attrs: { nativeBuildInputs = attrs.nativeBuildInputs ++ [ final.wrapGAppsHook ]; -- 2.47.2 From d425bde1a1e217efa5e5394fb46aca5ff756f64a Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 15 Feb 2025 13:46:52 +0100 Subject: [PATCH 32/41] Update gotosocial --- modules/cloud/authentik/default.nix | 1 + overlay.nix | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/cloud/authentik/default.nix b/modules/cloud/authentik/default.nix index 74d7f61..9c51f39 100644 --- a/modules/cloud/authentik/default.nix +++ b/modules/cloud/authentik/default.nix @@ -52,6 +52,7 @@ in serviceConfig.EnvironmentFile = cfg.envFile; serviceConfig.Type = "notify"; serviceConfig.NotifyAccess = "all"; + serviceConfig.TimeoutSec = 300; script = lib.mkBefore '' ${lib.getExe pkgs.wait4x} http http://127.0.0.1:${toString cfg.port} --expect-status-code 200 -t 0 -q -- systemd-notify --ready & ''; diff --git a/overlay.nix b/overlay.nix index cad74ce..1f43a8d 100644 --- a/overlay.nix +++ b/overlay.nix @@ -22,7 +22,7 @@ let overlay-versioning = final: prev: { gotosocial = prev.gotosocial.overrideAttrs (attrs: rec { - version = "0.17.1"; + version = "0.18.0-rc2"; ldflags = [ "-s" "-w" @@ -32,13 +32,13 @@ let web-assets = final.fetchurl { url = "https://github.com/superseriousbusiness/gotosocial/releases/download/v${version}/gotosocial_${version}_web-assets.tar.gz"; - hash = "sha256-rGntLlIbgfCtdqpD7tnvAY8qwF+BpYbQWfAGMhdOTgY="; + hash = "sha256-VX6ewG2fOKdzgm7FOd+Q+YmRt9oz+HcvDCoxnmijTO8="; }; src = final.fetchFromGitHub { owner = "superseriousbusiness"; repo = "gotosocial"; rev = "v${version}"; - hash = "sha256-oWWsCs9jgd244yzWhgLkuHp7kY0BQ8+Ay6KpuBVG+U8="; + hash = "sha256-XZLi4axYZNg90XGtFYK3l++kbxvZUYyq2PEsVXp20FE="; }; postInstall = '' tar xf ${web-assets} -- 2.47.2 From dd75a5b5ee445664862be9f9fd4636911b9f3179 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 15 Feb 2025 18:52:19 +0100 Subject: [PATCH 33/41] phanpy: update --- flake.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index 995ebaf..f76af9f 100644 --- a/flake.lock +++ b/flake.lock @@ -211,11 +211,11 @@ "nixpkgs": "nixpkgs_7" }, "locked": { - "lastModified": 1731494335, - "narHash": "sha256-G1G2WRGgIOFNmlJglfqEupSg0VWHgODbBJzp5xo+cYY=", + "lastModified": 1739632357, + "narHash": "sha256-aqLiDoLaqYdZIEgR7NGavo4KPbOYOhU7vuCDXe1uL5Y=", "ref": "dtth-fork", - "rev": "c414bb78f27b20df4463c36a5851c94cfe9c79b0", - "revCount": 3367, + "rev": "30979814a9dbbf590d4d954e559811e6a7504459", + "revCount": 3476, "type": "git", "url": "ssh://gitea@git.dtth.ch/nki-dtth/phanpy" }, -- 2.47.2 From 5aba8092bdf324e2504fcdebb96de04e2a30694f Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 20 Feb 2025 20:08:28 +0100 Subject: [PATCH 34/41] Update nixpkgs --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index f76af9f..119f58a 100644 --- a/flake.lock +++ b/flake.lock @@ -721,11 +721,11 @@ ] }, "locked": { - "lastModified": 1738448366, - "narHash": "sha256-4ATtQqBlgsGqkHTemta0ydY6f7JBRXz4Hf574NHQpkg=", + "lastModified": 1739571712, + "narHash": "sha256-0UdSDV/TBY+GuxXLbrLq3l2Fq02ciyKCIMy4qmnfJXQ=", "owner": "nix-community", "repo": "home-manager", - "rev": "18fa9f323d8adbb0b7b8b98a8488db308210ed93", + "rev": "6d3163aea47fdb1fe19744e91306a2ea4f602292", "type": "github" }, "original": { @@ -1073,11 +1073,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1738452225, - "narHash": "sha256-Qmwx3FXM0x0pdjibwTk/uRbayqDrs3EwmRJe7tQWu48=", + "lastModified": 1739451785, + "narHash": "sha256-3ebRdThRic9bHMuNi2IAA/ek9b32bsy8F5R4SvGTIog=", "owner": "nixos", "repo": "nixpkgs", - "rev": "6c4e0724e0a785a20679b1bca3a46bfce60f05b6", + "rev": "1128e89fd5e11bb25aedbfc287733c6502202ea9", "type": "github" }, "original": { -- 2.47.2 From a1cc06cfea1a6e2ed2f098d50581413461ad6999 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 21 Feb 2025 02:43:06 +0100 Subject: [PATCH 35/41] Update youmubot --- flake.lock | 7 +++---- flake.nix | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 119f58a..1ddbaec 100644 --- a/flake.lock +++ b/flake.lock @@ -1676,16 +1676,15 @@ "rust-overlay": "rust-overlay_4" }, "locked": { - "lastModified": 1737051126, - "narHash": "sha256-RXdUcprutFE53CwSyimRsiodETsCz6nrarJlh1aMD/M=", + "lastModified": 1740088478, + "narHash": "sha256-olqbNvJ5Uk1LseAC1zYDSL0BPLhPxkQG8EhO/3zhKRw=", "owner": "natsukagami", "repo": "youmubot", - "rev": "2f49f09a279f9cc20e2ea1dc312e213442cc7bf3", + "rev": "a35563801dbf74c6f221aac3e70146572e3fe14e", "type": "github" }, "original": { "owner": "natsukagami", - "ref": "osu-commands", "repo": "youmubot", "type": "github" } diff --git a/flake.nix b/flake.nix index bb13c06..d9edba7 100644 --- a/flake.nix +++ b/flake.nix @@ -37,7 +37,7 @@ # --- # Imported apps - youmubot.url = "github:natsukagami/youmubot/osu-commands"; + youmubot.url = "github:natsukagami/youmubot"; # swayfx = { # url = github:WillPower3309/swayfx; # inputs.nixpkgs.follows = "nixpkgs"; -- 2.47.2 From c2a0236c41356a6ba83f258e4b24f592e42bf395 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 21 Feb 2025 02:43:13 +0100 Subject: [PATCH 36/41] Update osu --- home/osu.nix | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/home/osu.nix b/home/osu.nix index e64424a..705f271 100644 --- a/home/osu.nix +++ b/home/osu.nix @@ -1,28 +1,28 @@ { pkgs, lib, ... }: let - osu-pkg = pkgs.unstable.osu-lazer-bin; - # osu-pkg = with pkgs; with lib; - # appimageTools.wrapType2 rec { - # pname = "osu-lazer-bin"; - # version = "2025.101.0"; - # src = fetchurl { - # url = "https://github.com/ppy/osu/releases/download/${version}/osu.AppImage"; - # hash = "sha256-GsnTxVpNk2RXHLET6Ugv0/ZOlq8RUkw2ZXqRjkU+dzw="; - # }; - # extraPkgs = pkgs: with pkgs; [ icu ]; + # osu-pkg = pkgs.unstable.osu-lazer-bin; + osu-pkg = with pkgs; with lib; + appimageTools.wrapType2 rec { + pname = "osu-lazer-bin"; + version = "2025.221.0"; + src = fetchurl { + url = "https://github.com/ppy/osu/releases/download/${version}/osu.AppImage"; + hash = "sha256-V6JJShVGE4GXGI8FvDhyWuHUnlI+p3JLW/NN+u+Vikc="; + }; + extraPkgs = pkgs: with pkgs; [ icu ]; - # extraInstallCommands = - # let contents = appimageTools.extract { inherit pname version src; }; - # in - # '' - # mv -v $out/bin/${pname} $out/bin/osu\! - # install -m 444 -D ${contents}/osu\!.desktop -t $out/share/applications - # for i in 16 32 48 64 96 128 256 512 1024; do - # install -D ${contents}/osu.png $out/share/icons/hicolor/''${i}x$i/apps/osu.png - # done - # ''; - # }; + extraInstallCommands = + let contents = appimageTools.extract { inherit pname version src; }; + in + '' + mv -v $out/bin/${pname} $out/bin/osu\! + install -m 444 -D ${contents}/osu\!.desktop -t $out/share/applications + for i in 16 32 48 64 96 128 256 512 1024; do + install -D ${contents}/osu.png $out/share/icons/hicolor/''${i}x$i/apps/osu.png + done + ''; + }; in { home.packages = [ osu-pkg ]; -- 2.47.2 From 43dfa8b845ec05383bc6abd677edf37f3dda74ea Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 21 Feb 2025 02:43:28 +0100 Subject: [PATCH 37/41] Seems like kak-tree-sitter has overwritten the tag --- packages/common/kak-tree-sitter/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common/kak-tree-sitter/default.nix b/packages/common/kak-tree-sitter/default.nix index 9819e3a..3894888 100644 --- a/packages/common/kak-tree-sitter/default.nix +++ b/packages/common/kak-tree-sitter/default.nix @@ -11,7 +11,7 @@ let inherit src; pname = "kak-tree-sitter"; version = "1.1.2"; - cargoHash = "sha256-OQPUWqJAts8DbFNSsC/CmMCbuZ9TVxRTR05O7oiodKI="; + cargoHash = "sha256-ruHklps7NZzsI1ub1trRKyufrP9tufWWrQ+urvEsIdA="; cargoBuildOptions = [ "--package" "kak-tree-sitter" "--package" "ktsctl" ]; nativeBuildInputs = [ clang git ]; -- 2.47.2 From 20287ca12f5265ed2070f6fd50368bed745c3d21 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 21 Feb 2025 12:57:46 +0100 Subject: [PATCH 38/41] vesktop: properly replace text-input flags across nixpkgses --- overlay.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/overlay.nix b/overlay.nix index 1f43a8d..4d33dea 100644 --- a/overlay.nix +++ b/overlay.nix @@ -85,7 +85,11 @@ let }); vesktop = prev.vesktop.overrideAttrs (attrs: { - postFixup = builtins.replaceStrings [ "NIXOS_OZONE_WL" "--enable-wayland-ime=true" ] [ "WAYLAND_DISPLAY" "--enable-wayland-ime=true --wayland-text-input-version=3" ] attrs.postFixup; + postFixup = + let + flagToReplace = if final.lib.hasInfix "--enable-wayland-ime=true" attrs.postFixup then "--enable-wayland-ime=true" else "--enable-wayland-ime"; + in + builtins.replaceStrings [ "NIXOS_OZONE_WL" flagToReplace ] [ "WAYLAND_DISPLAY" "${flagToReplace} --wayland-text-input-version=3" ] attrs.postFixup; }); }; -- 2.47.2 From 0ada1ba34fa9f5e578b485902df22e1f18e7d2ad Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 15 Feb 2025 14:45:40 +0100 Subject: [PATCH 39/41] kak-lsp: build with rustPlatform.buildRustApplication --- overlay.nix | 29 ++++++++++++--------- packages/common/kak-tree-sitter/default.nix | 8 +++--- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/overlay.nix b/overlay.nix index 4d33dea..71c70bd 100644 --- a/overlay.nix +++ b/overlay.nix @@ -100,19 +100,24 @@ let overlay-packages = final: prev: { kak-tree-sitter = final.callPackage ./packages/common/kak-tree-sitter { rustPlatform = final.unstable.rustPlatform; }; - kak-lsp = - let - src = inputs.kak-lsp; - cargoArtifacts = final.libs.crane.buildDepsOnly { inherit src; }; - in - final.libs.crane.buildPackage { - inherit src cargoArtifacts; - buildInputs = (with final; - lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Security SystemConfiguration CoreServices ]) - ) ++ (with final; [ libiconv ]); + kak-lsp = final.rustPlatform.buildRustPackage { + name = "kak-lsp"; + src = inputs.kak-lsp; + cargoHash = "sha256-U9KxTHzIDtdJ3A62rcdvWlxJfnhbFnS6KDRaV0HJOHE="; + buildInputs = [ final.libiconv ]; - meta.mainProgram = "kak-lsp"; - }; + meta.mainProgram = "kak-lsp"; + }; + # cargoArtifacts = final.libs.crane.buildDepsOnly { inherit src; }; + # in + # final.libs.crane.buildPackage { + # inherit src cargoArtifacts; + # buildInputs = (with final; + # lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Security SystemConfiguration CoreServices ]) + # ) ++ (with final; [ libiconv ]); + + # meta.mainProgram = "kak-lsp"; + # }; zen-browser-bin = inputs.zen-browser.packages.${final.stdenv.system}.zen-browser.override { inherit (inputs.zen-browser.packages.${final.stdenv.system}) zen-browser-unwrapped; diff --git a/packages/common/kak-tree-sitter/default.nix b/packages/common/kak-tree-sitter/default.nix index 3894888..ff395ff 100644 --- a/packages/common/kak-tree-sitter/default.nix +++ b/packages/common/kak-tree-sitter/default.nix @@ -3,15 +3,15 @@ let src = fetchFromSourcehut { owner = "~hadronized"; repo = "kak-tree-sitter"; - rev = "kak-tree-sitter-v1.1.2"; - hash = "sha256-wBWfSyR8LGtug/mCD0bJ4lbdN3trIA/03AnCxZoEOSA="; + rev = "kak-tree-sitter-v1.1.3"; + hash = "sha256-vQZ+zQgwIw5ZBdIuMDD37rIdhe+WpNBmq0TciXBNiSU="; }; kak-tree-sitter = rustPlatform.buildRustPackage { inherit src; pname = "kak-tree-sitter"; - version = "1.1.2"; - cargoHash = "sha256-ruHklps7NZzsI1ub1trRKyufrP9tufWWrQ+urvEsIdA="; + version = "1.1.3"; + cargoHash = "sha256-1OwPfl1446SYt1556jwR9mvWOWEv+ab+wH7GZQeS4/E="; cargoBuildOptions = [ "--package" "kak-tree-sitter" "--package" "ktsctl" ]; nativeBuildInputs = [ clang git ]; -- 2.47.2 From c678fc9009206438a5badb960641143d8bba67db Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 22 Feb 2025 15:40:03 +0100 Subject: [PATCH 40/41] framework: move default browser to zen --- flake.nix | 1 + home/nki-framework.nix | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index d9edba7..448036a 100644 --- a/flake.nix +++ b/flake.nix @@ -114,6 +114,7 @@ sops-nix.nixosModules.sops inputs.lix-module.nixosModules.default ]; + config.nix.settings.extra-deprecated-features = [ "url-literals" ]; # So lix won't complain }; common-nixos = stable: { ... }: { imports = [ diff --git a/home/nki-framework.nix b/home/nki-framework.nix index bddea4a..699512d 100644 --- a/home/nki-framework.nix +++ b/home/nki-framework.nix @@ -29,7 +29,8 @@ # Graphical set up linux.graphical.type = "wayland"; linux.graphical.wallpaper = ./images/wallpaper_0.png; - linux.graphical.defaults.webBrowser.package = pkgs.librewolf; + linux.graphical.defaults.webBrowser.package = pkgs.zen-browser-bin; + linux.graphical.defaults.webBrowser.desktopFile = "zen.desktop"; # Enable sway programs.my-sway.enable = true; programs.my-sway.fontSize = 14.0; -- 2.47.2 From f9c6056b74346836587e5df7ae12bafadde93957 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 22 Feb 2025 15:46:14 +0100 Subject: [PATCH 41/41] gotosocial: update to 0.18.0-rc3 --- overlay.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/overlay.nix b/overlay.nix index 71c70bd..81bb8f4 100644 --- a/overlay.nix +++ b/overlay.nix @@ -22,7 +22,7 @@ let overlay-versioning = final: prev: { gotosocial = prev.gotosocial.overrideAttrs (attrs: rec { - version = "0.18.0-rc2"; + version = "0.18.0-rc3"; ldflags = [ "-s" "-w" @@ -32,13 +32,13 @@ let web-assets = final.fetchurl { url = "https://github.com/superseriousbusiness/gotosocial/releases/download/v${version}/gotosocial_${version}_web-assets.tar.gz"; - hash = "sha256-VX6ewG2fOKdzgm7FOd+Q+YmRt9oz+HcvDCoxnmijTO8="; + hash = "sha256-qbhUsH9F7xteRVg9c9y/iVrtir1vhCOL3v6CsDsMblg="; }; src = final.fetchFromGitHub { owner = "superseriousbusiness"; repo = "gotosocial"; rev = "v${version}"; - hash = "sha256-XZLi4axYZNg90XGtFYK3l++kbxvZUYyq2PEsVXp20FE="; + hash = "sha256-BYGkuLYwJtV2FSfr0MQKMpwCddTWMfbYUXqP7SZCv1A="; }; postInstall = '' tar xf ${web-assets} -- 2.47.2