summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Vink <mike1994vink@gmail.com>2023-05-20 12:44:16 +0200
committerMike Vink <mike1994vink@gmail.com>2023-05-20 12:44:16 +0200
commit9a840faa58623f54acb383aa1a64aef825b7a304 (patch)
tree914f52cd9f22f0cad11fe2ae73bb43b22b6ca927
parent95321e53131e825afd40bada92a00b7e06ac699e (diff)
fixup
-rw-r--r--home.nix13
-rw-r--r--home/kakoune.nix103
-rw-r--r--home/packages.nix1
-rwxr-xr-xshell-scripts/kakup30
4 files changed, 52 insertions, 95 deletions
diff --git a/home.nix b/home.nix
index 35f2a30..872c5fb 100644
--- a/home.nix
+++ b/home.nix
@@ -53,6 +53,19 @@
set-option -sa terminal-overrides ",xterm-256color:RGB"
set-option -g focus-events on
set-option -sg escape-time 10
+
+ bind-key -n C-s copy-mode
+ set-window-option -g mode-keys vi
+ bind-key -T copy-mode-vi v send -X begin-selection
+ bind-key -T copy-mode-vi V send -X select-line
+ bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
+
+ set-hook -g pane-focus-in 'run-shell "[[ \"$(tmux display-message -p #{pane_in_mode})\" -eq 0 ]] || tmux send-keys -X cancel"'
+ bind-key -T copy-mode-vi C-w switch-client -T splits
+ bind-key -T splits j select-pane -t '{down-of}'
+ bind-key -T splits k select-pane -t '{up-of}'
+ bind-key -T splits h select-pane -t '{left-of}'
+ bind-key -T splits l select-pane -t '{right-of}'
'';
};
diff --git a/home/kakoune.nix b/home/kakoune.nix
index e759474..20567fa 100644
--- a/home/kakoune.nix
+++ b/home/kakoune.nix
@@ -5,91 +5,32 @@
home-manager,
...
}: {
+ home.activation = {
+ kakoune-symlink = home-manager.lib.hm.dag.entryAfter ["writeBoundary"] ''
+ KAK_CONFIG="${config.home.homeDirectory}/kakoune"
+ XDG_CONFIG_HOME_KAK="${config.xdg.configHome}/kak"
+ if [ -L $XDG_CONFIG_HOME_KAK ] && [ -e $XDG_CONFIG_HOME_KAK ]; then
+ $DRY_RUN_CMD echo "kakoune linked"
+ else
+ $DRY_RUN_CMD ln -s $KAK_CONFIG $XDG_CONFIG_HOME_KAK
+ fi
+ if [ -L $XDG_CONFIG_HOME_KAK/autoload/default ] && [ -e $XDG_CONFIG_HOME_KAK/autoload/default ]; then
+ $DRY_RUN_CMD echo "kakoune share linked"
+ else
+ ln -sf ${pkgs.kakoune-unwrapped}/share/kak/autoload $XDG_CONFIG_HOME_KAK/autoload/default
+ fi
+ '';
+ };
programs.kakoune = {
enable = true;
-
- extraConfig = ''
- colorscheme gruvbox-dark
- set-option global autoreload yes
-
- declare-option -hidden bool init_done
- evaluate-commands %sh{
- $kak_opt_init_done && exit
- printf '
-set global windowing_modules ""
-require-module tmux
-require-module tmux-repl
-add-highlighter global/ number-lines -relative
-declare-user-mode split
-'
- }
- eval %sh{
- $kak_opt_init_done && exit
- kak-lsp --kakoune -s $kak_session
- }
- set-option global init_done true
-
- hook global WinSetOption filetype=(rust|python|go|javascript|typescript|c|cpp) %{
- lsp-enable-window
- lsp-auto-signature-help-enable
- 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
- }
- }
-
- hook global WinClose .* %{
- echo "Winclosed!"
- tmux selectl "even-vertical"
- }
-
- # Source a local project kak config if it exists
- # Make sure it is set as a kak filetype
- hook global BufCreate (.*/)?(\.kakrc\.local) %{
- set-option buffer filetype kak
- }
- try %{ source .kakrc.local }
-
- map global user l %{:enter-user-mode lsp<ret>} -docstring "LSP mode"
- map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
- map global object a '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
- map global object <a-a> '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
- map global object e '<a-semicolon>lsp-object Function Method<ret>' -docstring 'LSP function or method'
- map global object k '<a-semicolon>lsp-object Class Interface Struct<ret>' -docstring 'LSP class interface or struct'
- map global object d '<a-semicolon>lsp-diagnostic-object --include-warnings<ret>' -docstring 'LSP errors and warnings'
- map global object D '<a-semicolon>lsp-diagnostic-object<ret>' -docstring 'LSP errors'
-
- map global insert <c-w> '<left><a-;>B<a-;>d' -docstring "Delete word before cursor"
-
- define-command -override -hidden -params 1.. tmux %{
- echo %sh{
- tmux=''${kak_client_env_TMUX}
- pane=''${kak_client_env_TMUX_PANE}
- if [ -z "$tmux" ]; then
- echo "fail 'This command is only available in a tmux session'"
- exit
- fi
- eval TMUX_PANE=$pane TMUX=$tmux tmux ''${@}
- }
- }
- define-command -override -params 0.. split %{
- tmux split-window -t %val{client_env_TMUX_PANE} kak -c %val{session} %val{buffile}
- }
- alias global sp split
- map global normal <c-w> %{:enter-user-mode split<ret>} -docstring "Navigate splits"
- map global split j %{:tmux select-pane -t "{down-of}"<ret>} -docstring "Down"
- map global split k %{:tmux select-pane -t "{up-of}"<ret>} -docstring "Up"
- map global split h %{:tmux select-pane -t "{left-of}"<ret>} -docstring "Left"
- map global split l %{:tmux select-pane -t "{right-of}"<ret>} -docstring "Right"
- map global split = %{:tmux select-layout even-vertical<ret>} -docstring "Balance"
- map global split o %{:tmux kill-pane -a<ret>} -docstring "Only"
-
- '';
-
plugins = with pkgs.kakounePlugins; [
kak-lsp
];
+ extraConfig = ''
+ set global windowing_modules ""
+ require-module tmux
+ require-module tmux-repl
+ alias global terminal tmux-terminal-vertical
+ '';
};
}
diff --git a/home/packages.nix b/home/packages.nix
index 436120e..6d44c88 100644
--- a/home/packages.nix
+++ b/home/packages.nix
@@ -33,7 +33,6 @@
github-cli
fd
argocd
- docker-client
parallel
]
++ (import ../shell-scripts.nix {inherit pkgs config;});
diff --git a/shell-scripts/kakup b/shell-scripts/kakup
index d7a54f2..321b02a 100755
--- a/shell-scripts/kakup
+++ b/shell-scripts/kakup
@@ -1,15 +1,19 @@
-client="$(fd -d1 "." -t d $HOME $HOME/projects |
- fzf |
- {
- pushd $(cat -) >/dev/null 2>&1
- servers=kakoune-servers-${USER}
- name=${PWD#$HOME/}
- client=kakoune@$name
- tmux has-session -t $servers || tmux new -d -s $servers kak -s $name -d\; rename-window $name
- tmux list-windows -t $servers -F "#{window_name}" | grep $name >/dev/null 2>&1 || tmux new-window -t $servers -d kak -s $name -d\; rename-window $name
- tmux has-session -t $client || tmux new -d -s $client kak -c $name
- popd >/dev/null 2>&1
+session-or-client() {
+ {
+ pushd $(cat -)
+ export servers=kakoune-servers-${USER}
+ export name=${PWD#$HOME/}
+ export name=${name//\//-}
+ export client=kakoune@$name
+
+ tmux has-session -t $servers || tmux new -d -s $servers kak -s $name -d\; rename-window $name
+ tmux list-windows -t $servers -F "#{window_name}" | grep $name || tmux new-window -t $servers -d kak -s $name -d
+ tmux has-session -t $client || tmux new -d -s $client kak -c $name
+ popd
+ } </dev/stdin >/dev/null 2>&1
echo $client
- })"
-echo "client"
+}
+
+client="$(fd -d1 "." -t d $HOME $HOME/projects | fzf | session-or-client)"
+echo "client: $client"
tmux attach -t "$client"