lsp4intellij icon indicating copy to clipboard operation
lsp4intellij copied to clipboard

Migrating from intellij-lsp to lsp4intellij

Open nixel2007 opened this issue 6 years ago • 51 comments

Hello!

I would like to migrate from scala intellij-lsp to your fork (and give some feedback, as you requested it in README :) ).

Do you support all basic capabilities of old intellij-lsp? At least i need a diagnostics, completion, hover and formatting capabilities.

Do i need to include something more than gradle/mvn dependency from jitpack (e.g.)? https://jitpack.io/#NipunaRanasinghe/lsp4intellij

As i can see there is similar to intellij-lsp registration process - via preloading task and server definition. No more surprises?

P.S. Big THANK YOU for your work. fork at intellij-community didn't shoot (and i haven't enough free time for this). but i reeaaaly would like to switch to your fork.

nixel2007 avatar Feb 13 '19 05:02 nixel2007

Hi @nixel2007! First of all, thank you for your interest. It would be a great help if you could test this with your language server and provide some feedback as I requested.

I'm planning to implement all the existing features of the scala plugin. As I mentioned in the README, I've implemented code completion support so far and still working on the other features(currently working on diagnostics in the develop branch).

As i can see there is similar to intellij-lsp registration process - via preloading task and server definition. No more surprises?

Yes of course! The current implementation is almost same as the Scala plugin ( A big thank goes to @gtache for his awesome work! ). I've used raw command server definition in the lsp4intellij-plugin example, but other options should work as well.

Do i need to include something more than gradle/mvn dependency from jitpack (e.g.)? https://jitpack.io/#NipunaRanasinghe/lsp4intellij

I tried but unfortunately jitpack didn't work for me :( I'll let you know once that issue is sorted. I'm currently using the local jar file.

NipunaRanasinghe avatar Feb 13 '19 12:02 NipunaRanasinghe

Looks like you've faced with the same issue - https://github.com/jitpack/jitpack.io/issues/3737

nixel2007 avatar Feb 13 '19 13:02 nixel2007

Ok, thank you! i'll try to migrate in a few days.

If you randomly choose features to implement - please, implement range and document formatting next :D

nixel2007 avatar Feb 13 '19 13:02 nixel2007

Sure I can work on formatting support after completing diagnostics :D

NipunaRanasinghe avatar Feb 14 '19 06:02 NipunaRanasinghe

No luck this time.

WARN: Lsp4IntelliJ not loaded: until build 173.SNAPSHOT < IC-183.4284.85

I'm using IDEA IC 2018.3.4. Plugin is targeted to >= 183.4284.85

Commit with migrating - https://github.com/1c-syntax/intellij-language-1c-bsl/commit/6b65197020bb50448e786b5ce19830aa6f2853d4

nixel2007 avatar Feb 15 '19 08:02 nixel2007

@nixel2007 Could you please try after changing the build number range in your plugin.xml? :) This might help https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html

And please note that I've tested the library only for 173+ . Will add the compatibility information soon.

NipunaRanasinghe avatar Feb 20 '19 11:02 NipunaRanasinghe

I've seen your fixes about plugin.xml and untilBuild in gradle. I'll check it asap. Thanks!

nixel2007 avatar Feb 21 '19 06:02 nixel2007

I've also updated the README. Hope it'll help :)

NipunaRanasinghe avatar Feb 21 '19 06:02 NipunaRanasinghe

Could you provide some info about LSPExtensionManager? https://github.com/NipunaRanasinghe/lsp4intellij/blob/de60747f47e0240f7298f1266614f89d6c41230a/src/main/java/com/github/lsp4intellij/extensions/LSPExtensionManager.java

what is designed for? i don't implement it (cause it was not needed in intellij-lsp) and (to be honest) not sure should i implement it and how.

nixel2007 avatar Feb 25 '19 12:02 nixel2007

@nixel2007 You don't have to implement it at all, If don't have any language server protocol extensions (custom capabilities in addition to the Language server Specification) in your language server :)

That capability is designed to support custom request/response and notifications, which are not in the language server protocol specification. Anyway I'll add a detailed description later, since it is still an experimental component.

Until then all you need to do is,

  • Add lsp4intellij as dependency via jitpack
  • Update your plugin.xml by registering the capabilities (Refer https://github.com/NipunaRanasinghe/lsp4intellij-plugin/blob/master/src/main/resources/META-INF/plugin.xml)
  • Add a preloading activity to register your language server definition.

and thats all! :)

NipunaRanasinghe avatar Feb 25 '19 12:02 NipunaRanasinghe

I did all this steps but don't see any diagnostics from my language server. I'll setup a lsp launcher tracer to get some logs and figure out if my lang server even starts.

ref - https://github.com/1c-syntax/intellij-language-1c-bsl/commit/a9f3b2a5d63d9e8083ff0ff46e0d7b61be2aa44e

nixel2007 avatar Feb 25 '19 12:02 nixel2007

@nixel2007 That would be great if you can verify that. I guess you are also using the RawCommandServer Definition option?

NipunaRanasinghe avatar Feb 25 '19 13:02 NipunaRanasinghe

@NipunaRanasinghe nope. ExeLanguageServerDefinition - https://github.com/1c-syntax/intellij-language-1c-bsl/blob/feature/lsp4intellij/src/main/java/org/github/_1c_syntax/intellij/bsl/BSLPreloadingActivity.java#L89

java -jar path/to/language-server.jar

nixel2007 avatar Feb 25 '19 13:02 nixel2007

@nixel2007 could you please try for only one file extension instead of two, since I've still not implemented support for multiple file extensions? :/

i.e.

 String extensions = BSLFileType.INSTANCE.getDefaultExtension(); 

NipunaRanasinghe avatar Feb 25 '19 13:02 NipunaRanasinghe

One more thing, you must add the IntelliJLanguageClient as a application component as follows, since it is the main class.

https://github.com/NipunaRanasinghe/lsp4intellij-plugin/blob/95ecedb19364408acf74c62ac26d59efa2466789/src/main/resources/META-INF/plugin.xml#L30

NipunaRanasinghe avatar Feb 25 '19 13:02 NipunaRanasinghe

One more thing, you must add the IntelliJLanguageClient as a application component as follows, since it is the main class.

oh. i missed it. ok, i'll try it.

could you please try for only one file extension instead of two, since I've still not implemented support for multiple file extensions? :/

sure. may i create an issue for it to be notified, when it'll be done?

nixel2007 avatar Feb 25 '19 14:02 nixel2007

sure. may i create an issue for it to be notified, when it'll be done?

Sure, please do :) Probably I can fix that within next 2, 3 days I guess

NipunaRanasinghe avatar Feb 25 '19 14:02 NipunaRanasinghe

Okay, adding missed component to plugin.xml and one extension did the trick. but... I have exeptions in idea.log (and server shutdown).

idea.log:

2019-02-25 20:29:39,515 [   9691]   INFO - ntellij.IntellijLanguageClient - Added definition for command : path java args : -jar D:\git\1c-syntax\bsl-language-server\build\libs\bsl-language-server-0.4.0-dev+25.dev.jar --diagnosticLanguage ru 
2019-02-25 20:29:39,516 [   9692]   INFO - .openapi.application.Preloader - org.github._1c_syntax.intellij.bsl.BSLPreloadingActivity took 7 ms 
2019-02-25 20:29:39,525 [   9701]   INFO - penapi.project.DumbServiceImpl - Running dumb mode task: com.intellij.util.indexing.UnindexedFilesUpdater@66a1e4a6 
2019-02-25 20:29:39,535 [   9711]   INFO - ntellij.internal.IconsLoadTime - IMG load time: ide_startup=10,43ms, average=0,58ms, median=0,83ms; number of icons: 18 
2019-02-25 20:29:39,535 [   9711]   INFO - ntellij.internal.IconsLoadTime - SVG load time: ide_startup=151,86ms, average=4,22ms, median=6,04ms; number of icons: 36 
2019-02-25 20:29:39,601 [   9777]   INFO - .diagnostic.PerformanceWatcher - Pushing properties took 74ms; general responsiveness: ok; EDT responsiveness: ok 
2019-02-25 20:29:40,010 [  10186]   INFO - ntellij.IntellijLanguageClient - Added serverDefinitions [command : path java args : -jar D:\git\1c-syntax\bsl-language-server\build\libs\bsl-language-server-0.4.0-dev+25.dev.jar --diagnosticLanguage ru] from plugins 
2019-02-25 20:29:40,013 [  10189]   INFO - ntellij.IntellijLanguageClient - Opened РаботаСКоннекторами.os 
2019-02-25 20:29:40,014 [  10190]   INFO - ntellij.IntellijLanguageClient - Instantiating wrapper for os : file:///D:D: 
2019-02-25 20:29:40,021 [  10197]   INFO - ntellij.IntellijLanguageClient - Adding file РаботаСКоннекторами.os 
2019-02-25 20:29:40,022 [  10198]  ERROR - plication.impl.ApplicationImpl - String index out of range: -1 
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1967)
	at com.github.lsp4intellij.utils.FileUtils.sanitizeURI(FileUtils.java:135)
	at com.github.lsp4intellij.utils.FileUtils.editorToURIString(FileUtils.java:94)
	at com.github.lsp4intellij.client.languageserver.wrapper.LanguageServerWrapper.connect(LanguageServerWrapper.java:257)
	at com.github.lsp4intellij.IntellijLanguageClient.lambda$editorOpened$0(IntellijLanguageClient.java:149)
	at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2019-02-25 20:29:40,026 [  10202]  ERROR - plication.impl.ApplicationImpl - IntelliJ IDEA 2018.3  Build #IC-183.4284.85 
2019-02-25 20:29:40,026 [  10202]  ERROR - plication.impl.ApplicationImpl - JDK: 1.8.0_152-release; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o 
2019-02-25 20:29:40,026 [  10202]  ERROR - plication.impl.ApplicationImpl - OS: Windows 10 
2019-02-25 20:29:40,031 [  10207]  ERROR - plication.impl.ApplicationImpl - Plugin to blame: Language 1C (BSL) version: 0.2.0 
2019-02-25 20:29:40,031 [  10207]  ERROR - plication.impl.ApplicationImpl - Last Action:  

after this opening new file throws more errors like this:

2019-02-25 20:30:10,238 [  40414]   INFO - ntellij.IntellijLanguageClient - Opened fake-entrypoint.os 
2019-02-25 20:30:10,240 [  40416]   INFO - ntellij.IntellijLanguageClient - Wrapper already existing for os , file:///D:D: 
2019-02-25 20:30:10,240 [  40416]   INFO - ntellij.IntellijLanguageClient - Adding file fake-entrypoint.os 
2019-02-25 20:30:10,241 [  40417]  ERROR - plication.impl.ApplicationImpl - String index out of range: -1 
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1967)
	at com.github.lsp4intellij.utils.FileUtils.sanitizeURI(FileUtils.java:135)
	at com.github.lsp4intellij.utils.FileUtils.editorToURIString(FileUtils.java:94)
	at com.github.lsp4intellij.client.languageserver.wrapper.LanguageServerWrapper.connect(LanguageServerWrapper.java:257)
	at com.github.lsp4intellij.IntellijLanguageClient.lambda$editorOpened$0(IntellijLanguageClient.java:149)
	at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2019-02-25 20:30:10,241 [  40417]  ERROR - plication.impl.ApplicationImpl - IntelliJ IDEA 2018.3  Build #IC-183.4284.85 
2019-02-25 20:30:10,241 [  40417]  ERROR - plication.impl.ApplicationImpl - JDK: 1.8.0_152-release; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o 
2019-02-25 20:30:10,241 [  40417]  ERROR - plication.impl.ApplicationImpl - OS: Windows 10 
2019-02-25 20:30:10,242 [  40418]  ERROR - plication.impl.ApplicationImpl - Plugin to blame: Language 1C (BSL) version: 0.2.0 
2019-02-25 20:30:10,242 [  40418]  ERROR - plication.impl.ApplicationImpl - Last Action:  
2019-02-25 20:30:10,242 [  40418]  ERROR - plication.impl.ApplicationImpl - Current Command:  

after some moment language server revieves shutdown and exit events. lsp-trace.log (sorry for long read):

{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "initialize",
  "params": {
    "processId": 28364,
    "rootPath": "d:\\git\\nixel2007\\entity",
    "rootUri": "file:///d%3A/git/nixel2007/entity",
    "capabilities": {
      "workspace": {
        "applyEdit": true,
        "workspaceEdit": {
          "documentChanges": true,
          "resourceOperations": [
            "create",
            "rename",
            "delete"
          ],
          "failureHandling": "textOnlyTransactional"
        },
        "didChangeConfiguration": {
          "dynamicRegistration": true
        },
        "didChangeWatchedFiles": {
          "dynamicRegistration": true
        },
        "symbol": {
          "symbolKind": {
            "valueSet": [
              1,
              2,
              3,
              4,
              5,
              6,
              7,
              8,
              9,
              10,
              11,
              12,
              13,
              14,
              15,
              16,
              17,
              18,
              19,
              20,
              21,
              22,
              23,
              24,
              25,
              26
            ]
          },
          "dynamicRegistration": true
        },
        "executeCommand": {
          "dynamicRegistration": true
        },
        "workspaceFolders": true,
        "configuration": true
      },
      "textDocument": {
        "synchronization": {
          "willSave": true,
          "willSaveWaitUntil": true,
          "didSave": true,
          "dynamicRegistration": true
        },
        "completion": {
          "completionItem": {
            "snippetSupport": true,
            "commitCharactersSupport": true,
            "documentationFormat": [
              "markdown",
              "plaintext"
            ],
            "deprecatedSupport": true,
            "preselectSupport": true
          },
          "completionItemKind": {
            "valueSet": [
              1,
              2,
              3,
              4,
              5,
              6,
              7,
              8,
              9,
              10,
              11,
              12,
              13,
              14,
              15,
              16,
              17,
              18,
              19,
              20,
              21,
              22,
              23,
              24,
              25
            ]
          },
          "contextSupport": true,
          "dynamicRegistration": true
        },
        "hover": {
          "contentFormat": [
            "markdown",
            "plaintext"
          ],
          "dynamicRegistration": true
        },
        "signatureHelp": {
          "signatureInformation": {
            "documentationFormat": [
              "markdown",
              "plaintext"
            ]
          },
          "dynamicRegistration": true
        },
        "references": {
          "dynamicRegistration": true
        },
        "documentHighlight": {
          "dynamicRegistration": true
        },
        "documentSymbol": {
          "symbolKind": {
            "valueSet": [
              1,
              2,
              3,
              4,
              5,
              6,
              7,
              8,
              9,
              10,
              11,
              12,
              13,
              14,
              15,
              16,
              17,
              18,
              19,
              20,
              21,
              22,
              23,
              24,
              25,
              26
            ]
          },
          "hierarchicalDocumentSymbolSupport": true,
          "dynamicRegistration": true
        },
        "formatting": {
          "dynamicRegistration": true
        },
        "rangeFormatting": {
          "dynamicRegistration": true
        },
        "onTypeFormatting": {
          "dynamicRegistration": true
        },
        "definition": {
          "dynamicRegistration": true
        },
        "typeDefinition": {
          "dynamicRegistration": true
        },
        "implementation": {
          "dynamicRegistration": true
        },
        "codeAction": {
          "codeActionLiteralSupport": {
            "codeActionKind": {
              "valueSet": [
                "",
                "quickfix",
                "refactor",
                "refactor.extract",
                "refactor.inline",
                "refactor.rewrite",
                "source",
                "source.organizeImports"
              ]
            }
          },
          "dynamicRegistration": true
        },
        "codeLens": {
          "dynamicRegistration": true
        },
        "documentLink": {
          "dynamicRegistration": true
        },
        "colorProvider": {
          "dynamicRegistration": true
        },
        "rename": {
          "prepareSupport": true,
          "dynamicRegistration": true
        },
        "publishDiagnostics": {
          "relatedInformation": true
        },
        "foldingRange": {
          "rangeLimit": 5000,
          "lineFoldingOnly": true,
          "dynamicRegistration": true
        }
      }
    },
    "trace": "off",
    "workspaceFolders": [
      {
        "uri": "file:///d%3A/git/nixel2007/entity",
        "name": "entity"
      }
    ]
  }
}
{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {
    "capabilities": {
      "textDocumentSync": 1,
      "documentFormattingProvider": true,
      "documentRangeFormattingProvider": true
    }
  }
}
{
  "jsonrpc": "2.0",
  "method": "initialized",
  "params": {}
}
{
  "jsonrpc": "2.0",
  "method": "textDocument/didOpen",
  "params": {
    "textDocument": {
      "uri": "file:///d%3A/git/nixel2007/entity/tasks/coverage.os",
      "languageId": "bsl",
      "version": 1,
      "text": "some file content"
    }
  }
}
{
  "jsonrpc": "2.0",
  "method": "textDocument/publishDiagnostics",
  "params": {
    "uri": "file:///d%3A/git/nixel2007/entity/tasks/coverage.os",
    "diagnostics": []
  }
}
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "shutdown",
  "params": null
}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}
{
  "jsonrpc": "2.0",
  "method": "exit",
  "params": null
}

nixel2007 avatar Feb 25 '19 17:02 nixel2007

@nixel2007 Glad it worked :D Seems there is an issue in a uri sanitization util method, and thats why the connection gets crashed. Could you please let me know,

  • your OS details and
  • absolute file path of the file that you were trying to open to reproduce the issue?

NipunaRanasinghe avatar Feb 25 '19 17:02 NipunaRanasinghe

  • Microsoft Windows [Version 10.0.18343.1] (PRO x64, RU locale)
  • d:/git/nixel2007/entity/tasks/coverage.os (from https://github.com/nixel2007/entity/blob/develop/tasks/coverage.os)

nixel2007 avatar Feb 25 '19 18:02 nixel2007

Oh that must be a windows specific issue, since I haven't had a time to test it on windows so far. Will fix it ASAP. Again, really appreciate your contribution and effort towards this :)

NipunaRanasinghe avatar Feb 26 '19 04:02 NipunaRanasinghe

@nixel2007 I'm having thoughts of transferring the ownership of this repository to IntelliJ LSP Community. For that

  • I may need to slightly change the org name ( from intellij-lsp to intellijcom? ) since I'll have to request a new maven group id with the org name
  • Copyrights of this repository will remain same until I get the approval from my organization

Are you okay with the above concerns? If so, I'll start working on the migration :)

NipunaRanasinghe avatar Mar 13 '19 03:03 NipunaRanasinghe

Good thoughts :)

  • I think we could have trademark problem with intellijcom. It is so close to intellij.com and so on. If the maven group id is the main problem, you could request 'org. github.intellij-lsp' or something similar? Also we could rename org to lsp4intellij.
  • for me copyright ownership is not a problem at all. But GPL have some strong states about considering transpiling to another language as "rework", that should be licensed with the same copyrights ownership (not "author" of concrete files). Does Apache license give you a permission to put wso2 ownership marks? Or may be there is so much code rewriting and reimplementing that it can not be considering as "rework" in terms of gpl?

nixel2007 avatar Mar 13 '19 06:03 nixel2007

Thanks for your feedback!

  • We can surely use com. github.intellij-lsp as a valid group id but since scala plugin is already using that as its name, using another name might be better I guess. Therefore I'm +1 for lsp4intellij or any other suggestion you got ;)
  • You seem to be having a valid point :) I'll update you with the final conclusion after having some further discussions

NipunaRanasinghe avatar Mar 13 '19 09:03 NipunaRanasinghe

Org was renamed - https://github.com/lsp4intellij Feel free to transfer ownership when you are ready.

nixel2007 avatar Mar 13 '19 09:03 nixel2007

Sure will do after sorting out the copyright issue. Thanks for your help towards the process.

NipunaRanasinghe avatar Mar 13 '19 09:03 NipunaRanasinghe

offtopic. it is so inspiring for me as Russian programmer to work with Sri Lanka's (Sri Lankan? Sri Lankian? 😄) programmer on opensource project, that can be usefull all over the world.

nixel2007 avatar Mar 13 '19 09:03 nixel2007

It should be "Sri Lankan" ;) :D We also are so glad to have such a valuable and contributor like you! Let's work together and see how this lsp4intellij thing rolls out!

NipunaRanasinghe avatar Mar 13 '19 09:03 NipunaRanasinghe

@nixel2007 Sorry for the late response since We were having several internal discussions regarding the copyrights and the maven publish thing. In brief, we considered the following factors

  • We have done internal design and architectural reviews and changed the design accordingly (might have to do more in the future). Therefore it is decided that it's reasonable to proceed with the wso2 copyrights.

  • Since we'll be using the company copyrights, its better to maintain it as a wso2-driven opensource project (There are many open source projects that are currently being developed and maintained by wso2). Then it'll also be easier for the maven publishing process as well.

WDYT?? :)

NipunaRanasinghe avatar Mar 26 '19 06:03 NipunaRanasinghe

Sounds reasonable :) I don't see any cons to this. So repo will be transfered to wso2 org?

nixel2007 avatar Mar 26 '19 06:03 nixel2007