liferay / liferay-intellij-plugin

Other
24 stars 30 forks source link

LSP support #111

Closed jtydhr88 closed 1 year ago

jtydhr88 commented 5 years ago

We plan to support Language Server Protocol(LSP) in all of GUI Dev Tools, such as DevStudio(Eclipse), IntelliJ IDEA, VS Code. More Information: https://langserver.org/ https://github.com/ballerina-platform/lsp4intellij https://github.com/gtache/intellij-lsp https://github.com/angelozerr/lsp4xml

dmarks2 commented 5 years ago

LSP is an interesting topic. As far as I know LSP adds code completion features to specific languages or file types. For which languages or file types do you plan to add LSP support?

jtydhr88 commented 5 years ago

hey @dmarks2 I am grateful that you are interesting on it. According to LSP doc, it has not only a ability of code completion, but also Hover, Jump to def, Find references and Diagnostics. For Liferay, it is just at beginning phase, I only worked out a demo to Greg, which can give the code proposals of all properties keys in portal.properties on your custom portal-ext.properties. Now it works well on DevStudio(Eclipse) and VS Code. see the screenshots: 1

屏幕快照 2019-07-09 下午4 44 40

But I tried the LSP support of InterlliJ(the two plugins I posted before), I failed. I have no idea about the reason, so I stopped it now. Just I said, right now it is just under research, but @gamerson plans use LSP in eclipse for editor features of almost file types/languages, like xml, jsp, properties, etc. For intelliJ side, we would not have a detailed plan until I figure out the infrastructure and reason of my failed before.

jtydhr88 commented 5 years ago

If you would like to see more code details, you can check my prs here: server (blade) https://github.com/gamerson/liferay-blade-cli/pull/873 client (eclipse/vs code) https://github.com/gamerson/liferay-ide/pull/4601 Let me know if you want more steps to try it.

dmarks2 commented 5 years ago

Hey @jtydhr88, I've implemented a small solution to make LSP work with IntelliJ.

To make it work, I had to make some small changes in the server part, see PR here: https://github.com/jtydhr88/liferay-blade-cli/pull/39

My implementation in the IntelliJ plugin can be found in this PR: https://github.com/jtydhr88/liferay-intellij-plugin/pull/83

For the portal-ext.properties files code completion now works:

image

jtydhr88 commented 5 years ago

hey @dmarks2 That's super cool! really thanks for figuring out this issue! I will have a discussion with Greg about the further plan of LSP for Liferay Dev Tool.

dmarks2 commented 5 years ago

hey @jtydhr88,

any progress here? Did you discuss further plans for LSP with @gamerson?

gamerson commented 5 years ago

Hey Dominik,

Sorry for the delay. But we need to review the plans for an official LSP for Liferay and determine what all it should include. Just having a LSP for Liferay that only supports portal-ext.properties editing I don't feel is enough for us to try to release something. Its good for POC, but I want to try to see what else makes sense to incorporate for liferay projects. I would love for you to join the discussion. Perhaps we can have a skype chat about it at some point. I'll be in touch.

On Fri, Aug 23, 2019 at 7:55 AM Dominik Marks notifications@github.com wrote:

hey @jtydhr88 https://github.com/jtydhr88,

any progress here? Did you discuss further plans for LSP with @gamerson https://github.com/gamerson?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/liferay/liferay-intellij-plugin/issues/111?email_source=notifications&email_token=AAERKFI6K4C7WKEQG3F3E4TQF7M3BA5CNFSM4IEWN67KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5AEBHY#issuecomment-524304543, or mute the thread https://github.com/notifications/unsubscribe-auth/AAERKFNTOYMISAZWNTE47TLQF7M3BANCNFSM4IEWN67A .

-- Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com

dmarks2 commented 5 years ago

@gamerson I would like to join the discussion about what can be done with LSP. Just tell me when and how you would like to discuss / how to collect ideas about it.

dmarks2 commented 5 years ago

Hey @gamerson,

I already discussed with @jtydhr88 that there are plans to add XML support and JSP taglib support to LSP.

Some additional ideas I have:

jtydhr88 commented 5 years ago

hey @dmarks2 here is the latest code I done for properties files support https://github.com/gamerson/liferay-blade-cli/pull/888 I am working on xml support right now

dmarks2 commented 5 years ago

@jtydhr88 I had a look at your implementation.

Just because I was interested I tried to integrate the Language Server into Sublime Text 3. However Sublime Text expects that the Server part provides a network socket (new ServerSocket()). However your current implementation tries to open a network connection to the client (new Socket()). Is that the correct way for the communication between an LSP Server and LSP client? Shouldn't it be the other way round?

jtydhr88 commented 5 years ago

@dmarks2 I did this way because the lsp4j expected. I noticed this issue before(btw, lsp4xml also need to do the same as Sublime Text 3 you mentioned). I can add new param may called --server/client to decide what we should create, new ServerSocket() or new Socket(), later this week.

jtydhr88 commented 5 years ago

hey @dmarks2 I added parameter in here https://github.com/gamerson/liferay-blade-cli/pull/890 it expects that command is java -jar $bladeJarFilePath languageServer -p $port --socket-server let me know if you have any problems on it.

dmarks2 commented 5 years ago

hey @jtydhr88, I tried your implementation with Sublime Text 3. At least it does something, however code completion for e.g. portal-ext.properties looks a litte bit strange:

image

jtydhr88 commented 5 years ago

It looks like that they are possible values of the key “include-and-override”, see here https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/portal.properties I guess it is a bug of my code, can you try another supported file like gradle.properties in one Liferay workspace?

dmarks2 commented 5 years ago

@jtydhr88 I tried with gradle.properties and .blade.properties. It is still the same here, the code completion seems to suggest some values but at the wrong position etc.

Here's a screenshot from a .blade.properties:

image

If you want to try it yourself, here is my LSP.sublime-settings file:

// Settings in here override those in "LSP/LSP.sublime-settings",
{
  "log_debug": true,    
  "log_stderr": true,
  "log_payloads": true,
  "only_show_lsp_completions": true,
  "clients": 
    {
        "liferay":
        {
            "command": [ "java", "-jar", "F:/temp/blade.jar", "languageServer", "-p", "12345", "--socket-server" ],
            "scopes": ["source.java-props", "meta.property.java-props", "string.unquoted.java-props"],
            "syntaxes": ["Packages/Java/JavaProperties.sublime-syntax"],
            "languageId": "JavaProperties",
            "tcp_port": 12345,
            "enabled": true
        }
    }
}
jtydhr88 commented 5 years ago

@dmarks2 it is a known issue and because the content is in draft when you type "=" to trigger proposals. (in another words, you have to "save" before you type "=", and then it should call the correct suggestions) @Seiphon already sent the fix on it to me today, but I don't have time to review. see here https://github.com/jtydhr88/liferay-blade-cli/pull/42 I will merge the change next week if it works well.

jtydhr88 commented 5 years ago

@dmarks2 do you have gmail and I can share a document about LSP with you?

jtydhr88 commented 1 year ago

close it as looks like no plan to implement it anymore