Coder Social home page Coder Social logo

Comments (6)

snoe avatar snoe commented on May 19, 2024

If you're downloading the release, try running it from the command line, it should start up and start reading stdin.
Type {}\n\n and you should get something like:

$ .clojure-lsp
{}

Apr 12, 2019 7:07:02 AM org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer fireError
SEVERE: Missing header Content-Length in input "{}

"
java.lang.IllegalStateException: Missing header Content-Length in input "{}

If that is ok, I log to /tmp/lsp.out, so watch that file and start your editor, let me know if you get errors there.

LSP Clients also generally have a way to trace server interactions.

In lsp-mode, it looks like:

Turn that on and attach both logs if it's not obvious what's going on.

from clojure-lsp.

ProjectFrank avatar ProjectFrank commented on May 19, 2024

Oddly, the /tmp/lsp.out file is not created when clojure-lsp is started using the editor. It is, however, created when I start it using the command line.

I can't get lsp-trace to work, but I tried setting lsp-print-io instead (which I think behaves similarly). This is what that log looks like:

Command "clojure-lsp" is present on the path.
Found the following clients for /Users/me/src/scratch/clojure-lsp/src/clojure_lsp/clojure_core.clj: (server-id clojure-lsp, priority 0)
The following clients were selected based on priority: (server-id clojure-lsp, priority 0)
>>> clojure-lsp:77971 status:starting(async)
Content-Length: 3158

{
  "jsonrpc": "2.0",
  "method": "initialize",
  "params": {
    "processId": 77072,
    "rootPath": "/Users/me/src/scratch/clojure-lsp/",
    "rootUri": "file:///Users/me/src/scratch/clojure-lsp/",
    "capabilities": {
      "workspace": {
        "workspaceEdit": {
          "documentChanges": true,
          "resourceOperations": [
            "create",
            "rename",
            "delete"
          ]
        },
        "applyEdit": 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
            ]
          }
        },
        "executeCommand": {
          "dynamicRegistration": false
        },
        "didChangeWatchedFiles": {
          "dynamicRegistration": true
        },
        "workspaceFolders": true,
        "configuration": true
      },
      "textDocument": {
        "declaration": {
          "linkSupport": true
        },
        "definition": {
          "linkSupport": true
        },
        "implementation": {
          "linkSupport": true
        },
        "typeDefinition": {
          "linkSupport": true
        },
        "synchronization": {
          "willSave": true,
          "didSave": true,
          "willSaveWaitUntil": 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
        },
        "formatting": {
          "dynamicRegistration": true
        },
        "codeAction": {
          "dynamicRegistration": true
        },
        "completion": {
          "completionItem": {
            "snippetSupport": true
          }
        },
        "signatureHelp": {
          "signatureInformation": {
            "parameterInformation": {
              "labelOffsetSupport": true
            }
          }
        },
        "documentLink": {
          "dynamicRegistration": true
        },
        "hover": {
          "contentFormat": [
            "plaintext",
            "markdown"
          ]
        },
        "foldingRange": {
          "dynamicRegistration": true,
          "rangeLimit": null,
          "lineFoldingOnly": null
        }
      }
    },
    "initializationOptions": null
  },
  "id": 8
}

Saving the json rpc part in a text file and piping it to clojure-lsp seems to work fine with the following response:

➜  clojure-lsp git:(6562b07) ✗ clojure-lsp < debug-init.txt
Content-Length: 396

{"jsonrpc":"2.0","id":9,"result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":1,"save":{"includeText":true}},"hoverProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":["c"]},"definitionProvider":true,"referencesProvider":true,"codeActionProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"renameProvider":true}}}

So I guess it's exiting for some reason other than the contents of the message 🤷‍♂️

This is the relevant bit in the *Messages* buffer:

lsp--send-no-wait: clojure-lsp<2>: Cannot communicate with the process (exit)
LSP :: clojure-lsp<2> has exited (exited abnormally with code 126)

It's interesting that the clojure-lsp process seems to exit immediately after being started, since the process takes a few seconds to initialize when started from the command line.

from clojure-lsp.

ProjectFrank avatar ProjectFrank commented on May 19, 2024

Some googling tells me that exit code 126 could mean I do not have permission to execute. However, I did run chmod 755 on the executable as directed:

clojure-lsp git:(6562b07) ✗ ls -l ~/bin/clojure-lsp
-rwxr-xr-x  1 me  staff  31955598 12 Apr 08:14 /Users/frankwang/bin/clojure-lsp

Edit: It looks like code 126 could also mean that the thing is not executable.

from clojure-lsp.

snoe avatar snoe commented on May 19, 2024

Hrm, I wonder if the binary needs to be run from a shell, could you try launching with

(lsp-stdio-connection '("bash" "-c" "clojure-lsp"))

from clojure-lsp.

ProjectFrank avatar ProjectFrank commented on May 19, 2024

That worked! Thank you so much!

from clojure-lsp.

piotr-yuxuan avatar piotr-yuxuan commented on May 19, 2024

@snoe, thanks for you work on this library! clojure-lsp (along with clj-kondo) have finally put Emacs on par and above IntelliJ for 'professional' code editing in my workflow. I'm super delighted about that!

One note though (perhaps for future reference): on my side I have had to use a custom lsp-clojure-server-command to get lsp server be launched properly:

(use-package lsp-mode
  :commands lsp
  :config
  (dolist (m '(clojure-mode
               clojurec-mode
               clojurescript-mode
               clojurex-mode))
    (add-to-list 'lsp-language-id-configuration `(,m . "clojure")))
  :custom
  ((lsp-clojure-server-command '("bash" "-c" "/Users/piotr-yuxuan/bin/clojure-lsp")) ;; <- here
   (lsp-enable-indentation nil))
  :hook
  (clojure-mode . lsp)
  (clojurec-mode . lsp)
  (clojurescript-mode . lsp))

Without that tweak it looks like bash can't find it, even if /Users/piotr-yuxuan/bin is added to bash $PATH in ~/.bashrc:

*lsp-log*

Command "bash -c clojure-lsp" is present on the path.
Found the following clients for /Users/piotr-yuxuan/src/some-file.clj: (server-id clojure-lsp, priority 0)
The following clients were selected based on priority: (server-id clojure-lsp, priority 0)

*clojure-lsp::stderr*

/bin/bash: clojure-lsp: command not found

Process clojure-lsp stderr finished

*Messages*

LSP :: clojure-lsp has exited (exited abnormally with code 127)
Server clojure-lsp:4086 status:starting exited with status exit. Do you want to restart it? (y or n) n

from clojure-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.