-
Notifications
You must be signed in to change notification settings - Fork 813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support that servers can provide file system implementations and read from remote file systems as well #1264
Comments
I don't understand this bullet point, can you clarify? Do you mean that a client can query the remote server's FS? Why would the client be interested in that?
This makes sense... A client can provide a kind of "virtual FS" to the remote-running language server and the server can then query the VFS. |
Ah, if the entire project is also remote, then it makes sense as a client would have to discover the directory layout somehow. |
Is anyone working actively on this? It would be amazing to have this feature in order to make my vscode extension work as a web extension (it relies on a language server that needs to read files). |
…lighting You can find more information about virtual workspaces here: https://code.visualstudio.com/api/extension-guides/virtual-workspaces The LSP does not support access to virtual resources: microsoft/language-server-protocol#1264 As a result, we cannot provide much in the way of features since the extension relies on the LSP for every provider. While we cannot provide any features from the @angular/language-server, we still can provide "limited" support to enable syntax highlighting in virtual workspaces.
…lighting You can find more information about virtual workspaces here: https://code.visualstudio.com/api/extension-guides/virtual-workspaces The LSP does not support access to virtual resources: microsoft/language-server-protocol#1264 As a result, we cannot provide much in the way of features since the extension relies on the LSP for every provider. While we cannot provide any features from the @angular/language-server, we still can provide "limited" support to enable syntax highlighting in virtual workspaces.
…lighting (#1694) You can find more information about virtual workspaces here: https://code.visualstudio.com/api/extension-guides/virtual-workspaces The LSP does not support access to virtual resources: microsoft/language-server-protocol#1264 As a result, we cannot provide much in the way of features since the extension relies on the LSP for every provider. While we cannot provide any features from the @angular/language-server, we still can provide "limited" support to enable syntax highlighting in virtual workspaces.
I would love to see this. One possible use case is if your language server has a decompiler built in. The language server would be able to reference things in the decompiled version of the file to the editor without needing to place decompiled sources into the filesystem. |
Just to make sure I understand this issue: Virtual file systems exist in VSCode's memory. Language servers run as a separate process so they can't read that memory and therefore can't access the virtual file system. The lsp protocol handles transferring the text of the current file being worked between the two so the language server will be able to process that just fine. It's the references to other files in the form of includes or other project references that will break because it can't resolve a virtual file path. My question then is - does VS code send these uri's across to the language server at all or do they get filtered out? I'm working on an internal use only language server. What I'm wondering is if VS code will send across the full Uri is there anything stopping me from adding logic to handle the virtual file system in my language server as well? (beyond the duplication of work of course and logic needed to keep the language server and client in sync) |
Yes that's right.
In this example, `scheme: 'file'` filters out virtual files, if you remove
it then the LSP will receive the virtual files as well.
https://code.visualstudio.com/api/language-extensions/language-server-extension-guide
…On Thu, 17 Nov 2022, 19:01 nelak2, ***@***.***> wrote:
Just to make sure I understand this issue: Virtual file systems exist in
VSCode's memory. Language servers run as a separate process so they can't
read that memory and therefore can't access the virtual file system. The
lsp protocol handles transferring the text of the current file being worked
between the two so the language server will be able to process that just
fine. It's the references to other files in the form of includes or other
project references that will break because it can't resolve a virtual file
path.
My question then is - does VS code send these uri's across to the language
server at all or do they get filtered out? I'm working on an internal use
only language server. What I'm wondering is if VS code will send across the
full Uri is there anything stopping me from adding logic to handle the
virtual file system in my language server as well? (beyond the duplication
of work of course and logic needed to keep the language server and client
in sync)
—
Reply to this email directly, view it on GitHub
<#1264 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALKZLXLXGVK2CMZKRYUFVLWIZ6JXANCNFSM44RBU3RQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Not sure if this is the right place to comment so please redirect if necessary. My use case is I'm trying to port an existing node.js Language Server to a Web Extension. I've got the basics working thanks to the useful sample however the challenge is now how to implement global (cross file) consistency checks for my language (think import checking etc). I can no longer use Is it possible to implement cross-file consistency checks within a web extension, or will it have to operate in a degraded "single file" mode? |
@dselman I had the same issue while porting an LSP server (written in Rust) to the web through WASM. Feel free to DM me on twitter for more details |
@hugocaillard is the porting of the LSP Server to WASM available on Github. We are working on WASM support for VS Code and I would be interested in looking at what you did. Our implementation is here https://github.com/microsoft/vscode-wasm and an extension that executes Python in the Browser is here: https://github.com/microsoft/vscode-python-web-wasm |
@dbaeumer Yes, and we made a blog post about it: https://www.hiro.so/blog/write-clarity-smart-contracts-with-zero-installations-how-we-built-an-in-browser-language-server-using-wasm. Everything is in this repo: https://github.com/hirosystems/clarinet The LSP server wasn't build for web from the ground up and the project is still under active development, but it's running in production and used by many developers every days (marketplace) |
@hugocaillard thanks to your code I now have something working. When the Language Server is initialised it requests that the client open all the |
@dselman Awesome, glad it helps! In the end you probably won't need to trigger false |
@hugocaillard thanks for the pointers. Looks actually really cool. Do you know if your RUST code compiles to WASM-WASI. If so, you could get rid of all your custom file system provider calls. What I implemented is a WASI host that maps the whole WASI API to the VS Code API. So you can right normal Rust, C/C++ code with normal file system operations and it will transparently be mapped to the VS Code file system API. What we want to achieve is that someone can take a normal Rust, ... program compile it down to WASM_WASI and run it inside VS Code where the file system available in the WASM execution is VS Code's workspace file system (and more since the vscode-wasm implementation support arbitrary mount points) |
@dbaeumer this sounds great! I'm looking at the code at https://github.com/microsoft/vscode-wasm/tree/a703168627ea8937829add349055a16640962227/wasm-wasi - do I understand correctly that the npm package here contains the VS Code WASI bindings, and that package wraps/hosts the CPython wasm binary in a way that provides it with the implementations for those file APIs? (eg. the compilation of CPython is just standard WASM/WASI and doesn't need anything VS Code-specific at compile time)? |
Yes, but you need sync-api-client and sync-api-service as well which implements the VS Code API in a sync way since WASI is sync :-). You might want to look inside |
I did wonder how that would work, thanks for the pointers! I don't know how likely it is that the Dart server will ever compile to wasm, but it's good to know that if it does, it may not need as many changes as I'd thought to be able to handle some of these use cases. Thanks! 🙂 |
In case you didn't notice Dirk's demo was via vscode.dev, WASI works anywhere WebAssembly works, so both browser and Node in our case. Think of WASI as POSIX for WebAssembly; it's just a spec and WebAssembly runtimes implement that spec to let code do stuff in a secure, portable way like accessing files. In other words, WASI works wherever VS Code works, desktop and web. 🙂 |
What are the odds that we can get some of @NTaylorMullen 's suggestions into 3.18? |
We would need someone who drives this in both the spec and an implementation. |
Maybe I am wrong, but I am not convinced that things like this would scale well:
That's ok for what language servers do now, but the mere client FS access suggests a more involved/complete source code analysis by the language server which in turn sounds a lot like what also a debugger needs (in-editor expression evaluation for example). Which may eventually make it interesting to somehow integrate LSP and debugging/runtime like the Debug Adapter Protocol. Which in turn might require a fully fledged parallel FS with locking, links, access rights and so on which is not necessarily trivial to implement. Instead, an IDE may configure a local FS server like SSH FS and the server may access it like any other local FS. Extending LSP to support file lock/update notifications might be useful in the case of operations like refactoring. Then, I did not study the subject too much and maybe that shows. |
For simplicity reason we might want to think about starting with a read only access on the server. This might handle most use cases. |
I think that makes the most sense. To me, a language server is intended to provide contextual data about a file to an editing tool, not be the editing tool itself. |
How a custom read-only FS tied to LSP is more simple than for example LDAP (initialized or tunneled by LSP), when it is LDAP which already has a lot of libraries and tools virtually everywhere from client JS to server Java? Not an opinion, just a question. |
On a second thought, a simple file read access as proposed by dbaeumer might still serve a lot of functions without, depending on the approach,
|
So perhaps you'd find this interesting https://news.ycombinator.com/item?id=16875685. With such an approach, even a source-wide refactoring could be done with contextual data only and without any write access. |
Do note that the AST approach has its own drawbacks, e.g., you need to make sure that AST representation can represent every potential structure needed for every language VS Code supports (which is a lot since it's any and all languages 😉). Plus not every e.g. refactoring will work the same for each language, so it doesn't necessarily save you from having to either re-implement or do a ton of special-casing for various languages (once again, needs to work with any language out there). |
The idea of just exposing an AST feels great in theory but I'm not sure it would work in practice. After all isn't that largely how editors handled different languages before the LSP? Not to say that it's inherently the wrong approach or that approach wouldn't have worked if there was a standard protocol around it but in general that approach was explored for decades without a standard developing or without editors being full of special handling for different languages. My conclusion after reading that discussion is that the world might need a language server framework to help language server developers build their AST which can be used by framework provided default implementations of common LSP features. |
Yes, the "ton of special casing" can be a problem which may happen when a protocol tries to actually define in detail the AST layer, in order to put above it yet another layer of generic language-independent operations, which the link seems to suggest. In order to avoid the problem in question, AST could be an otherwise undefined layer above the raw edited files. LSP would only provide a grammar-independent low-level API for a bidirectional translating service raw <-> AST and possibly its own example or default implementation of a "typical" LL(k) translating service. Such services could reside by default on the IDE side but the server could use any independent service on its side. Examples of what could be done when a grammar with error recovery and whitespace handling is transferred to the said LL(k) service:
See that I do not have much experience with language protocols, so I can miss some detail here. |
Is anybody currently working on this? In particular, I'm interested in the server being able to provide file contents for some virtual files (and being able to include URIs for the scheme it uses in other requests - for example being able to Go-to-Definition from a real I think @dbaeumer's comment above:
... probably covers what I need. If I understand correctly, I think VS Code also already has implementation for this ( I may be interested in helping (with this narrower-scoped version), but I don't want to duplicate effort if anything is already in progress. |
For prior art, jdt.ls implements this in a custom thing. In fact they used to send their |
What JDT-LS implements is more or less what has already been long discussed in #336 , a custom operation to attempt resolving of URI (of whichever scheme that client cannot process directly, in JDT-LS it's |
https://code.visualstudio.com/api/extension-guides/virtual-workspaces currently states
Which brings us here. What is going on?? |
Perhaps the LSIF format will help:
The Project Context looks like it will help enumerate files/folders The Embedding Contents feature could be used for retrieving the contents of a given file.
The explanation of the feature makes it sound like it is specifically for virtual files. If it also included something to the effect of "This can also be used to facilitate web-based editors that lack filesystem access" @dbaeumer this appears to be your baby, thoughts? |
Currently servers are restricted to read files from their local file systems. LSP should offer ways that servers can:
The text was updated successfully, but these errors were encountered: