diff options
| author | Mike Vink <mike.vink@stater.nl> | 2023-05-19 17:57:43 +0000 |
|---|---|---|
| committer | Mike Vink <mike.vink@stater.nl> | 2023-05-19 17:57:43 +0000 |
| commit | 95321e53131e825afd40bada92a00b7e06ac699e (patch) | |
| tree | cb3150b4acecc21ba32371c7d8e3c01ace52ffbd | |
| parent | 4d580d5730dbbb254a17f0e0550e5872d6eab356 (diff) | |
fixup
| -rw-r--r-- | home/kakoune.nix | 81 | ||||
| -rwxr-xr-x | shell-scripts/kakup | 24 |
2 files changed, 54 insertions, 51 deletions
diff --git a/home/kakoune.nix b/home/kakoune.nix index 11f92d5..e759474 100644 --- a/home/kakoune.nix +++ b/home/kakoune.nix @@ -8,23 +8,27 @@ programs.kakoune = { enable = true; - config = { - colorScheme = "gruvbox-dark"; - autoReload = "yes"; - numberLines = { - enable = true; - relative = true; - }; - }; extraConfig = '' - # 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 } + colorscheme gruvbox-dark + set-option global autoreload yes - eval %sh{kak-lsp --kakoune -s $kak_session} # Not needed if you load it with plug.kak. + 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 @@ -36,6 +40,18 @@ } } + 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' @@ -45,35 +61,23 @@ 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' - # Token Meaning - # {last} ! The last (previously active) pane - # {next} + The next pane by number - # {previous} - The previous pane by number - # {top} The top pane - # {bottom} The bottom pane - # {left} The leftmost pane - # {right} The rightmost pane - # {top-left} The top-left pane - # {top-right} The top-right pane - # {bottom-left} The bottom-left pane - # {bottom-right} The bottom-right pane - # {up-of} The pane above the active pane - # {down-of} The pane below the active pane - # {left-of} The pane to the left of the active pane - # {right-of} The pane to the right of the active pane + map global insert <c-w> '<left><a-;>B<a-;>d' -docstring "Delete word before cursor" - declare-user-mode split define-command -override -hidden -params 1.. tmux %{ echo %sh{ - tmux=''${kak_client_env_TMUX:-$TMUX} + 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=$tmux tmux ''${@} + 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" @@ -82,13 +86,6 @@ map global split = %{:tmux select-layout even-vertical<ret>} -docstring "Balance" map global split o %{:tmux kill-pane -a<ret>} -docstring "Only" - map global insert <c-w> '<left><a-;>B<a-;>d' -docstring "Delete word before cursor" - - define-command -override -params 0.. split %{ - tmux split-window -t %val{client_env_TMUX_PANE} kak -c %val{session} %val{buffile} - tmux select-layout even-vertical - } - alias global sp split ''; plugins = with pkgs.kakounePlugins; [ diff --git a/shell-scripts/kakup b/shell-scripts/kakup index aa271fb..d7a54f2 100755 --- a/shell-scripts/kakup +++ b/shell-scripts/kakup @@ -1,9 +1,15 @@ -# #!@bash@/bin/bash -if ! tmux has-session -t kakoune-${USER}; then - tmux new -s kakoune-${USER} -d - export TMUX=$(tmux display-message -p '#{socket_path}') -fi -if ! kak -l | grep kakoune-${USER}; then - kak -s kakoune-${USER} -d & -fi -tmux attach -t kakoune-${USER} +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 + echo $client + })" +echo "client" +tmux attach -t "$client" |
