OpenSCAD language plugin for the IntelliJ platform

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

OpenSCAD language plugin for the IntelliJ platform

ncsaba
Hi all,

I recently started working on a plugin for the IntelliJ Platform (that is
the framework behind JetBrains IDEs like IntelliJ Idea, PyCharm, Android
Studio, C-Lion, etc.) supporting the OpenSCAD language, and I thought I
would publish early the result, in the idea that perhaps people on this
forum would like to use it and possibly contribute with ideas/testing or
even code.

The first version of the plugin introduces support for syntax highlighting
and code folding, plus a color scheme coming close to the original OpenSCAD
one. It was in fact accepted in the official JetBrains plugin repository, so
for those who have the latest version of Idea (or pyCharm, C-Lion, etc.) you
can install it via the Plugin manager. The plugin page is located at:

https://plugins.jetbrains.com/plugin/11198-openscad-language-support

You'll find the source code (BSD licensed) here:

https://github.com/ncsaba/idea-openscad

For further details please read the README on either one of those links.

I'm still actively working on this plugin, and more features will come in
the next weeks.

I hope it will be as useful for you as it is for me :-)

Cheers,
Csaba




--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: OpenSCAD language plugin for the IntelliJ platform

ncsaba
Hi all,

For those using one of the jetbrains intellij platform based IDE, I just
pushed a new version of the OpenSCAD language support plugin.

This version fixes the grammar/parsing issues I found, I do hope now it
comes very close to the same parsing behaviour as the original OpenSCAD
editor. One remaining known issue is that I had to mark "use" and "include"
as keywords and can't be used as parameter/variable names - but I would
argue that such usage is to be avoided anyway, try this code in the original
OpenSCAD editor:

module m(use) {
    f = use < 10;
}

It will fail with compilation error - while this works:

module m(use) {
    f = use > 10;
}

Basically OpenSCAD will match any " use <" occurences regardless where it
occurs, which is hard to avoid for a lexer which is not a parser at the same
time. In my opinion "use" and "include" should be declared keywords and deny
usage of them as identifiers.

The current version of the plugin provides a structure view with
modules/functions/declared variables, including navigation to/from source
code.

It also provides a very first and rudimentary version of code navigation: if
you press CTRL/CMD (depending on the OS you use) and hover the mouse over a
module/function call, you will get a short description of the referenced
module/function, provided there is only one single matching module/function
with that name. The lookup is currently done in all files added to the
intellij project, regardless if the file was included/used in the current
file - that will be fixed in later versions so that only included files are
considered, and the names are looked up in the right context (local modules
overriding included/built-in ones).

Looking up variable references is only partially working, it is also brute
force and only can look up declared variables and no parameters yet. It also
considers all variables with the given name in all files of the project
(this will be fixed too in future version).

There's a crude version of documentation popup too (CTRL/CMD-J or
CTRL/CMD-Q, depending on jetbrains product and OS). It will take the comment
preceding the module/function/variable declaration and show it in a popup.
This only works if there is only one candidate reference for the given
identifier, in all files of the project (will be fixed in future versions to
always work, based on context).

Built-in functions/modules are provided in skeleton files, and their
documentation is available too as a popup. I tried to include meaningful
parameter info for them (CTRL-hover mouse and wait), but this likely needs
some more work.

All in all I find that even this is very much still a work in progress, it
is better than a version with buggy grammar, that's why publishing it
unpolished.

I plan to work next on OpenSCAD run configuration (to open scad files
directly from the plugin), and library support, with the goal that
included/used files are automatically found in the OpenSCAD include paths,
and/or deployment tools which deploy the intellij modules to the OpenSCAD
library directory.

In the long term I would like to implement code for searching github for
OpenSCAD library modules, and offer installing them. There is currently (as
far as I know) no real library management for OpenSCAD, and that's a pity...

Cheers,
Csaba







--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|

Re: OpenSCAD language plugin for the IntelliJ platform

tp3
Hi!

On 11/02/2018 05:13 PM, ncsaba wrote:

> It also provides a very first and rudimentary version of code navigation: if
> you press CTRL/CMD (depending on the OS you use) and hover the mouse over a
> module/function call, you will get a short description of the referenced
> module/function, provided there is only one single matching module/function
> with that name. The lookup is currently done in all files added to the
> intellij project, regardless if the file was included/used in the current
> file - that will be fixed in later versions so that only included files are
> considered, and the names are looked up in the right context (local modules
> overriding included/built-in ones).
>
Did you consider using the Language Server Protocol? An implementation
of that in OpenSCAD should (at least in theory) give all the benefits
while being available for all IDEs supporting it. From what I see,
IntelliJ does support this.

> In the long term I would like to implement code for searching github for
> OpenSCAD library modules, and offer installing them. There is currently (as
> far as I know) no real library management for OpenSCAD, and that's a pity...
>
No there's some discussions now and then, but it seems nothing continued
further than prototype state. It would be nice to see some progress on
that topic.

ciao,
   Torsten.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: OpenSCAD language plugin for the IntelliJ platform

ncsaba
Hi,

> Did you consider using the Language Server Protocol? An implementation
> of that in OpenSCAD should (at least in theory) give all the benefits
> while being available for all IDEs supporting it. From what I see,
> IntelliJ does support this.

Well to be honest I was not aware about the existence of the Language Server
Protocol, but after a quick check it is a lot more work than what the
IntelliJ plugin needs. The IntelliJ platform is basically a framework which
implements a lot of the basics for what a language server would provide, and
a lot of the functionality needs just some simple configuration from the
plugin side. I'm going to finish the plugin and consider the LSP after that,
but I'm afraid it will be a significantly higher effort.

> No there's some discussions now and then, but it seems nothing continued
> further than prototype state. It would be nice to see some progress on
> that topic.

I have some ideas on that, but I will first finish the plugin. What is
needed for the plugin right now is a simple library support for resolving
include and use clauses. I plan to build on top of that later with library
management features.

Cheers,
Csaba





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org