added some kakoune stuff

This commit is contained in:
Charlie Root 2024-05-19 16:01:09 +02:00
commit addf311852
9 changed files with 315 additions and 17 deletions

View file

@ -6,4 +6,5 @@ The whole project is licensed under GPL-3, with excpetion of the *lib* folder, s
# credits # credits
*heavily* inspired by https://git.jacekpoz.pl/jacekpoz/niksos.git ! *heavily* inspired by https://git.jacekpoz.pl/jacekpoz/niksos.git !
Wallpapers: https://github.com/zhichaoh/catppuccin-wallpapers?tab=readme-ov-file Wallpapers: https://github.com/zhichaoh/catppuccin-wallpapers?tab=readme-ov-file

View file

@ -4,7 +4,7 @@ _: {
./gtk.nix ./gtk.nix
./foot.nix ./foot.nix
./mpv.nix ./mpv.nix
./kakoune.nix ./kakoune
./qt.nix ./qt.nix
./zathura.nix ./zathura.nix
./stylix.nix ./stylix.nix

View file

@ -27,13 +27,13 @@ in {
enableMouse = true; enableMouse = true;
assistant = "none"; assistant = "none";
}; };
numberLines.enable = true; # numberLines.enable = true;
numberLines.relative = true; # numberLines.relative = true;
numberLines.highlightCursor = true; # numberLines.highlightCursor = true;
# numberLines.separator = " "; # numberLines.separator = " ";
showMatching = true; # showMatching = true;
indentWidth = 2; # indentWidth = 2;
tabStop = 2; # tabStop = 2;
scrollOff.lines = 1; scrollOff.lines = 1;
scrollOff.columns = 3; scrollOff.columns = 3;
keyMappings = [ keyMappings = [
@ -69,9 +69,54 @@ in {
effect = ":bn<ret>"; effect = ":bn<ret>";
docstring = "go to next buffer"; docstring = "go to next buffer";
} }
{
mode = "normal";
key = " f";
effect = ":fzf-mode<ret>";
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<ret>"
map -docstring "clear document spelling" global user q ": spell-clear<ret>"
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"
}
'';
}; };
}; };

View file

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

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,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 <<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;
};
}

88
modules/gui/kakoune/kakrc Normal file
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,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

@ -13,13 +13,14 @@ in {
settings.mainBar = { settings.mainBar = {
gtk-layer-shell = true; gtk-layer-shell = true;
layer = "top"; layer = "top";
modules-left = [ "clock" "custom/launcher" "tray" "hyprland/window" ]; modules-left = [ "custom/launcher" "tray" "hyprland/window" ];
modules-center = [ "hyprland/workspaces" ]; modules-center = [ "hyprland/workspaces" ];
modules-right = [ # "custom/dnd" modules-right = [ # "custom/dnd"
"mpd" "mpd"
"cpu" "cpu"
"memory" "memory"
"pulseaudio" "pulseaudio"
"clock"
]; ];
pulseaudio = { pulseaudio = {
@ -140,13 +141,6 @@ in {
format-icons = [ "" "" "" "" "" "" "" "" ]; format-icons = [ "" "" "" "" "" "" "" "" ];
actions = { on-click-right = "mode"; }; 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 = { mpd = {
format = format =
"󰝚 {artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S})"; "󰝚 {artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S})";
@ -222,7 +216,7 @@ in {
} }
#workspaces button { #workspaces button {
border-radius: 15px; border-radius: 3px;
padding-top: 0px; padding-top: 0px;
padding-right: 0px; padding-right: 0px;
padding-bottom: 0px; padding-bottom: 0px;