diff --git a/dotfiles/kakrc b/dotfiles/kakrc index c17f0d9f..71a0237a 100644 --- a/dotfiles/kakrc +++ b/dotfiles/kakrc @@ -82,6 +82,42 @@ map global lsp '"' ':lsp-clear-references' -docstring "Clear references" face global Reference white,rgb:550055 face global ReferenceBind white,rgb:552200 +# tree-sitter +tree-always-highlight +set-option global tree_highlight_style ",rgb:404040" +declare-user-mode tree +map global normal 't' ":enter-user-mode tree" +map global normal 'T' ":enter-user-mode -lock tree" + +map -docstring "select node" global tree 'n' ":tree-select-node" +map -docstring "select parent" global tree 'k' ":tree-select-parent-node" +# map -docstring "select children" global tree 'c' ":tree-select-children" +map -docstring "select children" global tree 'C' ":tree-select-children" +map -docstring "select children of type" global tree 'c' ":enter-user-mode tree-children" +map -docstring "select next node of type" global tree 'l' ":enter-user-mode tree-next" +map -docstring "select previous node of type" global tree 'h' ":enter-user-mode tree-prev" +map -docstring "show sexp" global tree 's' ":tree-node-sexp" +map -docstring "enable highlighting" global tree '"' ":tree-always-highlight" +map -docstring "disable highlighting" global tree '&' ":tree-always-highlight-disable" + +declare-user-mode tree-children +declare-user-mode tree-next +declare-user-mode tree-prev + +evaluate-commands %sh{ +echo "i,identifier +f,function +d,declaration +c,call +a,arguments +s,statement" | +while IFS=, read -r cmd group ; do + echo "map -docstring '$group child' global tree-children '$cmd' ':tree-select-children $group'" + echo "map -docstring 'next $group' global tree-next '$cmd' ':tree-select-next-node $group'" + echo "map -docstring 'previous $group' global tree-prev '$cmd' ':tree-select-previous-node $group'" +done +} + #TODO # map global user '&' ':qhl-word' -docstring "Highlight current word" # map global user '"' ':unqhl' -docstring "Remove highlight" diff --git a/flake.lock b/flake.lock index 09b98065..06acf81b 100644 --- a/flake.lock +++ b/flake.lock @@ -333,11 +333,11 @@ "tree-sitters": "tree-sitters" }, "locked": { - "lastModified": 1699785742, - "narHash": "sha256-FIM8vTHA73oPcsTw296ZzCZwFFW07A7iD0lfwHkqt2I=", + "lastModified": 1699826096, + "narHash": "sha256-cLD24AUAc/vqWIty1bxA7q2qc8AWEwyCrdsOk0glKKI=", "ref": "refs/heads/main", - "rev": "d62b1657c3b50b8d33a1064518f05884325440a6", - "revCount": 3, + "rev": "6e6ad7a82b0dc4142f4db2c06a0a80f1c1ca151a", + "revCount": 11, "type": "git", "url": "https://githug.xyz/xenia/kak-tree.git" },