Language Server Protocol (LSP)

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

Language Server Protocol (LSP)

Farhan Ahmed
Hi,

This is new territory for me, so I just wanted to know if there’s LSP support in TextMate 2?

Best,
Farhan


_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Language Server Protocol (LSP)

Bijan
Hi, I really like the thought of having Language Server Protocol support in
Textmate 2. Textmate would clearly benefit by getting first class code
completion, code navigation, documentation view and all the other LSP
goodness.
Are there any plans for adding LSP support? Might this be something that
should be implemented as a bundle or is it something that ships with the App
itself?
VSCode, Vim, Emacs, Sublime, Atom and other Editors now offer support or
have plugins for LSP support. Would it be feasible for TM2 too?



--
Sent from: http://textmate.1073791.n5.nabble.com/textmate-users-f3.html

_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Language Server Protocol (LSP)

じょいすじょん
I second that !
This would be phenomenal.
But, it would probably require overhauling some of the completion UI to support more of what is available.


> On Jun 25, 2018, at 17:33, Bijan <[hidden email]> wrote:
>
> Hi, I really like the thought of having Language Server Protocol support in
> Textmate 2. Textmate would clearly benefit by getting first class code
> completion, code navigation, documentation view and all the other LSP
> goodness.
> Are there any plans for adding LSP support? Might this be something that
> should be implemented as a bundle or is it something that ships with the App
> itself?
> VSCode, Vim, Emacs, Sublime, Atom and other Editors now offer support or
> have plugins for LSP support. Would it be feasible for TM2 too?
>
>
>
> --
> Sent from: http://textmate.1073791.n5.nabble.com/textmate-users-f3.html
>
> _______________________________________________
> textmate mailing list
> [hidden email]
> http://lists.macromates.com/listinfo/textmate


_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Language Server Protocol (LSP)

Allan Odgaard-4
In reply to this post by Bijan

On 25 Jun 2018, at 15:33, Bijan wrote:

Are there any plans for adding LSP support? Might this be something that
should be implemented as a bundle or is it something that ships with the App
itself?

It should probably be native.

As for plans; can’t really answer that before it’s at least halfway implemented :)



_______________________________________________
textmate mailing list
[hidden email]
https://lists.macromates.com/listinfo/textmate
jrk
Reply | Threaded
Open this post in threaded view
|

Re: Language Server Protocol (LSP)

jrk
I am very interested in this (for completion, in particular). Do you have
thoughts or pointers if I wanted to take a crack, myself?



--
Sent from: http://textmate.1073791.n5.nabble.com/textmate-users-f3.html

_______________________________________________
textmate mailing list
[hidden email]
https://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Language Server Protocol (LSP)

Jacob Carlborg

On 15 Dec 2018, at 01:39, jrk <[hidden email]> wrote:

I am very interested in this (for completion, in particular). Do you have
thoughts or pointers if I wanted to take a crack, myself?

I would start by creating a socket and try to get the communication with a server working. TextMate already has an interface for showing completion results, via the Dialog plugin [1]. Not sure if you should continue to use the plugin or move that code directly into TextMate. Note, the completion interface does not support showing any documentation, as far as I can see.


-- 
/Jacob Carlborg



_______________________________________________
textmate mailing list
[hidden email]
https://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Language Server Protocol (LSP)

Bijan
Oh Textmate loaded with LSP support would be sooooo superb.

Here are some interesting links regarding this LSP support:


So basically this is the flow:


This is an example LSP plugin written for SublimeText (written in Python) https://github.com/tomv564/LSP
But this is just an editor-extension.




Am 15.12.2018 um 11:25 schrieb Jacob Carlborg <[hidden email]>:


On 15 Dec 2018, at 01:39, jrk <[hidden email]> wrote:

I am very interested in this (for completion, in particular). Do you have
thoughts or pointers if I wanted to take a crack, myself?

I would start by creating a socket and try to get the communication with a server working. TextMate already has an interface for showing completion results, via the Dialog plugin [1]. Not sure if you should continue to use the plugin or move that code directly into TextMate. Note, the completion interface does not support showing any documentation, as far as I can see.


-- 
/Jacob Carlborg


_______________________________________________
textmate mailing list
[hidden email]
https://lists.macromates.com/listinfo/textmate



_______________________________________________
textmate mailing list
[hidden email]
https://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Language Server Protocol (LSP)

f1nnix
I've started to work on rough implementation:
https://github.com/f1nnix/LSP.tmbundle
<https://github.com/f1nnix/LSP.tmbundle>  . Completion already ~works.

It would be nice, if someone could take a look at my questions about
Textmate internal bundle mechanism. Thanks.





--
Sent from: http://textmate.1073791.n5.nabble.com/textmate-users-f3.html

_______________________________________________
TextMate mailing list
[hidden email]
https://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Language Server Protocol (LSP)

Stefan Daschek
Great, thank you so much! 🚀🎉🥳 (LSP support is indeed the one single feature I’m missing so much that it would probably make me migrate away from TextMate in the foreseeable future 😔).

I think you’re referring to http://textmate.1073791.n5.nabble.com/How-to-implement-async-code-runner-building-a-LSP-client-tt32440.html ?

Unfortunately I’m not really an expert in this regard so I hope someone with more knowledge can answer your questions. Anyone? :)

s.

On 15.12.19 14:26, f1nnix wrote:
I've started to work on rough implementation: 
https://github.com/f1nnix/LSP.tmbundle
<https://github.com/f1nnix/LSP.tmbundle>  . Completion already ~works.

It would be nice, if someone could take a look at my questions about
Textmate internal bundle mechanism. Thanks. 





--
Sent from: http://textmate.1073791.n5.nabble.com/textmate-users-f3.html

_______________________________________________
TextMate mailing list
[hidden email]
https://lists.macromates.com/listinfo/textmate


_______________________________________________
TextMate mailing list
[hidden email]
https://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Language Server Protocol (LSP)

Jacob Carlborg
In reply to this post by f1nnix


On 15 Dec 2019, at 14:26, f1nnix <[hidden email]> wrote:

I've started to work on rough implementation:
https://github.com/f1nnix/LSP.tmbundle
<https://github.com/f1nnix/LSP.tmbundle>  . Completion already ~works.

It would be nice, if someone could take a look at my questions about
Textmate internal bundle mechanism. Thanks.

* To run a command in the background, you need to create a subprocess and close stdout and stderr. See [1][2] for more details.

* It’s not possible to highlight arbitrary symbols.

* Regarding diagnostic reporting, It’s not possible highlight symbols. But it’s possible to show an icon in the gutter on a specific line. When the user clicks on the icon a message will be shown. Run “mate —help” and see the “mark” related flags. It would be something like: “mate foo.rb —line 3 —set-mark error:'missing symbol’”

* The callback for open document is called "callback.document.did-open”. Set that as the semantic class of a bundle command

* Regarding your last question: "Is there a way to run a command on file opening?”. I guess it’s the same answer as the previous question. I don’t think there’s a difference between opening a document or a file.

This is a list of semantic class callbacks that I’ve managed to collect from different places:

* callback.application.did-activate
* callback.application.did-deactivate
* callback.document.binary-export
* callback.document.binary-import
* callback.document.did-change-scm-status
* callback.document.did-open
* callback.document.did-reload
* callback.document.did-save
* callback.document.export
* callback.document.import
* callback.document.will-reload
* callback.document.will-save
* callback.double-click
* callback.file-browser.action-menu
* callback.mouse-click (old)
* callback.single-click
* callback.triple-click

For mouse click callbacks, the following modifiers can be used:

* dyn.modifier.shift
* dyn.modifier.control
* dyn.modifier.option
* dyn.modifier.command

The modifiers are set in "Scope Selector".


-- 
/Jacob Carlborg



_______________________________________________
TextMate mailing list
[hidden email]
https://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Language Server Protocol (LSP)

"Uğur Özyılmazel (vigo)"
In reply to this post by f1nnix
I couldn’t run, can you please add more information about running ? also, some python packages are missing: cattrs==0.9.0

On 15 Dec 2019, at 16:26, f1nnix <[hidden email]> wrote:

I've started to work on rough implementation:
https://github.com/f1nnix/LSP.tmbundle
<https://github.com/f1nnix/LSP.tmbundle>  . Completion already ~works.

It would be nice, if someone could take a look at my questions about
Textmate internal bundle mechanism. Thanks.





--
Sent from: http://textmate.1073791.n5.nabble.com/textmate-users-f3.html

_______________________________________________
TextMate mailing list
[hidden email]
https://lists.macromates.com/listinfo/textmate



_______________________________________________
TextMate mailing list
[hidden email]
https://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Language Server Protocol (LSP)

f1nnix
Thanks everyone for interest! I'm really happy someone else find this project
useful.

Right now it's nearly impossible to use this bundle unless you *exactly*
know, how it works and what can fail. Soon I'll describe, how to run this
project "as-is". And then we'll try to implement some kind of settings to be
able to launch it somewhere except my own machine :).

Please, note two things:

1. For now I've developed it mostly to use with one particular Language
server — https://github.com/palantir/python-language-server. That means, I
rely on Python-specific things like PYTHONPATH, venv, etc. I'll try to dig
other language servers' transport interfaces and adopt this bundle to it.
But for now you will probably need to install and configure appropriate
Language servers yourself. For example, for TypeScript you'll need to
install https://github.com/theia-ide/typescript-language-server manually,
etc.
2. Right now Textmate communicates with LS over dual-bound socket proxy.
I've decided to make an intermediate proxy to handle persistent connection,
as Textmate can't run async code in a way we need — not just disconnect from
stdin/stdout, but be able to print something «back» if LS event occurs. That
adds one additional step — you'll need to lauch LSP proxy yourself in
separate terminal. I'll take a look closer on next week, maybe we would be
able to drop proxy and rely just on PID of created LS process, saved
somewhere on filesystem.

And obviously, there is just a limited subset of LS capabilities, that we
physically can implement:

* Code completion — via DIALOG popup.
* Go to definition — via `mate <file> <line>`
* Hover — via DIALOG tooltip.
* Document diagnostics — via some kind of internal HTML preview, rendered in
modal window.

But for example, we won't be able go highlight errors in code as Jacob
Carlborg stated above.



--
Sent from: http://textmate.1073791.n5.nabble.com/textmate-users-f3.html

_______________________________________________
TextMate mailing list
[hidden email]
https://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Language Server Protocol (LSP)

f1nnix
Some updates.

I've implemented simple stdio client to LS, and it works for completion
requests. Also I've made ability to setup different LS (bin and env)
variables via `.tm_properties`.

Unfortunately, it seems there's a major limitation in TM callbacks. Some of
language servers strictly require didOpen, didChange and didClose
notifications for each opened file. In other words:

1. When user __first time__ opens document from project, we should notify
Language server. Callback `callback.document.did-open` runs __every time_
document gets focus, for example it you switch tabs. It means we should
manage list of opened documents manually, which can't be done on TM side,
but can be implemented on proxy-side. So it not an actual problem, but if
there a callback for actual document first open event, it's better.

2. To get completions, we should notify sever a new document is opened (see
1) before. And when we open document, then we need to notify Language server
about it's every change as document "truth" can't be read from file since
opening.

Though specification clearly says "Note that a server’s ability to fulfill
requests is independent of whether a text document is open or closed.", some
popular language servers refuse to fulfill completion requests until
document explicitly opened.

And this means unless we are able notify server on every content change of
opened document in realtime, we can't make completion requests for major
part for Language Server implementations. Is there a way to run command on
every content change?

3. The same as 1. When document is closed, we need to notify LS about it. I
can't find any info about document.close callback
(https://github.com/textmate/textmate/search?q=callback.document.did-close&unscoped_q=callback.document.did-close&type=Commits).
Is it true there is no such callback?







--
Sent from: http://textmate.1073791.n5.nabble.com/textmate-users-f3.html

_______________________________________________
TextMate mailing list
[hidden email]
https://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Language Server Protocol (LSP)

Jacob Carlborg

On 20 Dec 2019, at 17:06, f1nnix <[hidden email]> wrote:

And this means unless we are able notify server on every content change of
opened document in realtime, we can't make completion requests for major
part for Language Server implementations. Is there a way to run command on
every content change?

Have a look at this changelog entry [1].

3. The same as 1. When document is closed, we need to notify LS about it. I
can't find any info about document.close callback
(https://github.com/textmate/textmate/search?q=callback.document.did-close&unscoped_q=callback.document.did-close&type=Commits).
Is it true there is no such callback?

No there’s no such callback. I asked about that recently. But, if you look at [1], there’s DocumentClosed, which might work.

As Allan mentioned [2], I think it’s better if the LSP support is natively implemented inside TextMate and not as a bundle.


-- 
/Jacob Carlborg



_______________________________________________
TextMate mailing list
[hidden email]
https://lists.macromates.com/listinfo/textmate