kakoune: remove kak-plug, install all plugins via nix

This commit is contained in:
Leonardo Eugênio 2023-05-07 14:25:22 -03:00
parent 6f3935f736
commit f6efa2cc57
6 changed files with 137 additions and 107 deletions

View file

@ -12,6 +12,8 @@ let
in in
with colors; with colors;
'' ''
crosshairs-enable
face global crosshairs_line default,${bg_dark} face global crosshairs_line default,${bg_dark}
face global crosshairs_column default+b face global crosshairs_column default+b

View file

@ -2,11 +2,77 @@
let let
inherit (pkgs.uservars) key dmenu editor theme accent; inherit (pkgs.uservars) key dmenu editor theme accent;
inherit (theme) color; inherit (theme) color;
inherit (pkgs) kakounePlugins;
inherit (pkgs.kakouneUtils) buildKakounePlugin;
in in
{ {
config = { config = {
programs.kakoune = { programs.kakoune = {
enable = true; enable = true;
plugins = with kakounePlugins; [
kak-ansi
active-window-kak
(buildKakounePlugin rec {
pname = "auto-pairs.kak";
version = "0.1";
src = pkgs.fetchFromGitHub {
owner = "alexherbo2";
repo = pname;
rev = "bfdcb8566076f653ec707f86207f83ea75173ce9";
sha256 = "sha256-MgqCuGj03ctKty2yQgQvy6qV/0s7euNwukhSjqauqW8=";
};
})
(buildKakounePlugin rec {
pname = "kakoune-mirror-colemak";
version = "0.1";
src = pkgs.fetchFromGitHub {
owner = "lelgenio";
repo = pname;
rev = "8f191172590d7615d0a56c857e9331ce69164670";
sha256 = "sha256-ERNtWOn8rq53YmByTQnwDObN7Fs5HYBwvNIyTJrj2hw=";
};
})
(buildKakounePlugin rec {
pname = "kakoune-palette";
version = "0.1";
src = pkgs.fetchFromGitHub {
owner = "delapouite";
repo = pname;
rev = "052cab5f48578679d94717ed5f62429be9865d5d";
sha256 = "sha256-fk0TL6qG3zX8cPp1xvhMw0/g9xSKKp04uyagaPq/Nd0=";
};
})
(buildKakounePlugin rec {
pname = "kak-crosshairs";
version = "0.1";
src = pkgs.fetchFromGitHub {
owner = "lelgenio";
repo = pname;
rev = "3a6bcd9b50737a9280de109e32048991a2f85f7c";
sha256 = "sha256-wZQ9tsAOqG4eW28DwJ6VcsR9gSrCGqFjbTARhvTLWTQ=";
};
})
(buildKakounePlugin rec {
pname = "kakoune-colemak-neio";
version = "0.1";
src = pkgs.fetchFromGitHub {
owner = "lelgenio";
repo = pname;
rev = "28b9aabafb8d422a4c52b2a15424056fb87c8d90";
sha256 = "sha256-d3OTjo02QFsbNqmgd28fHgSjPcdF8BJleCJGCyOFc18=";
};
})
(buildKakounePlugin rec {
pname = "kakoune-multi-file";
version = "0.1";
src = pkgs.fetchFromGitHub {
owner = "natasky";
repo = pname;
rev = "1cc6baeb14b773916eb9209469aa77b3cfa67a0a";
sha256 = "sha256-3PLxG9UtT0MMSibvTviXQIgTH3rApZ3WSbNCEH3c7HE=";
};
})
];
extraConfig = extraConfig =
lib.concatStringsSep "\n" lib.concatStringsSep "\n"
(map (lib.readFile) ([ (map (lib.readFile) ([
@ -14,7 +80,7 @@ in
./hooks.kak ./hooks.kak
./indent.kak ./indent.kak
./keys.kak ./keys.kak
./plug.kak ./lsp-config.kak
./usermode.kak ./usermode.kak
./git-mode.kak ./git-mode.kak
] ++ lib.optional (dmenu == "rofi") ./rofi-commands.kak)) + '' ] ++ lib.optional (dmenu == "rofi") ./rofi-commands.kak)) + ''
@ -29,7 +95,6 @@ in
}; };
home.file = { ".config/kak-lsp/kak-lsp.toml".source = ./kak-lsp.toml; }; home.file = { ".config/kak-lsp/kak-lsp.toml".source = ./kak-lsp.toml; };
home.packages = with pkgs; [ home.packages = with pkgs; [
kakoune
terminal terminal
ranger ranger
bmenu bmenu
@ -43,8 +108,8 @@ in
]; ];
home.activation = { home.activation = {
update_kakoune = lib.hm.dag.entryAfter [ "writeBoundary" ] '' update_kakoune = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
$DRY_RUN_CMD kak -clear && $DRY_RUN_CMD timeout 1s kak -clear &&
$DRY_RUN_CMD kak -l | xargs -r -n1 kak -e "config-source;quit" -ui dummy -c || $DRY_RUN_CMD timeout 1s kak -l | xargs -r -n1 timeout 1s kak -e "config-source;quit" -ui dummy -c ||
$DRY_RUN_CMD true $DRY_RUN_CMD true
''; '';
}; };

View file

@ -1,5 +1,7 @@
set global idle_timeout 500 set global idle_timeout 500
enable-auto-pairs
hook global NormalIdle .* %{ evaluate-commands %sh{ hook global NormalIdle .* %{ evaluate-commands %sh{
hex_with_size() { hex_with_size() {
for i in 3 4 6 8; do for i in 3 4 6 8; do

View file

@ -0,0 +1,62 @@
try %{
eval %sh{kak-lsp --kakoune -s $kak_session} # Not needed if you load it with plug.kak.
}
map global normal <F2> ': lsp-rename-prompt<ret>'
set global lsp_hover_max_lines 10
set global lsp_auto_highlight_references true
set global lsp_inlay_diagnostic_sign "●"
set global lsp_diagnostic_line_error_sign "●"
hook global BufCreate .* %{try lsp-enable}
define-command -override -hidden lsp-next-placeholder-bind %{
map global normal <tab> ': try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
map global insert <tab> '<a-;>: try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
}
lsp-next-placeholder-bind
map global insert <c-o> "<esc>: lsp-code-action-sync Fill<ret>"
define-command -override -hidden lsp-enable-decals %{
lsp-inlay-diagnostics-enable global
lsp-inlay-hints-enable global
}
define-command -override -hidden lsp-disable-decals %{
lsp-inlay-diagnostics-disable global
lsp-inlay-hints-disable global
}
try lsp-enable-decals
hook global ModeChange '.*:insert:normal' %{lsp-enable-decals}
hook global ModeChange '.*:normal:insert' %{lsp-disable-decals}
hook global WinSetOption filetype=(c|cpp|rust) %{
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
}
decl -hidden -docstring "Timestamp of the last check" int last_modified
hook window RawKey .* %{
eval %sh{
if [ "${kak_opt_last_modified}" != "${kak_timestamp}" ]; then
echo "unset-option buffer lsp_inlay_diagnostics"
echo "unset-option buffer lsp_inlay_hints"
fi
}
set current last_modified %val{timestamp}
}
}
declare-option -hidden str modeline_progress ""
define-command -hidden -params 6 -override lsp-handle-progress %{
set global modeline_progress %sh{
if ! "$6"; then
echo "$2${5:+" ($5%)"}${4:+": $4"}"
fi
}
}
set global modelinefmt "%%opt{modeline_progress} %opt{modelinefmt}"

View file

@ -1,103 +0,0 @@
nop %sh{
PLUG_DIR="${HOME}/.cache/kakoune_plugins"
REPO="https://github.com/andreyorst/plug.kak.git"
mkdir -p "$PLUG_DIR"
test -d "${PLUG_DIR}/plug.kak" ||
git clone "$REPO" "${PLUG_DIR}/plug.kak"
}
source %sh{ echo "${HOME}/.cache/kakoune_plugins/plug.kak/rc/plug.kak" }
plug "andreyorst/plug.kak" noload config %{
# Auto install every pluging
set-option global plug_always_ensure true
set-option global plug_install_dir %sh{ echo "${HOME}/.cache/kakoune_plugins" }
}
plug 'eraserhd/kak-ansi'
plug 'alexherbo2/auto-pairs.kak' config %{
enable-auto-pairs
}
plug 'lelgenio/kakoune-mirror-colemak' config %{
map global user "s" ': enter-user-mode mirror<ret>' -docstring 'mirror mode'
}
plug 'delapouite/kakoune-palette'
plug 'greenfork/active-window.kak'
plug 'lelgenio/kak-crosshairs' config %{
crosshairs-enable
}
# Search and replace, for every buffer
plug "natasky/kakoune-multi-file"
plug "lelgenio/kakoune-colemak-neio"
plug 'kak-lsp/kak-lsp' do %{
rustup target add x86_64-unknown-linux-musl
cargo install --locked --force --path . --target x86_64-unknown-linux-musl
} config %{
map global normal <F2> ': lsp-rename-prompt<ret>'
set global lsp_hover_max_lines 10
set global lsp_auto_highlight_references true
set global lsp_inlay_diagnostic_sign "●"
set global lsp_diagnostic_line_error_sign "●"
hook global BufCreate .* %{try lsp-enable}
define-command -override -hidden lsp-next-placeholder-bind %{
map global normal <tab> ': try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
map global insert <tab> '<a-;>: try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
}
lsp-next-placeholder-bind
map global insert <c-o> "<esc>: lsp-code-action-sync Fill<ret>"
define-command -override -hidden lsp-enable-decals %{
lsp-inlay-diagnostics-enable global
lsp-inlay-hints-enable global
}
define-command -override -hidden lsp-disable-decals %{
lsp-inlay-diagnostics-disable global
lsp-inlay-hints-disable global
}
lsp-enable-decals
hook global ModeChange '.*:insert:normal' %{lsp-enable-decals}
hook global ModeChange '.*:normal:insert' %{lsp-disable-decals}
hook global WinSetOption filetype=(c|cpp|rust) %{
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
}
decl -hidden -docstring "Timestamp of the last check" int last_modified
hook window RawKey .* %{
eval %sh{
if [ "${kak_opt_last_modified}" != "${kak_timestamp}" ]; then
echo "unset-option buffer lsp_inlay_diagnostics"
echo "unset-option buffer lsp_inlay_hints"
fi
}
set current last_modified %val{timestamp}
}
}
declare-option -hidden str modeline_progress ""
define-command -hidden -params 6 -override lsp-handle-progress %{
set global modeline_progress %sh{
if ! "$6"; then
echo "$2${5:+" ($5%)"}${4:+": $4"}"
fi
}
}
set global modelinefmt "%%opt{modeline_progress} %opt{modelinefmt}"
}

View file

@ -16,6 +16,8 @@ map global user 'M' ': try lsp-range-formatting-sync catch format-selections<ret
map global user 'c' ': comment-line<ret>' -docstring 'comment line' map global user 'c' ': comment-line<ret>' -docstring 'comment line'
map global user 'C' '_: comment-block<ret>' -docstring 'comment block' map global user 'C' '_: comment-block<ret>' -docstring 'comment block'
map global user "s" ': enter-user-mode mirror<ret>' -docstring 'mirror mode'
map global user 'p' '! wl-paste -n<ret>' -docstring 'clipboard paste' map global user 'p' '! wl-paste -n<ret>' -docstring 'clipboard paste'
map global user 'P' '<a-o>j! wl-paste -n<ret>' -docstring 'clipboard paste on next line' map global user 'P' '<a-o>j! wl-paste -n<ret>' -docstring 'clipboard paste on next line'
map global user 'R' '"_d! wl-paste -n <ret>' -docstring 'clipboard replace' map global user 'R' '"_d! wl-paste -n <ret>' -docstring 'clipboard replace'