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. 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/). 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.

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. 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.


> 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.


> 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. 

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.


> 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.


> 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.


> 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.


> 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 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.


> 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.


> 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.

Hope that helps.


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
ebre...@gmail.com


On Fri, Oct 8, 2021 at 7:45 AM Eric Bresie <ebre...@gmail.com> 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 <ebre...@gmail.com> 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 <jaroslav.tul...@gmail.com>
>> 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: dev-unsubscr...@netbeans.apache.org
>>> For additional commands, e-mail: dev-h...@netbeans.apache.org
>>>
>>> For further information about the NetBeans mailing lists, visit:
>>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>>
>>>
>>>
>>> --
>> Eric Bresie
>> ebre...@gmail.com
>>
> --
> Eric Bresie
> ebre...@gmail.com
>

Reply via email to