This commit is contained in:
Charlie Root 2024-10-28 21:52:16 +01:00
commit e0a7e9a533
Signed by: faukah
SSH key fingerprint: SHA256:jpYIt4Vkz1NBTQcks/N9OPTfTFxE6KF2W/rV7hrfrIw
13 changed files with 451 additions and 4 deletions

View file

@ -4,6 +4,6 @@ _: {
./system.nix
./xdg.nix
./git.nix
/users.nix
./users.nix
];
}

View file

@ -14,9 +14,9 @@ in {
"audio"
"nix"
];
hashedPasswordFile = "/etc/passwords/cr";
# hashedPasswordFile = "/etc/passwords/cr";
};
root.hashedPasswordFile = "/persist/passwords/root";
# root.hashedPasswordFile = "/persist/passwords/root";
};
};
}

View file

@ -66,6 +66,54 @@ in {
auto-format = true;
language-servers = ["dprint" "typescript-language-server"];
}
{
name = "rust";
debugger = {
command = "${pkgs.lldb_19}/bin/lldb-dap";
name = "lldb";
transport = "stdio";
templates = [
{
name = "binary";
request = "launch";
completion = [
{
name = "binary";
completion = "filename";
}
];
args = {
program = "{0}";
runInTerminal = true;
};
}
];
};
}
{
name = "c";
debugger = {
name = "gdb";
command = "${pkgs.gdb}/bin/gdb";
transport = "stdio";
templates = [
{
name = "binary";
request = "launch";
completion = [
{
name = "binary";
completion = "filename";
}
];
args = {
program = "{0}";
runInTerminal = true;
};
}
];
};
}
];
language-server = {

View file

@ -0,0 +1,66 @@
{
config,
lib,
pkgs,
...
}: let
inherit (config.modules.other.system) username;
cfg = config.modules.system.programs.editors.kakoune;
inherit (lib) mkIf mkEnableOption;
in {
imports = [./mappings.nix];
options.modules.editors.kakoune.enable = mkEnableOption "kakoune";
config.home-manager.users.${username}.programs.kakoune = mkIf cfg.enable {
enable = true;
package = pkgs.kakoune-unwrapped;
config = {
autoComplete = ["insert"];
autoReload = "yes";
indentWidth = 4;
tabStop = 4;
incrementalSearch = false;
numberLines = {
enable = true;
relative = true;
highlightCursor = true;
separator = "|";
};
scrollOff = {
lines = 4;
columns = 4;
};
wrapLines = {
enable = true;
indent = true;
word = true;
};
ui = {
enableMouse = true;
assistant = "none";
statusLine = "bottom";
};
};
plugins = with pkgs.kakounePlugins; [
active-window-kak
auto-pairs-kak
byline-kak # ope
prelude-kak # dependency of byline
fzf-kak
kakboard
kakoune-buffer-switcher
kakoune-buffers
kakoune-lsp
kakoune-rainbow
kakoune-registers
kakoune-vertical-selection
powerline-kak
quickscope-kak
smarttab-kak
zig-kak
];
# extraConfig = ./kakrc;
};
}

View file

@ -0,0 +1,18 @@
[language.haskell]
filetypes = ["haskell"]
roots = ["Setup.hs", "stack.yaml", "*.cabal"]
command = "haskell-language-server-wrapper"
args = ["--lsp"]
[language.rust]
filetypes = ["rust"]
roots = ["Cargo.toml"]
command = "rust-analyzer"
settings_section = "rust-analyzer"
[language.rust.settings.rust-analyzer]
"proMacro.enable" = true
[language.nix]
filetypes = ["nix"]
roots = ["shell.nix", "default.nix", "home.nix", "flake.nix"]
command = "rnix-lsp"

View file

@ -0,0 +1,135 @@
{
config,
lib,
pkgs,
buildGoModule,
...
}:
with lib; let
cfg = config.modules.programs.kakoune;
username = config.modules.other.system.username;
kakship = pkgs.rustPlatform.buildRustPackage rec {
pname = "kakship";
version = "0.2.8";
src = pkgs.fetchFromGitHub {
owner = "mesabloo";
repo = "kakship";
rev = "937d904a893daf59f70dc955e60209cd8866a7c3";
sha256 = "1pk0v0b31bppjzl08qgrjld40pc7rqc257zzgdl4r8zaamqsmkz9";
};
cargoLock = {
lockFile = "${src}/Cargo.lock";
outputHashes = {
"kak-0.1.2" = "sha256-RhtHQkC9yCSJtr/kbC5c9MavbL79acrsiEGXyoAST8U=";
"yew-ansi-0.1.0" = "sha256-dSaEzqiOon+OqCZKQudzLRNP+Iv97kC+XZcTElKNrzs=";
};
};
# patchPhase = ''
# substituteInPlace src/main.rs \
# --replace '"starship"' "\"${pkgs.starship}/bin/starship\""
# '';
postInstall = ''
# Copy rc files to /share/kak/autoload
mkdir -p $out/share/kak/autoload/plugins/${pname}
cp $src/rc/*.kak $out/share/kak/autoload/plugins/${pname}
'';
};
kak-rainbow = pkgs.kakouneUtils.buildKakounePluginFrom2Nix rec {
pname = "kak-rainbow";
version = "1.0.0";
src = pkgs.fetchFromGitHub {
owner = "Bodhizafa";
repo = "kak-rainbow";
rev = "9c3d0aa62514134ee5cb86e80855d9712c4e8c4b";
sha256 = "sha256-ryYq4A89wVUsxgvt4YqBPXsTFMDrMJM6BDBEHrWHD1c=";
};
postInstall = ''
mkdir -p $out/lib
mv $out/share/kak/autoload/plugins/${pname}/rainbow.kak $out/lib
cat >$out/share/kak/autoload/plugins/${pname}/rainbow.kak <<EOF
provide-module rainbow %{
source $out/lib/rainbow.kak
}
EOF
'';
};
kks = pkgs.buildGoModule rec {
pname = "kks";
version = "8113ea3";
src = pkgs.fetchFromGitHub {
owner = "kkga";
repo = pname;
rev = "8113ea3bd718dec88b812faa1a41bacba0110fd7";
sha256 = "sha256-/0ocgWArELGQkOZqbYRljPnzM/zQ9HCZq7gqhMD0Mq4=";
};
vendorHash = "sha256-E4D9FGTpS9NkZy6tmnuI/F4dnO9bv8MVaRstxVPvEfo=";
doCheck = false;
meta = with lib; {
description = "Handy Kakoune companion.";
homepage = "https://github.com/kkga/kks";
license = licenses.unfree;
maintainers = with maintainers; [kalbasit];
};
};
kak-alacritty = pkgs.kakouneUtils.buildKakounePluginFrom2Nix rec {
pname = "alacritty.kak";
version = "10025b8";
src = pkgs.fetchFromGitHub {
owner = "Lokasku";
repo = pname;
rev = "66b0d2e2451c01719262effd008c40614427bb35";
sha256 = "sha256-Ibjs6dCU8/XEjUoWNB5a8R4QW7z8w6cFBSxd7UvZrxE=";
};
};
kakoune-snow = pkgs.kakouneUtils.buildKakounePluginFrom2Nix rec {
pname = "kakoune-snow";
version = "35f8187";
src = pkgs.fetchFromGitHub {
owner = "caksoylar";
repo = pname;
rev = "35f81876bcaea061982396f8071b89528940ae61";
sha256 = "";
};
};
# with lib;
in {
options.modules.programs.kakoune.enable = mkEnableOption "kakoune";
config = mkIf cfg.enable {
home-manager.users.${username} = {programs.kakoune.enable = true;};
environment.systemPackages = with pkgs; [
rust-analyzer
rustfmt # Rust LSP
kakship
kks
];
programs.kakoune = {
plugins = with pkgs.kakounePlugins; [
kakoune-lsp
fzf-kak
kak-rainbow
kak-alacritty
];
config = {
numberLines = {
enable = true;
# separator = "|";
};
scrollOff = {
columns = 15;
lines = 15;
};
};
extraConfig = builtins.readFile ./kakrc;
};
xdg.configFile."kak/starship.toml".source = ./starship.toml;
xdg.configFile."kak-lsp/kak-lsp.toml".source = ./kak-lsp.toml;
};
}

View file

@ -0,0 +1,88 @@
# --- kks
eval %sh{ kks init }
# --- kak-lsp
eval %sh{kak-lsp --kakoune -s $kak_session}
hook global WinCreate .* %{
lsp-inlay-hints-enable window
lsp-auto-signature-help-enable
}
hook global WinSetOption filetype=(nix|haskell) %{
lsp-enable-window
}
set-option global lsp_completion_trigger "execute-keys 'h<a-h><a-k>\S[^\h\n,=;*(){}\[\]]\z<ret>'"
set-option global lsp_diagnostic_line_error_sign "!"
set-option global lsp_diagnostic_line_warning_sign "?"
hook global WinSetOption filetype=(rust) %{
map window user "l" ':enter-user-mode lsp<ret>' -docstring "LSP mode"
lsp-enable-window
lsp-auto-hover-insert-mode-disable
set-option window lsp_hover_anchor true
set-face window DiagnosticError default+u
set-face window DiagnosticWarning default+u
set-option window lsp_server_configuration rust.clippy_preference="on"
}
# hook global WinSetOption filetype=rust %{
# lsp-enable-window hook window BufWritePre .* lsp-formatting-sync
# hook window -group rust-inlay-hints BufWritePost .* rust-analyzer-inlay-hints
# hook -once -always window WinSetOption filetype=.* %{
# remove-hooks window rust-inlay-hints
# }
# }
map global normal <a-d> ':lsp-definition<ret>'
# --- kakoune-rainbow
hook global ModuleLoaded rainbow %{
set-option global rainbow_colors rgb:FF3B2F+db rgb:FF9500+db rgb:FFCC02+db rgb:27cd41+db rgb:007AFF+db rgb:AF52DE+db
hook global WinSetOption filetype=(rust|python|c|cpp|scheme|lisp|clojure|javascript|json|kak|haskell|python|latex|nix) %{
rainbow-enable-window
}
}
# --- alacritty.kak
hook global ModuleLoaded x11 %{
alias global terminal kitty-terminal
alias global popup alacritty-terminal-popup
}
# --- Kakship
hook global ModuleLoaded kakship %{
kakship-enable
}
# --- Broot
define-command -override broot-oneoff-select -docstring 'focus broot' %{
evaluate-commands %sh{
d="$(dirname "$kak_buffile")"
b="$(basename "$kak_buffile")"
echo echo -debug "$d"
broot_cmd="broot"
if [ -d "$d" ]; then
broot_cmd="$broot_cmd --cmd \":focus $d;:select $b\""
fi
echo "kks-connect ala-popup sh -c '""kks send edit $broot_cmd""'"
}
}
define-command ala-popup -params .. -shell-completion -docstring 'alacritty-terminal-popup <program> [arguments]: create a new terminal as an Alacritty window (class: popup, app_id: popup)' %{
nop %sh{
setsid alacritty -o window.dimensions.columns=200 window.dimensions.lines=57 --title popup --class 'alacritty-popup' --command "$@" < /dev/null > /dev/null 2>&1 &
}
}
# --- Map
map global normal <c-f> ':fzf-mode<ret>f<ret>'
map global normal <c-t> ':alacritty-popup<ret>'
require-module fzf
set-option global fzf_terminal_command 'ala-popup kak -c %val{session} -e "%arg{@}"'
require-module alacritty
require-module rainbow

View file

@ -0,0 +1,48 @@
{
config,
lib,
pkgs,
...
}: let
inherit (config.modules.other.system) username;
in {
config.home-manager.users.${username}.programs.kakoune.config.keyMappings = [
{
mode = "normal";
key = "<esc>";
effect = ";,";
docstring = "Press escape to clear highlighted text and collapse cursors";
}
{
mode = "normal";
key = "<c-v>";
effect = ":comment-line<ret>";
docstring = "Comment a line with <c-v>!";
}
{
mode = "normal";
key = "b";
effect = ":db<ret>";
docstring = "close current buffer";
}
{
mode = "normal";
key = "n";
effect = ":bp<ret>";
docstring = "go to next buffer";
}
{
mode = "normal";
key = "m";
effect = ":bn<ret>";
docstring = "go to next buffer";
}
{
mode = "normal";
key = " f";
effect = ":fzf-mode<ret>";
docstring = "open fzf";
}
];
}

View file

@ -0,0 +1,20 @@
# add_newline = false
format = """
\$directory
\${custom.separator}
"""
[directory]
format = '[$path/]($style)'
truncate_length = 2
truncate_to_repo = false
use_logical_pat = true
style = "fg:cyan"
truncate_symbol = "../"
disabled = false
[custom.separator]
format = "[ ||| ]($style)"
style = "fg:purple"
disabled = false

View file

@ -0,0 +1,5 @@
_: {
imports = [
./kakoune
];
}