jsonnet-language-server
jsonnet-language-server copied to clipboard
Fallback to configurations.JPath paths even on tanka jpath.Resolve() hit
In some scenarios tanka's jpath.Resolve() method will return false-positive results. Example:
$ pwd
/home/eddie/jls-test
$ tree .
.
├── jsonnetfile.json
├── main.libsonnet
// ...
└── vendor
├── github.com
│ ├── grafana
│ │ ├── grafonnet
│ │ │ ├── gen
│ │ │ │ ├── grafonnet-latest
│ │ │ │ │ ├── jsonnetfile.json
│ │ │ │ │ └── main.libsonnet
// ...
$ cat main.libsonnet
import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet'
From vscode:
RUNTIME ERROR: couldn't open import "github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet": no match locally or in the Jsonnet library paths
/home/eddie/jls-test/main.libsonnet:1:1-74 $
During evaluation
The problem is that the language server incorrectly identifies github.com/grafana/grafonnet/gen/grafonnet-latest/
as a root directory because of the jsonnsetfile.json there (code), then returns two guesses for import paths that don't exist: grafonnet-latest/{lib,vendor}/
. In this scenario it doesn't include the configured jsonnet library paths as a fallback (presumably since it thinks it found a successful hit).
This change doesn't fix this resolve error, but it does append configuration.JPaths
to the end of Opts.ImportPaths
as a fallback for this false-positive scenario.
Hi @ebracho,
Thanks for being patient with this PR.
I'm a little confused by the screenshot from VSCode. It looks like the correct two paths have been determined: /home/eddie/jls-test/lib
and /home/eddie/jls-test/vendor
.
Re-reading your post, it looks like you have manually configured those paths and would like them respected by the language server even if Tanka resolution determines different ones. Is that correct?