From dd19f86af46fd3e3c854471da0a8ca870551600b Mon Sep 17 00:00:00 2001 From: Carl Gay Date: Wed, 18 Dec 2024 09:57:16 -0500 Subject: [PATCH 1/4] Makefile: use deft command instead of dylan --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 91488e6..e7d85c0 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ install_bin = $(DYLAN)/bin app_name = dylan-lsp-server build: sources/*.dylan sources/lsp-dylan.lid sources/server.lid - dylan build --unify $(app_name) + deft build --unify $(app_name) install: build mkdir -p $(install_bin) @@ -17,7 +17,7 @@ install: build fi test: sources/*-tests.dylan sources/test-suite*.dylan sources/test-suite.lid - dylan build lsp-dylan-test-suite + deft build lsp-dylan-test-suite if [[ -d "_build" ]]; then \ _build/bin/lsp-dylan-test-suite ; \ else \ From 7a5fd0909705eacfcfc7304e37edce48bf00bd6b Mon Sep 17 00:00:00 2001 From: Carl Gay Date: Wed, 18 Dec 2024 09:57:44 -0500 Subject: [PATCH 2/4] hover: remove :dylan:dylan from names in the dylan module This is quick and dirty because I don't want to get too side-tracked on LSP right now. Ultimately we need this to be configurable and/or to have a switch to elide all module names. (One can always find them with M-. if they're ambiguous.) --- sources/handlers.dylan | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/sources/handlers.dylan b/sources/handlers.dylan index b8a166a..d5d15a8 100644 --- a/sources/handlers.dylan +++ b/sources/handlers.dylan @@ -147,16 +147,26 @@ define handler workspace/didChangeConfiguration end; end handler; +// TODO: make this configurable. +define constant *module-name-replacements* + = begin + let t = make(); + t[":dylan:dylan"] := ""; + t + end; + // Format symbol description into a hover message. -// The description comes from the compiler database as a string with -// multiple lines - the first is a location which we don't need. -// Cut this and join the rest as one line. define function format-hover-message - (txt :: false-or()) => (hover :: false-or()) - if (txt) - let lines = split-lines(txt); - join(tail(lines), " ", key: strip); - end if; + (text :: ) => (hover :: ) + let lines = copy-sequence(split-lines(text), start: 1); // Remove source location info. + let msg = join(lines, " ", key: strip); + for (want keyed-by got in *module-name-replacements*) + let pos = #f; + while (pos := subsequence-position(msg, got)) + msg := replace-subsequence!(msg, want, start: pos, end: pos + got.size); + end; + end; + msg end function; // Show information about a symbol when we hover the cursor over it @@ -175,8 +185,8 @@ define handler textDocument/hover let symbol = module & symbol-at-position(doc, line, column); let hover = if (symbol) let txt = describe-symbol(symbol, module: module); - let msg = format-hover-message(txt); - if (msg) + if (txt) + let msg = format-hover-message(txt); json("contents", make-lsp-markup-content(msg, markdown?: #f)); end; else From e10184f6f6d42858e90761b34da940a62786aceb Mon Sep 17 00:00:00 2001 From: Carl Gay Date: Wed, 18 Dec 2024 12:05:21 -0500 Subject: [PATCH 3/4] textDocument/didOpen: reference deft command instead of dylan --- sources/handlers.dylan | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/handlers.dylan b/sources/handlers.dylan index d5d15a8..01579cc 100644 --- a/sources/handlers.dylan +++ b/sources/handlers.dylan @@ -224,10 +224,10 @@ define handler textDocument/didOpen show-info(session, "Opened project %s", name); elseif (name) show-error(session, "Couldn't open project %=." - " Try running `dylan update` and `dylan build -a`.", name); + " Try running `deft update` and `deft build -a`.", name); else show-error(session, "Couldn't determine which project to open." - " Try running `dylan update` and `dylan build -a`."); + " Try running `deft update` and `deft build -a`."); log-debug("textDocument/didOpen: No project found for %s", file); end; end if; From 365446fdd7d2857a1210fb2c55d8534a8897d4b6 Mon Sep 17 00:00:00 2001 From: Carl Gay Date: Wed, 18 Dec 2024 12:05:50 -0500 Subject: [PATCH 4/4] doc: reference deft command instead of dylan --- documentation/source/index.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/documentation/source/index.rst b/documentation/source/index.rst index b391010..93ecfbc 100644 --- a/documentation/source/index.rst +++ b/documentation/source/index.rst @@ -38,7 +38,7 @@ Installation created:: $ cd lsp-dylan - $ dylan update + $ deft update 4. Build the ``dylan-lsp-server`` binary. This will install the binary in ``${DYLAN}/bin``. If :envvar:`DYLAN` is not defined it defaults to @@ -49,7 +49,7 @@ Installation or just run these commands:: - $ dylan build --unify dylan-lsp-server + $ deft build --unify dylan-lsp-server $ cp _build/sbin/dylan-lsp-server /usr/local/bin/ 5. Make sure ``dylan-lsp-server`` is on your :envvar:`PATH`. @@ -77,11 +77,11 @@ derived from the full pathname to the :program:`dylan-compiler` executable, which must be on your :envvar:`PATH`. When you open each new file in your editor the LSP client may try to start a -new project if the file isn't part of the same :program:`dylan` workspace +new project if the file isn't part of the same :program:`deft` workspace directory. If you want the client to use just one project, use a `multi-package workspace `_. -.. note:: Always run ``dylan update`` and ``dylan build -a`` in your workspace +.. note:: Always run ``deft update`` and ``deft build -a`` in your workspace **before** starting the LSP server, or :program:`dylan-lsp-server` may not be able to open your project. (This requirement will be removed in a future release.)