FurqanSoftware / codemirror-languageserver

Language Server integration for CodeMirror 6
BSD 3-Clause "New" or "Revised" License
183 stars 24 forks source link

How does filename work? #8

Closed arnoson closed 2 years ago

arnoson commented 2 years ago

Not really an issue more a question:

In your example you use a filename variable in the language server setup. Can you explain how this works exactly? Right now my file will only exist in codemirror and not in a filesystem. How can I still connect a language server?

thanks, Arno

hjr265 commented 2 years ago

@arnoson In that case you can assign an arbitrary filename.

A language server usually keeps a virtual representation of a workspace within its state. And, in that workspace, your files need names. Even if you are dealing with just a single file, give it any arbitrary and reasonable name.

For example, you can just name the file "main.cpp" in the case of a C++ source file.

arnoson commented 2 years ago

Thank you for the explanation @hjr265 !

arnoson commented 2 years ago

What I still don't understand however is how the language server can access the file if it is only in memory. I watched the WS communication and it seems that the filename I choose is used as the URI that is send to my language server. The language server can't access this non-existent file und keeps returning "loading workspace 0/0".

arnoson commented 2 years ago

Nevermind, I just saw that the file content is send over WS, so my problem seems not related to this.