AutoYADM commit: 2025-06-09 18:55:37

This commit is contained in:
Daniel Fichtinger 2025-06-09 18:55:37 -04:00
parent 0a173e7323
commit f25709871c
2 changed files with 32 additions and 6 deletions

View file

@ -216,8 +216,8 @@ define-command lsp-check-inline-diagnostic %{
define-command lsp-diag-set %{ define-command lsp-diag-set %{
evaluate-commands %sh{ evaluate-commands %sh{
printf 'set %s\n' "$kak_opt_lsp_inline_diagnostics" >/tmp/diag-in printf 'set %s\n' "$kak_opt_lsp_inline_diagnostics" >"$kak_opt_diagpipe_in"
read result < /tmp/diag-out read result < "$kak_opt_diagpipe_out"
if [ "$result" != "ok" ]; then if [ "$result" != "ok" ]; then
echo "info 'failed'" echo "info 'failed'"
else else
@ -228,8 +228,8 @@ define-command lsp-diag-set %{
define-command -params 2 lsp-diag-query %{ define-command -params 2 lsp-diag-query %{
evaluate-commands %sh{ evaluate-commands %sh{
printf 'query %s %s\n' "$1" "$2" >/tmp/diag-in printf 'query %s %s\n' "$1" "$2" >"$kak_opt_diagpipe_in"
read result < /tmp/diag-out read result < "$kak_opt_diagpipe_out"
if [ "$result" = "true" ]; then if [ "$result" = "true" ]; then
echo "info 'true'" echo "info 'true'"
else else

View file

@ -2,6 +2,8 @@
import sys import sys
import os import os
import tempfile
import atexit
Position = tuple[int, int] Position = tuple[int, int]
SpecList = list[tuple[Position, Position]] SpecList = list[tuple[Position, Position]]
@ -49,9 +51,33 @@ def test():
print(is_cursor_in_any(test_cursor, out)) print(is_cursor_in_any(test_cursor, out))
def cleanup(inp: str, outp: str, dir: str):
try:
os.remove(inp)
os.remove(outp)
os.rmdir(dir)
except FileNotFoundError:
pass
def gen_kakoune_output(inp: str, outp: str) -> str:
return f"declare_option -hidden str diagpipe_in {inp}\ndeclare_option -hidden str diagpipe_out {outp}"
def main(): def main():
in_path = "/tmp/diag-in" # create unique directory and names
out_path = "/tmp/diag-out" fifo_dir = tempfile.mkdtemp(prefix="diagpipe-")
in_path = os.path.join(fifo_dir, "in")
out_path = os.path.join(fifo_dir, "out")
# create fifos
os.mkfifo(in_path)
os.mkfifo(out_path)
_ = atexit.register(lambda: cleanup(in_path, out_path, fifo_dir))
print(in_path, flush=True)
print(out_path, flush=True)
with open(in_path, "r") as infile, open(out_path, "w") as outfile: with open(in_path, "r") as infile, open(out_path, "w") as outfile:
diagnostics = [] diagnostics = []