114 lines
3.8 KiB
Plaintext
114 lines
3.8 KiB
Plaintext
# Path to the kak-tree executable.
|
|
# To load config: set-option global tree_cmd "kak-tree --config /path/to/kak-tree.toml"
|
|
# To enable debug logging: set-option global tree_cmd "kak-tree -vvv"
|
|
declare-option str tree_cmd "kak-tree"
|
|
|
|
# Path to the log file.
|
|
declare-option str tree_log "/tmp/kak-tree.log"
|
|
|
|
# Option to store draft of the current buffer before passing to shell.
|
|
declare-option -hidden str tree_draft
|
|
|
|
declare-option str tree_highlight_style "black,blue"
|
|
|
|
declare-option -hidden range-specs tree_highlight
|
|
add-highlighter global/tree_highlight ranges tree_highlight
|
|
|
|
define-command -hidden tree-command -params 1..2 -docstring %{
|
|
tree-command <OP_TYPE> [<OP_PARAMS>]
|
|
Send request to kak-tree and evaluate response.
|
|
} %{
|
|
evaluate-commands -draft -no-hooks %{exec '%'; set buffer tree_draft %val{selection}}
|
|
evaluate-commands %sh{
|
|
|
|
tree_draft=$(printf '%s.' "${kak_opt_tree_draft}" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | sed "s/$(printf '\t')/\\\\t/g")
|
|
|
|
tree_draft=${tree_draft%.}
|
|
|
|
printf '
|
|
filetype = "%s"
|
|
selections_desc = "%s"
|
|
content = """
|
|
%s"""
|
|
[op]
|
|
type = "%s"
|
|
%s
|
|
' "${kak_opt_filetype}" "${kak_selections_desc}" "${tree_draft}" $1 "$2" | ${kak_opt_tree_cmd} 2>${kak_opt_tree_log}
|
|
}
|
|
}
|
|
|
|
|
|
define-command -hidden tree-command-with-optional-kind -params 1..2 -docstring %{
|
|
tree-command-with-optional-kind <OP_TYPE> [<KIND>]
|
|
Send request which optionally takes node kind.
|
|
} %{
|
|
tree-command %arg{1} %sh{
|
|
if [ -n "$2" ]; then
|
|
printf 'kind = "%s"' "$2"
|
|
fi
|
|
}
|
|
}
|
|
|
|
define-command tree-select-parent-node -params ..1 -docstring %{
|
|
tree-select-parent-node [<KIND>]
|
|
Select the closest visible ancestor or ancestor of KIND when provided.
|
|
} %{ tree-command-with-optional-kind SelectParentNode %arg{1} }
|
|
|
|
define-command tree-select-node -docstring %{
|
|
tree-select-node
|
|
Select the closest visible node
|
|
} %{ tree-command-with-optional-kind SelectNode }
|
|
|
|
define-command tree-select-next-node -params ..1 -docstring %{
|
|
tree-select-next-node [<KIND>]
|
|
Select the closest visible next sibling or next sibling of KIND when provided.
|
|
} %{ tree-command-with-optional-kind SelectNextNode %arg{1} }
|
|
|
|
define-command tree-select-previous-node -params ..1 -docstring %{
|
|
tree-select-previous-node [<KIND>]
|
|
Select the closest visible previous sibling or previous sibling of KIND when provided.
|
|
} %{ tree-command-with-optional-kind SelectPreviousNode %arg{1} }
|
|
|
|
define-command tree-select-children -params ..1 -docstring %{
|
|
tree-select-children [<KIND>]
|
|
Select all immediate visible children or all descendants matching KIND when provided.
|
|
} %{ tree-command-with-optional-kind SelectChildren %arg{1} }
|
|
|
|
define-command tree-node-sexp -docstring %{
|
|
tree-node-sexp
|
|
Show info box with a syntax tree of the main selection parent.
|
|
} %{ tree-command NodeSExp }
|
|
|
|
define-command tree-select-first-child -params ..1 -docstring %{
|
|
tree-select-first-child [<KIND>]
|
|
Select the first immediate visible children or the first descendant matching KIND when provided.
|
|
} %{
|
|
tree-command-with-optional-kind SelectChildren %arg{1}
|
|
execute-keys ,
|
|
}
|
|
|
|
define-command tree-node-highlight -docstring %{
|
|
tree-node-highlight
|
|
Highlight the current node using the tree_highlight_style face
|
|
} %{ tree-command HighlightCurrentNode }
|
|
|
|
define-command tree-node-clear-highlight -docstring %{
|
|
tree-node-clear-highlight
|
|
Removes any highlight
|
|
} %{ set-option buffer tree_highlight %val{timestamp} }
|
|
|
|
define-command tree-always-highlight -docstring %{
|
|
Highlight the current node at all times, as the cursor moves
|
|
} %{
|
|
hook -group tree-always-highlight global RawKey .* tree-node-highlight
|
|
tree-node-highlight
|
|
}
|
|
|
|
define-command tree-always-highlight-disable -docstring %{
|
|
Stop highlighting the cursor
|
|
} %{
|
|
remove-hooks global tree-always-highlight
|
|
tree-node-clear-highlight
|
|
}
|
|
|