Git Product home page Git Product logo

Comments (6)

gtache avatar gtache commented on June 24, 2024 1

Well, I looked a bit into your code and from what I understood, vscode will call activate() on the client when it needs to start the server, as you said. What happens in my plugin is that the commands to start the server are run as soon as you open an editor with a recognized extension.
Now, as long as you can start your language server from the command line, you should be able to use it with the plugin (in which case you could use either a raw command or an executable server definition ; I added a little bit of information about them in the readme). What the plugin needs is basically just an input and output stream to the server, however, if you use an existing ServerDefinition (RawCommand for example), these streams need to be the stdin and stdout of the server.
If you need something else, you'll need to extend the plugin by creating a simple plugin and implementing a custom LanguageServerDefinition.

In short, if you can make it work like https://github.com/rcjsuen/dockerfile-language-server-nodejs for example, you just have to install the server, then in your settings, write something like this :
2017-12-01_23h54_08
(As I installed the server globally with npm, it is in my user folder)

If you can't start your server from the command line however, then I don't really know how to help (or I need more infos).

from intellij-lsp.

tempit avatar tempit commented on June 24, 2024 1

It works! Changing the server connection from nodeIPC to stdin/stdout worked like a charm.
Many thanks for the assistance, and a great plugin.

from intellij-lsp.

tempit avatar tempit commented on June 24, 2024

Ok, I tried it and I'm stuck again...
I added a runnable that runs the server, and am calling it as an executable, like so:
image

Idea.log seems to indicate the server was started, but I see no interaction with it. Every completion request returns 'no suggestions', for example, and nothing in the log.
Can you help somehow? Any tips on debugging this in Intellij would also be welcome.
My code is in the repo from above, in intellij-lsp branch if you want to have a look.

In idea.log, I see:
2017-12-03 11:39:01,107 [ 5138] INFO - m.github.gtache.lsp.PluginMain - PluginMain init finished
2017-12-03 11:39:01,353 [ 5384] INFO - plication.impl.ApplicationImpl - 103 application components initialized in 4849ms
2017-12-03 11:39:01,366 [ 5397] INFO - .intellij.idea.IdeaApplication - App initialization took 6072 ms
2017-12-03 11:39:01,904 [ 5935] INFO - pl$FileIndexDataInitialization - Initialization done:1443
2017-12-03 11:39:02,026 [ 6057] INFO - exImpl$StubIndexInitialization - Initialization done:122
2017-12-03 11:39:02,839 [ 6870] INFO - com.intellij.ide.ui.UISettings - Loaded: fontSize=12, fontScale=1.0; restored: fontSize=11, fontScale=0.9166667
2017-12-03 11:39:02,841 [ 6872] INFO - com.intellij.ide.ui.UISettings - Loaded: fontSize=11, fontScale=0.9166667; restored: fontSize=11, fontScale=0.9166667
2017-12-03 11:39:03,255 [ 7286] INFO - .openapi.application.Preloader - Finished preloading com.intellij.openapi.actionSystem.impl.ActionPreloader@377eb07c
2017-12-03 11:39:03,968 [ 7999] INFO - ellij.project.impl.ProjectImpl - 204 project components initialized in 1712 ms
2017-12-03 11:39:04,408 [ 8439] INFO - le.impl.ModuleManagerComponent - 1 module(s) loaded in 438 ms
2017-12-03 11:39:04,863 [ 8894] WARN - om.intellij.util.ProfilingUtil - Profiling agent is not enabled. Add -agentlib:yjpagent to idea.vmoptions if necessary to profile IDEA.
2017-12-03 11:39:05,195 [ 9226] INFO - .openapi.application.Preloader - Finished preloading com.intellij.ide.ui.search.SearchableOptionPreloader@448d6401
2017-12-03 11:39:05,494 [ 9525] INFO - CompilerBackwardReferenceIndex - backward reference index version differ due to: class java.io.FileNotFoundException
2017-12-03 11:39:05,988 [ 10019] INFO - .openapi.application.Preloader - Finished preloading com.intellij.codeInsight.completion.CompletionPreloader@27671e76
2017-12-03 11:39:07,123 [ 11154] INFO - m.github.gtache.lsp.PluginMain - Added serverDefinitions Set() from plugins
2017-12-03 11:39:07,136 [ 11167] INFO - m.github.gtache.lsp.PluginMain - Opened DottyPreloadingActivity.scala
2017-12-03 11:39:07,170 [ 11201] INFO - .diagnostic.PerformanceWatcher - Pushing properties took 860ms; general responsiveness: ok; EDT responsiveness: ok
2017-12-03 11:39:07,580 [ 11611] INFO - ScriptTemplatesProviders - [kts] loading script definitions [] using cp:
2017-12-03 11:39:07,596 [ 11627] INFO - ScriptTemplatesProviders - Templates provider KotlinCompilerScriptTemplatesSettings is invalid:
2017-12-03 11:39:07,647 [ 11678] INFO - ScriptTemplatesProviders - Templates provider Gradle Kotlin DSL is invalid: Unable to get Gradle home directory
2017-12-03 11:39:07,647 [ 11678] INFO - ScriptTemplatesProviders - Templates provider Gradle Script Kotlin is invalid: Unable to get Gradle home directory
2017-12-03 11:39:07,710 [ 11741] INFO - ScriptTemplatesProviders - [kts] loading script definitions [kotlin.script.templates.standard.ScriptTemplateWithArgs] using cp:
2017-12-03 11:39:07,731 [ 11762] INFO - m.github.gtache.lsp.PluginMain - Opened ScalaBundle.java
2017-12-03 11:39:08,114 [ 12145] INFO - m.github.gtache.lsp.PluginMain - Opened ScalaLanguage.java
2017-12-03 11:39:08,688 [ 12719] INFO - m.github.gtache.lsp.PluginMain - Opened ScalaFileTypeFactory.java
2017-12-03 11:39:08,812 [ 12843] INFO - m.github.gtache.lsp.PluginMain - Opened test.stcss
2017-12-03 11:39:08,818 [ 12849] INFO - m.github.gtache.lsp.PluginMain - Instantiating wrapper for stcss : file:///home/wix/IdeaProjects/plugin-test/
2017-12-03 11:39:08,835 [ 12866] INFO - m.github.gtache.lsp.PluginMain - Adding file test.stcss
2017-12-03 11:39:08,939 [ 12970] INFO - rocessStreamConnectionProvider - Starting server process with commands WrappedArray(../../projects/stylable-intelligence/packages/client/server/src/cli.js) and workingDir /home/wix/IdeaProjects/plugin-test
2017-12-03 11:39:08,973 [ 13004] INFO - rocessStreamConnectionProvider - Server process started java.lang.UNIXProcess@2af9d105
2017-12-03 11:39:08,977 [ 13008] INFO - tartup.impl.StartupManagerImpl - OpenFilesActivity run in 2801ms under project opening modal progress
2017-12-03 11:39:09,236 [ 13267] INFO - tartup.impl.StartupManagerImpl - InitToolWindowsActivity run in 258ms under project opening modal progress
2017-12-03 11:39:09,352 [ 13383] INFO - .diagnostic.PerformanceWatcher - Post-startup activities under progress took 3302ms; general responsiveness: ok; EDT responsiveness: 1/3 sluggish, 1/3 very slow
2017-12-03 11:39:10,077 [ 14108] INFO - tartup.impl.StartupManagerImpl - /home/wix/IdeaProjects/plugin-test/.idea case-sensitivity: expected=true actual=true
2017-12-03 11:39:10,089 [ 14120] INFO - pl.projectlevelman.NewMappings - VCS Root: [] - []
2017-12-03 11:39:11,090 [ 15121] INFO - tor.impl.FileEditorManagerImpl - Project opening took 8917 ms
2017-12-03 11:39:11,987 [ 16018] INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 4815ms; general responsiveness: ok; EDT responsiveness: 1/6 sluggish, 1/6 very slow
2017-12-03 11:39:12,523 [ 16554] INFO - CompilerWorkspaceConfiguration - Available processors: 8

from intellij-lsp.

gtache avatar gtache commented on June 24, 2024

Okay, the server started log indicates that the process has been started, but not that it is communicating with the client. It's the message "Got initializeResult for ..." that indicates that a connection has been made. If you look at the bottom of the IntelliJ window, you should have an icon for the server, and I imagine it stays yellow (which means starting).

The thing is, I'm not very knowledgeable in JavaScript, but I imagine you have to launch your js file with something (and not simply "execute" it).

For example, the docker-langserver file (generated by npm I think) that I use to start the docker server uses node to start the server :
2017-12-04_18h34_34

where the bin file has
2017-12-04_18h35_28

and the server.js file is simply the "js-translated" equivalent (that npm made when installing I guess) of the server.ts file that you can see at https://github.com/rcjsuen/dockerfile-language-server-nodejs/blob/master/src/server.ts

Now, if you want to easily (except the setup) debug using IntelliJ, you can clone/download the intellij-lsp subfolder, create a new IntelliJ plugin project with the root at intellij-lsp, add a new IntelliJ Platform SDK (by going into Project Structure/SDKs) pointing at the IntelliJ installation folder, add a Scala (2.12.4) SDK (by going into Project Structure/Global Libraries), add the required libraries (by going into project structure/libraries and seeing which libraries are needed by looking into the build.gradle file: it's lsp4j, coursier and flexmark ; I guess you could also synchronize using Gradle), and finally launch the plugin and if everything was done correctly a sandbox should start. Now you have easy access to the log in the main IntelliJ window, you can set breakpoints in the code, etc.

Sadly, it doesn't seem like you can access a plugin code otherwise, so you can't really debug it if you don't do that I guess...

from intellij-lsp.

tempit avatar tempit commented on June 24, 2024

I tried doing that (using bin generated by npm) but did not see any difference. The server.ts file being run is similar to the one in the dockerfile-language-server repo.

Also, what message in the log are you referring to? I don't see 'initializeResult' or similar, but I do see
2017-12-05 12:54:31,938 [ 9455] INFO - rocessStreamConnectionProvider - Starting server process with commands WrappedArray(stylable-intelligence-server) and workingDir /home/wix/IdeaProjects/plugin-test
2017-12-05 12:54:31,942 [ 9459] INFO - rocessStreamConnectionProvider - Server process started java.lang.UNIXProcess@647d6f95

Does that mean server was started? I see no further communication with it...
[Thanks for all the help, BTW, it's much appreciated]

from intellij-lsp.

gtache avatar gtache commented on June 24, 2024

Glad to hear it! I hope it will help you for the development of your server !

from intellij-lsp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.