Thanks Chris, this is very helpful and appreciated,  Some more below..

Eric Bresie
[email protected]


On Wed, Oct 27, 2021 at 1:47 PM Christian Lenz <[email protected]>
wrote:

> Hey Eric,
>
> probably you already found your answers, but this may also be helpful for
> others. Here are some answers to your questions from my understanding,
> please if smth is wrong, someone correct me:
>
> > I’ve seen the tutorial and appreciated the context, but was curious if
> more
> generalized perspective can be expanded on as this is a specific
> implementation.  Some of the following may be implied by the article
> indirectly but wanted to confirm it here as well.
>
> The article you are talking about (
> https://blogs.apache.org/netbeans/entry/lsp-client-demo-ba-sh) is for
> implementing a custom language
> via textmate and a language server. This seems more or less generic.


Drilling down some,I was able to find some of the more general things, as
well as based on previous discussions.
For this I was talking about general "sub-tasks" (i.e. implement
preferences, handling different "versions", execution, autocompletion,
etc.).

For textmate it is, for LSP maybe also but not for all LSP implementations
> out there
> (
> https://microsoft.github.io/language-server-protocol/implementors/servers/).
>


So is this saying the LSP may already provide some aspects of what the
textmate highlighting functionality?


> A friend of mine tried to implement the omnisharp LSP into NetBeans
> but he needed to updaate the eclipse lsp. Please see the repo here why and
> what he did: https://github.com/ranSprd/netbeans-lsp-client-fork.
>

Will look at this to see more.


> I also had a talk with a developer. They said that the LSP is more or less
> generic but as we all know, you can implement your own stuff into it,
> what might break the concept of that. So it could be, that you need to add
> specific code for each LSP anyway but should be not that much.
>
> Not each language needs a LSP. Textmate and LSP are 2 different things.
> Maybe the LSP also uses the same textmate files or others to parse the file,
> but you can add languages with textmate without having a LSP. I did this
> for example: https://github.com/Chris2011/netbeans-textmate-files


> But that means, that you just have basic syntax highlighting, thats it.


 I found the python textmate from above and was able to get some basic
language highlighting working, so this was very helpful.

The LSP implementation in NetBeans, hopefully will work with most of the
> stuff,
> didn't test it yet, but I think we need to be up to date with all
> dependencies and mentioned above for the OmniSharp LS.
>

Is a ticket to update that needed?


> > Assume if a server is not available then one may need to be implemented.
> Assume to do this would require compliance with LSP interface of some type
> and if so where can this be found?  Is there interface defined in Netbeans
> which can be extended or implemented from?
>
> Yes, if there is no LS for a specific language is available, we or someone
> else needs to create one. But step by step. For doing that, I would prefer
> to read about the stuff at the MS page:
> https://microsoft.github.io/language-server-protocol/. But I think for
> most of the langauges, there is one.
> I also find one for NixOS nix config files.
>
>
> > If an server is available how should that be brought in?  Add a
> dependency
> which gets pulled in with maybe some wrapper layer having it?
>
> If a server is available, you should see the tutorial from Jan in which he
> called just the command line tool. In the example it is node but could be
> any exe or CLI tool that you want. As long as you post the arguments
> correctly.
>

Started trying to use one of the implementations which in the case of
python involves executing a python script.  After that I'm not really sure
if this is working or not.  I assume it depends on specific servers but
assume when starting up the LSP, it awaits for "LSP" calls and responses
back.  So how are those triggered?  For example, for autocompletion, what
triggers (and what specific call) from "autocomplete client" to call to the
"LSP Server" running in the background?

> In what context does the “server” get started up/loaded within Netbeans?
> Are there specific triggers to start it (i.e. when working on a specific
> file type of the given language, if the language support is “active”, at
> startup, or some other trigger)?
>
> On the last sentence of the tutorial it says: Caveat: the language server
> is started only for files that are inside a project, so create (any) new
> project, and inside the project, put a shell file. E.g. copy "bin/netbeans"
> as "test.sh" into the project. Open it in the editor - there should be
> syntax highlighting, Navigator, and code completion should show something,
> etc.
>

With what I've implemented so far, the coloration works but not the code
completion.  Assume this is where the LSP needs to pick up some of the
workload.


> That means that you need to have a project and files inside. If you open a
> file, you can see a subprocess under netbeans starts. You can test this
> with a HTML project and a TypeScript file. LSP's concept as I understood it
> correct or maybe it is just our implementation is one server per project.
> So if you open multiple .ts files in one project, just one language server
> started. If you open a second project with a ts file inside and you open
> this, a second language server started.
>
>
> > I seem to recall in the preference section there is the ability to define
> an LSP support.  How does this interact with the new language implemented
> here?  In other words, does something have to be defined and added so that
> it includes in that area?  Does the user have to manually define that (I
> would hope not but maybe initially) and link up the LSP?
>
> I was also a bit confused with the new options UI for language servers. I
> think it would be better to split them up or call them "Custom Language
> Implementation". You can add there a new custom language by adding a
> json/xml file to be parsed. A name, an icon and a language server. That
> means,
> that everything should work out of the box, but I didn't test the LSP
> implementation. Just added all langauges, that I wanted to NetBeans.
>

So is it possible to take one of the "textmate" grammars and use that in
the "LSP UI"?  Pick some language X, create an "X" entry in the LSP
section, link up an icon, and put the context from "tmX.json" in there?

> How is the grammar (tm) linked up?  Is that supported by the server or
> does
> the server link to the external grammar?  So if there is an “external
> implemented server”, does this mean limited or no coverage of the grammar
> would have to be considered?
>
> Back to that, what I already wrote, both the textmate grammar file and the
> lsp are not coupled in NetBeans. The LSP has their own parser, maybe they
> are also based on the given textmate, but not from NetBeans. You can have a
> look into a LSP and search for the parser and you will see that.
>
> Okay...I have the tm python working but now I guess looking in the LSP to
see how it works.  That said, in the case of the Python LSP implementation,
this is a python module running which leads me to believe, what would the
interface between that "running python started by python code" link up with
the netbeans internal?


> > What client interfaces need to be implemented and where are they defined?
> Does the client also need knowledge of the grammar in some way?
>
> I have no idea what that means, sry about that.
>

I may be repeating myself a little but..., if "code completion" is needed,
while typing assume some handling of keystroke in the editor needs to
trigger and get handled, which would query for possible "completion" token
at the time.  How does that get triggered and then how does that interact
with the LSP server running?

>
> > Assume the “mime-type” may need to be based on standardized ‘mime-types”
> for a given language.  Is there a sources to use to get these
> “mime-types”?  Can always google but if there is someplace already
> established with these to base on that may also help some.
>
> The problem with the options UI, it will only add a mimetype which does
> not make any sense (text/x-ext-a, text/x-ext-b, text/x-ext-c, etc.). So I
> added my own mimetype to each filetype, where I think it makes sense. I
> dunno whether every filetype has a standard mimetype, I know there is a
> list somewhere in the net but yeah.
>

Ironically, I searched and found a python mimetype module from which I was
able to determine the mimetype from that. :-)

> Assume the LSP is for language editing mainly but how do linking with a
> given compiler and/or run type action get handled?
>
> I think for building and compiling you will need a CLI to add this like
> adding node, rust or the .net CLI. I dunno whether the LSP will do this
> also but could be.
>

Assume some action (and/or UI button) is needed then which would execute
the CLI command then right?

> Assume there may be need to handle setting up instances of a given
> languages compiler/runtime so where is this setup?
>
> Just create a new option where it make sense and let the user search for
> the binaries that you need as you also can see in the node implementation
> or in a could of other plugins.
>

Using nodejs/javascript as a basis and starting to try to get that working
but running into minor issues (see Public vs Friend API thread)

>
> > Depending on the language assume there may be need for additional
> plug-in/module management support (i.e. node module, Python pips, etc.).
> Or would this be in someway some kind of dependency handling functionality
> for the language?
>
> If there is smth else that you need beside the language server or the
> textmate like a package manager or whatever, you need to add this by your
> own. But should be simple. Custom nodes, adding CLIs etc.
>

For python usage, I'm trying to account for (1) different versions of
python (maybe including jython), and (2) python modules/packages (node js
uses npm so though python + pip might be a good equivalent mechanism), and
(3) debugging (this is a bigger beast but I think python may provide a
"pdb" type interface which may be usable at some point).

>
> > If in the past there was an older implementations for a given language,
> is
> it better to start over, to convert over to an LSP based merging code when
> possible or just maintain the existing updating to current standards?
> Assume this depends on the implemented language but figure I’d add as an
> extra step to start porting languages.
>
> I would say it is a matter of taste. If you think ANTLR is easy, use this.
> For me I would definitely use the newest stuff if all is working just fine.
>
> Well...I'm trying to reimplement python as an LSP, so I will see how this
pans out.

If that does work, would it be better to include it as a cluster in
mainline or as a separate plugin?  I'm leaning towards plugin at the
moment, but still in the early stages.


> Hope that helps.
>

Very much.  Thanks again.


> Cheers
>
> Chris
>
> Von: Eric Bresie
> Gesendet: Samstag, 16. Oktober 2021 16:49
> An: Netbeans Developer List
> Betreff: Re: LSP Language Server Protocol
>
> While looking on the wiki, I noticed the following.
>
>
> https://cwiki.apache.org/confluence/display/NETBEANS/Adding+New+Language+Support
>
> Perhaps discussions of writing a tutorial can be added to this to help the
> community.
>
> Eric Bresie
> [email protected]
>
>
> On Fri, Oct 8, 2021 at 7:45 AM Eric Bresie <[email protected]> wrote:
>
> > Follow up question…
> >
> > Assume the LSP is for language editing mainly but how do linking with a
> > given compiler and/or run type action get handled?
> >
> > Assume there may be need to handle setting up instances of a given
> > languages compiler/runtime so where is this setup?
> >
> > Depending on the language assume there may be need for additional
> > plug-in/module management support (i.e. node module, Python pips, etc.).
> > Or would this be in someway some kind of dependency handling
> functionality
> > for the language?
> >
> > If in the past there was an older implementations for a given language,
> is
> > it better to start over, to convert over to an LSP based merging code
> when
> > possible or just maintain the existing updating to current standards?
> > Assume this depends on the implemented language but figure I’d add as an
> > extra step to start porting languages.
> >
> > On Fri, Oct 8, 2021 at 7:34 AM Eric Bresie <[email protected]> wrote:
> >
> >> I’ve seen the tutorial and appreciated the context, but was curious if
> >> more generalized perspective can be expanded on as this is a specific
> >> implementation.  Some of the following may be implied by the article
> >> indirectly but wanted to confirm it here as well.
> >>
> >> It talks about setting up a node.js bash LSP server.  So in general,
> does
> >> each language need some sort of equivalent LSP Server ?  Or does the
> >> provided LSP in Netbeans work well enough to support other languages?
> >>
> >> Assume if a server is not available then one may need to be implemented.
> >> Assume to do this would require compliance with LSP interface of some
> type
> >> and if so where can this be found?  Is there interface defined in
> Netbeans
> >> which can be extended or implemented from?
> >>
> >> If an server is available how should that be brought in?  Add a
> >> dependency which gets pulled in with maybe some wrapper layer having it?
> >>
> >> In what context does the “server” get started up/loaded within Netbeans?
> >> Are there specific triggers to start it (i.e. when working on a specific
> >> file type of the given language, if the language support is “active”, at
> >> startup, or some other trigger)?
> >>
> >> I seem to recall in the preference section there is the ability to
> define
> >> an LSP support.  How does this interact with the new language
> implemented
> >> here?  In other words, does something have to be defined and added so
> that
> >> it includes in that area?  Does the user have to manually define that (I
> >> would hope not but maybe initially) and link up the LSP?
> >>
> >> How is the grammar (tm) linked up?  Is that supported by the server or
> >> does the server link to the external grammar?  So if there is an
> “external
> >> implemented server”, does this mean limited or no coverage of the
> grammar
> >> would have to be considered?
> >>
> >> What client interfaces need to be implemented and where are they
> >> defined?  Does the client also need knowledge of the grammar in some
> way?
> >>
> >> Assume the “mime-type” may need to be based on standardized ‘mime-types”
> >> for a given language.  Is there a sources to use to get these
> >> “mime-types”?  Can always google but if there is someplace already
> >> established with these to base on that may also help some.
> >>
> >>
> >> On Thu, Oct 7, 2021 at 1:18 AM Jaroslav Tulach <
> [email protected]>
> >> wrote:
> >>
> >>> >    - LSP <https://langserver.org/> seems to be gaining ground, but
> >>> there
> >>> >    are no tutorials, apart from Jan Lahoda's rudimental one
> >>> >    <https://blogs.apache.org/netbeans/entry/lsp-client-demo-ba-sh>.
> >>>
> >>>
> >>> Why do you call the tutorial "rudimental"? The tutorial is short, but
> it
> >>> contains grammar, syntax coloring, and LSP server. E.g. everything.
> >>> Shouldn't
> >>> you rather call the tutorial "end-to-end" guide for integrating
> >>> languages into
> >>> NetBeans via LSP?
> >>>
> >>> -jt
> >>>
> >>> PS: The only question is why people don't follow the tutorial and
> create
> >>> a new
> >>> PR with a new language integration per week?
> >>>
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [email protected]
> >>> For additional commands, e-mail: [email protected]
> >>>
> >>> For further information about the NetBeans mailing lists, visit:
> >>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
> >>>
> >>>
> >>>
> >>> --
> >> Eric Bresie
> >> [email protected]
> >>
> > --
> > Eric Bresie
> > [email protected]
> >
>
>

Reply via email to