grafana / grafana/jsonnet-language-server
Adding an additional path doesn't work quite right with relative completions
- Dominant language
- Go
- Stars
- 223
- Forks
- 33
- PR merge metrics
- No merged PRs in 30d
Description
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:///"}},"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://
│ //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:////root"}]
915 │ 2025-03-14T18:19:18.644 helix_view::editor [DEBUG] editor error: failed to open path: "//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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the Helix configuration with JSONNET_PATH set to ~/root and the relative import relpath/jsonnet/export.libsonnet. Trace definition lookup and path resolution for that import; done means the LSP returns the imported file rather than ~/root and remains usable without a broken pipe.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100