-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Added experimental language server #3635
base: master
Are you sure you want to change the base?
Conversation
bc3011e
to
8c3cd79
Compare
❎ NetbeansLanguage Server on Netbeans (currently no preview support, this will unfortunately most likely require a custom plugin):
State of integration
means the default LanguageServer implementation of Netbeans is very limited for the Moment. Quirks
|
✔️ Visual Studio Code
State of Integration
|
✔️ vimInstallation: Using vim Ale (https://github.com/dense-analysis/ale) with added SCAD language (https://github.com/Tomatower/ale/tree/lsp-openscad NOT MAINTAINED! - will have to do a PR after this is merged.) State of Integration
|
✔️ emacsInstallation: Use this fork of State of Integration
Thank you @Lenbok for the emacs integration! |
✔️ atomInstallation: Somehow hack together a minimal LSP server, either as host or as client mode. If you ask me nicely I can give some source code. But it is barely working. State of Integration
|
🟡 Netbeans (with plugin)
State of integration
means the LanguageServer implementation of Netbeans is very limited for the Moment. Quirks
|
ad486b5
to
17c6573
Compare
I can help test any emacs lsp integration |
BTW, I've currently been using this small emacs extension I wrote for controlling the openscad gui from within emacs: https://github.com/Lenbok/scad-dbus - it uses DBUS for the IPC mechanism (linux only), but if your LSP server provides for equivalent control of the scad GUI that would probably be a step forward for other platforms. Is that within scope of an LSP server? |
UI control, which is provided via DBUS is not scope of the LSP. The dbus interface will still be usable if you use the LSP. I would be very happy if someone can help me out in testing / developing the extension for emacs |
Yeah, I thought that UI manipulation would probably be out of scope for an LSP server, but saw you had some comments about it in the PR. I will try and have a play with your preliminary code over the weekend, thanks for the pointer! |
f420c33
to
4ff41af
Compare
@Tomatower I figured how how to send the
|
thanks for the test, I will look into it! |
c5d9e67
to
cd72c07
Compare
I saw your force push and had another try - the extra logging helped. Looks like I was sending the preview with the incorrect message structure (you can see in my paste above, I had the uri inside a textDocument element). Once I rearranged the params correctly it previews. However, even though it shows the preview, I noticed that the openscad app itself doesn't seem to know the file is loaded. By which I mean if I then switch to the GUI and tell it to do a final render (and export stl, etc) - it still thinks it's looking at an empty "Untitled.scad" and the console warns: "No top level geometry to render". Do you have a suggestion? BTW, You can update the "Emacs" section above to indicate that TextDocument sync, and Diagnostics are working. Go To Code isn't currently implemented in lsp-mode (emacs-lsp/lsp-mode#2459). Log Messages seem to be currently disabled in your PR? (I also noticed that your initial checkbox in the PR description mentions a This is coming along nicely, and is already quite handy! |
Thanks - glad it helped, I did not have the time to test this enough to tell you! As you can see in the message log, the language server client (emacs) is sending the document content to openscad in a This was a deliberate decision, since opening the file in openscad opens pandoras box of parallel editing the same document in two editors - which I wanted to avoid. |
I should also mention that I don't like the fact that when you run openscad as an LSP server, it permanently overwrites the user's preference for whether to show the editor and use automatic reload and preview. This makes it hard to switch between using the LSP server and using openscad standalone. It should only alter those settings in a non-persistent manner. |
@Tomatower Have you had any time to take this feature any further? |
I did not yet have any real issues with my own setup (where I use openscad as LSP + vscode), but I did not yet have the time to fix up the preferences-issue you pointed out. |
Can you describe your workflow in more detail, in terms of where openscad gets started, when and how you trigger previews / renders / STL exports etc, and how that works for multi-file projects? Here's my workflow prior to this PR:
Here's the workflow I've been using with this PR:
With this workflow it would be nice if the lsp-server didn't mess with the user preferences (and even better if it could start headless without a GUI at all). Alternatively I could just use the GUI started by lsp-server and hook into emacs so that it had a notion of the "primary scad file" and whenever any scad file in the project was saved it issued the Do you have any suggestions? |
Not sure what's missing here, but would be amazing to be able to use this in the OpenSCAD Web Demo (which uses the Monaco editor + some dirty regexps for completion right now). |
As an alternative take on a language server for openscad, see https://github.com/dzhu/openscad-language-server (it doesn't require openscad itself). |
I have implemented a base structure for Microsofts Language Server Protocol (https://langserver.org).
Alongside the basic protocol parsing and error message generation it currently only supports 2 things:
This PR has to be completed with a lot more implementations: such as utilizing the AST-Trees for context sensitive autocomplete information and keeping track of open and modified fieles in vscode in order to render them without saving.
I would like to get some feedback on how I integrated it into the remaining codebase so far, and maybe somebody has more ideas on how we can control the openscad window from an external editor.
Open Questions
LanguageServerInterface
to the first opened window. Is that a limitation?ToDo
--lsp-*
flag)window/showDocument
textDocument/didOpen
,textDocument/didChange
,textDocument/didClose
textDocument/publishDiagnostics
window/logMessage
textDocument/documentSymbol
(required for Netbeans)--lsp-stdio
cmdline switch--lsp-listen PORT
cmdline switch--lsp-connect PORT
$openscad/preview
followed up by #3648
closes #2629