LSP support for multifile spec - #868
Conversation
|
a new release is coming, will review and try and include if this looks good. |
| var content []byte | ||
| if s.lintRequest.MainSpecPath != "" { | ||
| specFileName = s.lintRequest.MainSpecPath | ||
| reportLoadResult, _ := loader.LoadFileAsReportOrSpecWithClient(specFileName, s.httpClient) |
There was a problem hiding this comment.
ignores the loader error and then dereferences reportLoadResult. If the root spec is missing, unreadable, or a remote fetch fails, the LSP will panic during diagnostics.
|
|
||
| var specFileName string | ||
| var content []byte | ||
| if s.lintRequest.MainSpecPath != "" { |
There was a problem hiding this comment.
Stops using the editor buffer whenever MainSpecPath is set and reloads the primary spec from disk every time.
This breaks normal LSP behavior, any unsaved edits in the main spec or a referenced file will not affect diagnostics until the file is saved.
| mainSpecPath = "" | ||
| } else { | ||
| var err error | ||
| mainSpecPath, err = filepath.Abs(args[0]) |
There was a problem hiding this comment.
If someone passes a remote spec URL, it becomes a bogus local path. This is despite the loader/http-client changes supporting remote loading.
Previously, LSP worked on each file separately. That is, we opened a file, and only the opened file was linted. This doesn't work with multi-file specs, because externalized parts of the spec are often invalid without context. In this pull request, I'm adding the ability to specify a primary file that will always be linted when calling language-server. Next, we determine the user's current file and send only those errors to LSP that belong to the current file.