From addf3118528d4889d07eb29d1e1561efd172b6f9 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Sun, 19 May 2024 16:01:09 +0200 Subject: [PATCH] added some kakoune stuff --- README.md | 1 + modules/gui/default.nix | 2 +- modules/gui/kakoune.nix | 59 ++++++++++++-- modules/gui/kakoune/default.nix | 1 + modules/gui/kakoune/kak-lsp.toml | 18 ++++ modules/gui/kakoune/kakoune.nix | 131 ++++++++++++++++++++++++++++++ modules/gui/kakoune/kakrc | 88 ++++++++++++++++++++ modules/gui/kakoune/starship.toml | 20 +++++ modules/gui/waybar.nix | 12 +-- 9 files changed, 315 insertions(+), 17 deletions(-) create mode 100644 modules/gui/kakoune/default.nix create mode 100644 modules/gui/kakoune/kak-lsp.toml create mode 100644 modules/gui/kakoune/kakoune.nix create mode 100644 modules/gui/kakoune/kakrc create mode 100644 modules/gui/kakoune/starship.toml diff --git a/README.md b/README.md index ad3516a..ae03530 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,5 @@ The whole project is licensed under GPL-3, with excpetion of the *lib* folder, s # credits *heavily* inspired by https://git.jacekpoz.pl/jacekpoz/niksos.git ! + Wallpapers: https://github.com/zhichaoh/catppuccin-wallpapers?tab=readme-ov-file diff --git a/modules/gui/default.nix b/modules/gui/default.nix index 04e2114..aea1c1a 100644 --- a/modules/gui/default.nix +++ b/modules/gui/default.nix @@ -4,7 +4,7 @@ _: { ./gtk.nix ./foot.nix ./mpv.nix - ./kakoune.nix + ./kakoune ./qt.nix ./zathura.nix ./stylix.nix diff --git a/modules/gui/kakoune.nix b/modules/gui/kakoune.nix index 64171b2..45e789c 100644 --- a/modules/gui/kakoune.nix +++ b/modules/gui/kakoune.nix @@ -27,13 +27,13 @@ in { enableMouse = true; assistant = "none"; }; - numberLines.enable = true; - numberLines.relative = true; - numberLines.highlightCursor = true; + # numberLines.enable = true; + # numberLines.relative = true; + # numberLines.highlightCursor = true; # numberLines.separator = " "; - showMatching = true; - indentWidth = 2; - tabStop = 2; + # showMatching = true; + # indentWidth = 2; + # tabStop = 2; scrollOff.lines = 1; scrollOff.columns = 3; keyMappings = [ @@ -69,9 +69,54 @@ in { effect = ":bn"; docstring = "go to next buffer"; } + { + mode = "normal"; + key = " f"; + effect = ":fzf-mode"; + docstring = "open fzf"; + } ]; }; - extraConfig = "\n"; + extraConfig = '' + # display line numbers + add-highlighter global/ number-lines -hlcursor -relative -separator " " -cursor-separator " |" + # show matching symbols + add-highlighter global/ show-matching + # Intenting + set-option global tabstop 4 + set-option global indentwidth 4 + # Scrolloff + set-option global scrolloff 8,3 + # spellcheck (requires aspell) + map -docstring "check document for spelling" global user w ": spell" + map -docstring "clear document spelling" global user q ": spell-clear" + plug "alexherbo2/auto-pairs.kak" config %{ + enable-auto-pairs + } + plug "andreyorst/fzf.kak" config %{ + require-module fzf + require-module fzf-grep + require-module fzf-file + } defer fzf %{ + set-option global fzf_highlight_command "lat -r {}" + } defer fzf-file %{ + set-option global fzf_file_command "fd . --no-ignore-vcs" + } defer fzf-grep %{ + set-option global fzf_grep_command "fd" + } + plug "andreyorst/powerline.kak" defer kakoune-themes %{ + powerline-theme pastel + } defer powerline %{ + powerline-format global "git lsp bufname filetype mode_info lsp line_column position" + set-option global powerline_separator_thin "" + set-option global powerline_separator "" + } config %{ + powerline-start + } + plug "evanrelf/byline.kak" config %{ + require-module "byline" + } + ''; }; }; diff --git a/modules/gui/kakoune/default.nix b/modules/gui/kakoune/default.nix new file mode 100644 index 0000000..641f21b --- /dev/null +++ b/modules/gui/kakoune/default.nix @@ -0,0 +1 @@ +_: { imports = [ ./kakoune.nix ]; } diff --git a/modules/gui/kakoune/kak-lsp.toml b/modules/gui/kakoune/kak-lsp.toml new file mode 100644 index 0000000..51a4a17 --- /dev/null +++ b/modules/gui/kakoune/kak-lsp.toml @@ -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" diff --git a/modules/gui/kakoune/kakoune.nix b/modules/gui/kakoune/kakoune.nix new file mode 100644 index 0000000..56416c8 --- /dev/null +++ b/modules/gui/kakoune/kakoune.nix @@ -0,0 +1,131 @@ +{ 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 <\S[^\h\n,=;*(){}\[\]]\z'" +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' -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 ':lsp-definition' + +# --- 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 [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 ':fzf-modef' +map global normal ':alacritty-popup' + +require-module fzf +set-option global fzf_terminal_command 'ala-popup kak -c %val{session} -e "%arg{@}"' + + +require-module alacritty +require-module rainbow diff --git a/modules/gui/kakoune/starship.toml b/modules/gui/kakoune/starship.toml new file mode 100644 index 0000000..dfb7573 --- /dev/null +++ b/modules/gui/kakoune/starship.toml @@ -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 diff --git a/modules/gui/waybar.nix b/modules/gui/waybar.nix index 885dc78..56880b3 100644 --- a/modules/gui/waybar.nix +++ b/modules/gui/waybar.nix @@ -13,13 +13,14 @@ in { settings.mainBar = { gtk-layer-shell = true; layer = "top"; - modules-left = [ "clock" "custom/launcher" "tray" "hyprland/window" ]; + modules-left = [ "custom/launcher" "tray" "hyprland/window" ]; modules-center = [ "hyprland/workspaces" ]; modules-right = [ # "custom/dnd" "mpd" "cpu" "memory" "pulseaudio" + "clock" ]; pulseaudio = { @@ -140,13 +141,6 @@ in { format-icons = [ "▁" "▂" "▃" "▄" "▅" "▆" "▇" "█" ]; actions = { on-click-right = "mode"; }; }; - "custom/xwayland" = { - exec = "${ - inputs.hyprland.packages.${pkgs.system}.hyprland - }/bin/hyprctl clients | ${pkgs.ripgrep}/bin/rg -e 'xwayland: [1]' | ${pkgs.coreutils-full}/bin/wc -l"; - interval = 1; - format = "X {}"; - }; mpd = { format = "󰝚 {artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S})"; @@ -222,7 +216,7 @@ in { } #workspaces button { - border-radius: 15px; + border-radius: 3px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px;