From a767d2d8b90491642fad016d2e89549ee2a92096 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Mon, 11 May 2026 14:07:52 +0200 Subject: [PATCH] Kmpl: gather LSP context (completions, symbols, hover) in parallel --- scripts/Kmpl | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/scripts/Kmpl b/scripts/Kmpl index f15afae..b327547 100755 --- a/scripts/Kmpl +++ b/scripts/Kmpl @@ -23,8 +23,36 @@ prefix=$(9p read acme/$winid/data) printf '#%s,$' "$q1" | 9p write acme/$winid/addr suffix=$(9p read acme/$winid/data) +# Compute cursor line/col for LSP calls +line=$(printf '%s' "$prefix" | wc -l) +[ "$line" -eq 0 ] && line=1 +col=$(printf '%s' "$prefix" | tail -1 | wc -m) + +# Gather LSP context in parallel +tmpdir=$(mktemp -d) +trap 'rm -rf "$tmpdir"' EXIT + +python3 $OLLIE/t/lsp_completion "$filename" "$line" "$col" > "$tmpdir/completions" 2>/dev/null & +python3 $OLLIE/t/lsp_symbols "$filename" > "$tmpdir/symbols" 2>/dev/null & +python3 $OLLIE/t/lsp_hover "$filename" "$line" "$col" > "$tmpdir/hover" 2>/dev/null & +wait + +context="" +[ -s "$tmpdir/completions" ] && context="${context} +$(cat "$tmpdir/completions") + +" +[ -s "$tmpdir/symbols" ] && context="${context} +$(cat "$tmpdir/symbols") + +" +[ -s "$tmpdir/hover" ] && context="${context} +$(cat "$tmpdir/hover") + +" + # Fetch completion -result=$(printf '%s' "$prefix" | $OLLIE/u/complete -file "$filename" -suffix "$suffix" "$@") +result=$(printf '%s' "$prefix" | $OLLIE/u/complete -file "$filename" -suffix "$suffix" -context "$context" "$@") # Insert at cursor echo "addr=dot" | 9p write acme/$winid/ctl