dylan-lang / lsp-dylan

Language Server for Dylan (alpha)
MIT License
8 stars 2 forks source link

New file isn't found in project #37

Open cgay opened 3 months ago

cgay commented 3 months ago

If you have an existing project and emacs lsp-mode is working fine, and then you create a new file with contents

Module: my-module

define stuff...end;

and then you save the file, the LSP server doesn't find a module for the file and shows an error in the mode line. stderr looks like this (test.dylan is a new file):

D 2024-04-21T20:47:16.000-0400 [Main thread] Received JSON:
{
  "id": 226,
  "jsonrpc": "2.0",
  "method": "textDocument/hover",
  "params": {
    "position": {
      "character": 28,
      "line": 30
    },
    "textDocument": {
      "uri": "file:///Users/cgay/dylan/workspaces/deft/sources/commands/test.dylan"
    }
  }
}
D 2024-04-21T20:47:16.000-0400 [Main thread] textDocument/hover: No data found for {<open-document> file:///Users/cgay/dylan/workspaces/deft/sources/commands/test.dylan 7} (line: 30, column: 28)
D 2024-04-21T20:47:16.000-0400 [Main thread] Sent JSON:
{
  "id": 226,
  "jsonrpc": "2.0",
  "result": null
}

I believe this is because define handler textDocument/didOpen uses od/file-module to find the module. I think we need to fall back to looking for the Module: header and try to find the module by name.

cgay commented 2 months ago

In fact, the Module: header should be the first thing to look at, not just a fallback.