You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by Randamuna Namae <io...@gmail.com> on 2020/11/24 00:15:19 UTC

Question on LSP client

Hello dear community,

I'm working on integrating Apache NetBeans with Scala's LSP server and got
the basics working.

The problem I'm facing is that after starting the LSP client and
initialization is done with the Scala LSP Server, I need to send a command
to it programmatically so that it does an indexing step it needs to do. I'm
struggling to find a proper hook that gets run *after* initialization of
the LSPBindings went alright.
I'd greatly appreciate it if you could point me in the right direction.

Thanks.

Re: Question on LSP client

Posted by Randamuna Namae <io...@gmail.com>.
Following up on my self, it seems that calling a command programmatically
wont be possible after all since the LSP classes are module private.
Is there a workaround for this?

Cheers.

On Mon, Nov 23, 2020 at 9:15 PM Randamuna Namae <io...@gmail.com> wrote:

> Hello dear community,
>
> I'm working on integrating Apache NetBeans with Scala's LSP server and got
> the basics working.
>
> The problem I'm facing is that after starting the LSP client and
> initialization is done with the Scala LSP Server, I need to send a command
> to it programmatically so that it does an indexing step it needs to do. I'm
> struggling to find a proper hook that gets run *after* initialization of
> the LSPBindings went alright.
> I'd greatly appreciate it if you could point me in the right direction.
>
> Thanks.
>

Re: Question on LSP client

Posted by Randamuna Namae <io...@gmail.com>.
Hello dear community,

These past days I've been reading the LSP module code, testing possible
changes and thinking a lot on the topic.

I can't find any simple way to open up the plugin that wouldn't require big
changes (something clearly undesireable). If possible, I'd like to discuss
about possible extensions, in particular, the fact that the LSP module
relies on being friend module with so many core components is a bit that
scares me. It tells me that you cannot provide the same functionality
LSP-wise unless you're a core NetBeans module, so unless the LSP module
supports everything you might need, you're stuck not being able to do
anything about it. I say this because among the things I tried, I did try
using lsp4j directly myself and re-doing what the plugin does until I
crashed against the module-friends wall.

In the spirit of having something to show and start discussing, I did
create a minimal-changes PR that would enable my particular use case,
please take a look at https://github.com/apache/netbeans/pull/2564 .

Thank you for your time.
Cheers.


On Tue, Nov 24, 2020 at 6:05 PM Randamuna Namae <io...@gmail.com> wrote:

> Hi Jan,
>
> I was hoping you'd chime in.
>
> > I think it would be good to avoid having LSP4J classes in the API
>
> I agree, but designing such an API would be too much a task for me I think
> (I'm too new to NetBeans innards).
> From the cursory look I took, I don't think I can just minimally expose
> some API, because I'd need access to the LSPBinding and the
> WorkspaceService.
> It's probably best to give it more thought about what an extensible API
> for LSP clients could look like.
>
> > Also, I wonder why the server needs a command to start working - should
> not
> > be that done automatically? (Does it really require all LSP clients to be
> > modified to send it a command? Seems to be against the purpose of the
> > protocol.)
>
> I can more or less answer this. Their LSP server does a bit more than just
> language support by also interfacing with the BSP server [1], at the same
> time, because of the limitations of what has been standardize so far in
> LSP, they have several extensions that you wouldn't be able to leverage via
> generic protocol.
> So a text-editor integrating with Metals is expected to run some workspace
> commands to guide it [2].
>
> In some ideal world scenario for my case (the Scala LSP integration), I'd
> integrate with the BSP server myself, but for now Metals (that's the name
> of the Scala LSP server) takes care of that.
>
> [1] https://github.com/scalacenter/bsp/blob/master/docs/bsp.md
> [2]
> https://scalameta.org/metals/docs/integrations/new-editor.html#metals-server-commands
>
>
> On Tue, Nov 24, 2020 at 5:05 PM Jan Lahoda <la...@gmail.com> wrote:
>
>> FWIW, for an API, I think it would be good to avoid having LSP4J classes
>> in
>> the API. So that we can replace the library that handles the communication
>> if we need/want without breaking clients.
>>
>> Also, I wonder why the server needs a command to start working - should
>> not
>> be that done automatically? (Does it really require all LSP clients to be
>> modified to send it a command? Seems to be against the purpose of the
>> protocol.)
>>
>> Anyway - having a way to run a (registered) command would sound great to
>> me!
>>
>> Jan
>>
>>
>> On Tue, Nov 24, 2020 at 2:46 PM Randamuna Namae <io...@gmail.com>
>> wrote:
>>
>> > Alright, will do.
>> >
>> > Thanks.
>> >
>> > On Tue, Nov 24, 2020 at 8:58 AM Jaroslav Tulach <
>> jaroslav.tulach@gmail.com
>> > >
>> > wrote:
>> >
>> > > Dne úterý 24. listopadu 2020 1:15:19 CET, Randamuna Namae napsal(a):
>> > > > Hello dear community,
>> > > >
>> > > > I'm working on integrating Apache NetBeans with Scala's LSP server
>> and
>> > > got
>> > > > the basics working.
>> > >
>> > > That's great! Recently I needed to work with scala code (https://
>> > > renaissance.dev/ benchmark) and the old Scala support in NetBeans
>> 8.x is
>> > > no
>> > > longer very reliable.
>> > >
>> > > > it seems that calling a command programmatically
>> > > > wont be possible after all since the LSP classes are module private.
>> > > > Is there a workaround for this?
>> > >
>> > > Prepare a PR that opens up the API slightly and let Jan Lahoda review
>> it.
>> > > -jt
>> > >
>> > >
>> > >
>> > >
>> >
>>
>

Re: Question on LSP client

Posted by Randamuna Namae <io...@gmail.com>.
Hi Jan,

I was hoping you'd chime in.

> I think it would be good to avoid having LSP4J classes in the API

I agree, but designing such an API would be too much a task for me I think
(I'm too new to NetBeans innards).
From the cursory look I took, I don't think I can just minimally expose
some API, because I'd need access to the LSPBinding and the
WorkspaceService.
It's probably best to give it more thought about what an extensible API for
LSP clients could look like.

> Also, I wonder why the server needs a command to start working - should
not
> be that done automatically? (Does it really require all LSP clients to be
> modified to send it a command? Seems to be against the purpose of the
> protocol.)

I can more or less answer this. Their LSP server does a bit more than just
language support by also interfacing with the BSP server [1], at the same
time, because of the limitations of what has been standardize so far in
LSP, they have several extensions that you wouldn't be able to leverage via
generic protocol.
So a text-editor integrating with Metals is expected to run some workspace
commands to guide it [2].

In some ideal world scenario for my case (the Scala LSP integration), I'd
integrate with the BSP server myself, but for now Metals (that's the name
of the Scala LSP server) takes care of that.

[1] https://github.com/scalacenter/bsp/blob/master/docs/bsp.md
[2]
https://scalameta.org/metals/docs/integrations/new-editor.html#metals-server-commands


On Tue, Nov 24, 2020 at 5:05 PM Jan Lahoda <la...@gmail.com> wrote:

> FWIW, for an API, I think it would be good to avoid having LSP4J classes in
> the API. So that we can replace the library that handles the communication
> if we need/want without breaking clients.
>
> Also, I wonder why the server needs a command to start working - should not
> be that done automatically? (Does it really require all LSP clients to be
> modified to send it a command? Seems to be against the purpose of the
> protocol.)
>
> Anyway - having a way to run a (registered) command would sound great to
> me!
>
> Jan
>
>
> On Tue, Nov 24, 2020 at 2:46 PM Randamuna Namae <io...@gmail.com>
> wrote:
>
> > Alright, will do.
> >
> > Thanks.
> >
> > On Tue, Nov 24, 2020 at 8:58 AM Jaroslav Tulach <
> jaroslav.tulach@gmail.com
> > >
> > wrote:
> >
> > > Dne úterý 24. listopadu 2020 1:15:19 CET, Randamuna Namae napsal(a):
> > > > Hello dear community,
> > > >
> > > > I'm working on integrating Apache NetBeans with Scala's LSP server
> and
> > > got
> > > > the basics working.
> > >
> > > That's great! Recently I needed to work with scala code (https://
> > > renaissance.dev/ benchmark) and the old Scala support in NetBeans 8.x
> is
> > > no
> > > longer very reliable.
> > >
> > > > it seems that calling a command programmatically
> > > > wont be possible after all since the LSP classes are module private.
> > > > Is there a workaround for this?
> > >
> > > Prepare a PR that opens up the API slightly and let Jan Lahoda review
> it.
> > > -jt
> > >
> > >
> > >
> > >
> >
>

Re: Question on LSP client

Posted by Jan Lahoda <la...@gmail.com>.
FWIW, for an API, I think it would be good to avoid having LSP4J classes in
the API. So that we can replace the library that handles the communication
if we need/want without breaking clients.

Also, I wonder why the server needs a command to start working - should not
be that done automatically? (Does it really require all LSP clients to be
modified to send it a command? Seems to be against the purpose of the
protocol.)

Anyway - having a way to run a (registered) command would sound great to me!

Jan


On Tue, Nov 24, 2020 at 2:46 PM Randamuna Namae <io...@gmail.com> wrote:

> Alright, will do.
>
> Thanks.
>
> On Tue, Nov 24, 2020 at 8:58 AM Jaroslav Tulach <jaroslav.tulach@gmail.com
> >
> wrote:
>
> > Dne úterý 24. listopadu 2020 1:15:19 CET, Randamuna Namae napsal(a):
> > > Hello dear community,
> > >
> > > I'm working on integrating Apache NetBeans with Scala's LSP server and
> > got
> > > the basics working.
> >
> > That's great! Recently I needed to work with scala code (https://
> > renaissance.dev/ benchmark) and the old Scala support in NetBeans 8.x is
> > no
> > longer very reliable.
> >
> > > it seems that calling a command programmatically
> > > wont be possible after all since the LSP classes are module private.
> > > Is there a workaround for this?
> >
> > Prepare a PR that opens up the API slightly and let Jan Lahoda review it.
> > -jt
> >
> >
> >
> >
>

Re: Question on LSP client

Posted by Randamuna Namae <io...@gmail.com>.
Alright, will do.

Thanks.

On Tue, Nov 24, 2020 at 8:58 AM Jaroslav Tulach <ja...@gmail.com>
wrote:

> Dne úterý 24. listopadu 2020 1:15:19 CET, Randamuna Namae napsal(a):
> > Hello dear community,
> >
> > I'm working on integrating Apache NetBeans with Scala's LSP server and
> got
> > the basics working.
>
> That's great! Recently I needed to work with scala code (https://
> renaissance.dev/ benchmark) and the old Scala support in NetBeans 8.x is
> no
> longer very reliable.
>
> > it seems that calling a command programmatically
> > wont be possible after all since the LSP classes are module private.
> > Is there a workaround for this?
>
> Prepare a PR that opens up the API slightly and let Jan Lahoda review it.
> -jt
>
>
>
>

Re: Question on LSP client

Posted by Jaroslav Tulach <ja...@gmail.com>.
Dne úterý 24. listopadu 2020 1:15:19 CET, Randamuna Namae napsal(a):
> Hello dear community,
> 
> I'm working on integrating Apache NetBeans with Scala's LSP server and got
> the basics working.

That's great! Recently I needed to work with scala code (https://
renaissance.dev/ benchmark) and the old Scala support in NetBeans 8.x is no 
longer very reliable.

> it seems that calling a command programmatically
> wont be possible after all since the LSP classes are module private.
> Is there a workaround for this?

Prepare a PR that opens up the API slightly and let Jan Lahoda review it.
-jt




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
For additional commands, e-mail: dev-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists