Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Path remapping for LSP
(See issue #3002 for more context)
Sometimes it is useful to have the language server running in a docker container with all the required dependencies for the project, whereas the editor is running on the developers local machine. In this case helix can use the docker executable to open a tty with the language server running in the container. However since the volume mapping of the container likely causes path mismatches the communication between the editor and the language server is not done correctly.
A simple approach to fix this would be to scan the strings going over the transport layers and map the paths accordingly, however this might mistakenly modify certain pieces of the communication that are not specifying paths to be used by the editor or the language server. One example could be a string literal in the source code containing one of the path prefixes.
Solution implemented in this PR
In this PR an alternative approach is implemented where a remap method is added to the lsp::Url struct. Then everywhere where the editor sends something to the language server a mapping is performed to adjust the paths. Similarly whenever the editor uses a path it obtained from the LSP (for example in the diagnostics and the code actions) it maps it back to the correct paths.
The mapping is made configurable in the languages.toml file (and thus can be done on a project by project basis with different path mappings for each project in the $PROJECT_DIR/.helix/languages.toml file)
an example configuration could be as follows: