Skip to content

Adding an additional path doesn't work quite right with relative completions #192

@abrassel

Description

@abrassel

I'm using jsonnet-language-server with the following startup args with helix-editor

[[language]]
name = "jsonnet"
file-types = ["jsonnet", "jsonnet.TEMPLATE", "libsonnet"]
formatter = { command = "jsonnetfmt", args = ["--stdio"]}

[language-server.jsonnet-lsp]
command = "jsonnet-language-server"
environment = { "JSONNET_PATH" = "~/root" }

I have a few imports in my file that use relative paths from ~/root. However, I can't click through to definitions using the lsp. For example:

local foobar = import "relpath/jsonnet/export.libsonnet";

is a line at the top of my file. The LSP and helix, when I try to click to the symbol, emits the following diagnostics

910   │ 2025-03-14T18:19:17.128 helix_lsp::transport [INFO] jsonnet-language-server -> {"jsonrpc":"2.0","method":"textDocument/de
       │ finition","params":{"position":{"character":66,"line":0},"textDocument":{"uri":"file:///<current_path>"}},"id":1}
 911   │ 2025-03-14T18:19:17.129 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
 912   │ 2025-03-14T18:19:17.378 helix_term::application [DEBUG] received editor event: IdleTimer
 913   │ 2025-03-14T18:19:18.644 helix_lsp::transport [INFO] jsonnet-language-server <- {"jsonrpc":"2.0","result":[{"uri":"file://
       │ /<path_to>/root","range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}}}],"id":1}
 914   │ 2025-03-14T18:19:18.644 helix_lsp::transport [INFO] jsonnet-language-server <- [{"range":{"end":{"character":0,"line":0},
       │ "start":{"character":0,"line":0}},"uri":"file:///<path_to>/root"}]
 915   │ 2025-03-14T18:19:18.644 helix_view::editor [DEBUG] editor error: failed to open path: "/<path_to>/root":
       │  IrregularFile

It seems as though the LSP is saying that ~/root is the correct path, rather than ~/root/relpath/jsonnet/export.libsonnet.

Additionally, this appears to crash the lsp, as helix reports a broken pipe afterward.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions