emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.78k stars 884 forks source link

haskell-mode not running the binary haskell-language-server #3606

Closed dewijones92 closed 2 years ago

dewijones92 commented 2 years ago

Thank you for the bug report

Bug description

Thanks for this amazing project 😊 I am banging my head against a brick wall here 😔 When I run "haskell-mode" I expect it to run the associated language server. But it is not.

Steps to reproduce

  1. Open a haskell project
  2. Run in emacs haskell-mode

Expected behavior

Spacemacs should run haskell-language-server

Which Language Server did you use?

haskell-language-server

OS

Linux

Error callstack

lsp-log-buffer
[Trace - 11:30:47 AM] Sending request 'initialize - (1)'.
Params: {
  "processId": null,
  "rootPath": "/home/dewi/tmp/haskellTut/helloworld2",
  "clientInfo": {
    "name": "emacs",
    "version": "GNU Emacs 29.0.50 (build 44, x86_64-pc-linux-gnu, GTK+ Version 3.24.25, cairo version 1.16.0)\n of 2022-06-24"
  },
  "rootUri": "file:///home/dewi/tmp/haskellTut/helloworld2",
  "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,
      "codeLens": {
        "refreshSupport": true
      },
      "fileOperations": {
        "didCreate": false,
        "willCreate": false,
        "didRename": true,
        "willRename": true,
        "didDelete": false,
        "willDelete": false
      }
    },
    "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
      },
      "rangeFormatting": {
        "dynamicRegistration": true
      },
      "rename": {
        "dynamicRegistration": true,
        "prepareSupport": true
      },
      "codeAction": {
        "dynamicRegistration": true,
        "isPreferredSupport": true,
        "codeActionLiteralSupport": {
          "codeActionKind": {
            "valueSet": [
              "",
              "quickfix",
              "refactor",
              "refactor.extract",
              "refactor.inline",
              "refactor.rewrite",
              "source",
              "source.organizeImports"
            ]
          }
        },
        "resolveSupport": {
          "properties": [
            "edit",
            "command"
          ]
        },
        "dataSupport": true
      },
      "completion": {
        "completionItem": {
          "snippetSupport": true,
          "documentationFormat": [
            "markdown",
            "plaintext"
          ],
          "resolveAdditionalTextEditsSupport": true,
          "insertReplaceSupport": true,
          "deprecatedSupport": true,
          "resolveSupport": {
            "properties": [
              "documentation",
              "detail",
              "additionalTextEdits",
              "command"
            ]
          },
          "insertTextModeSupport": {
            "valueSet": [
              1,
              2
            ]
          }
        },
        "contextSupport": true
      },
      "signatureHelp": {
        "signatureInformation": {
          "parameterInformation": {
            "labelOffsetSupport": true
          }
        }
      },
      "documentLink": {
        "dynamicRegistration": true,
        "tooltipSupport": true
      },
      "hover": {
        "contentFormat": [
          "markdown",
          "plaintext"
        ]
      },
      "foldingRange": {
        "dynamicRegistration": true
      },
      "callHierarchy": {
        "dynamicRegistration": false
      },
      "publishDiagnostics": {
        "relatedInformation": true,
        "tagSupport": {
          "valueSet": [
            1,
            2
          ]
        },
        "versionSupport": true
      },
      "linkedEditingRange": {
        "dynamicRegistration": true
      }
    },
    "window": {
      "workDoneProgress": true,
      "showMessage": null,
      "showDocument": {
        "support": true
      }
    }
  },
  "initializationOptions": null,
  "workDoneToken": "1"
}
------------------------------------------------------------------------

lsp-haskell:stderr
No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.7.0.0, Gi\
t revision 59016bb9ae55b6c59b6866eb3f47c70f255b3c7a (dirty) (2824 commits) x86_64 ghc-9.2.3
Current directory: /home/dewi/tmp/haskellTut/hell3/helloworld
Operating system: linux
Arguments: ["--lsp","-d","-l","/tmp/hls.log"]
Cradle directory: /home/dewi/tmp/haskellTut/hell3/helloworld
Cradle type: Stack

Tool versions found on the $PATH
cabal:    3.6.2.0
stack:    2.7.5
ghc:    9.2.3

Consulting the cradle to get project GHC version...
Project GHC version: 9.0.2
haskell-language-server exe candidates: ["haskell-language-server-9.0.2","haskell-language-server"]
Launching haskell-language-server exe at:/home/dewi/.local/bin/haskell-language-server

Process lsp-haskell stderr finished

------------------------------------------------------------------------

Anything else?

No response

yyoncho commented 2 years ago

To me it sounds like your project is problematic for the server, @michaelpj is more familiar with haskell ls.

michaelpj commented 2 years ago

Yes, please consult the HLS troubleshooting page and open an issue if that doesn't help: https://haskell-language-server.readthedocs.io/en/latest/troubleshooting.html

yyoncho commented 2 years ago

Closing the issue for now, please reopen if you discover something to be fixed on lsp-mode side.

dewijones92 commented 2 years ago

@michaelpj @yyoncho Hello, thanks for your response. It doesn't seem to be a problem with the server side of things. The process does not exit when running on the command line.

haskell-language-server-wrapper --lsp --debug
No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.7.0.0, Git revision a32db0b296d16611def15fb1d7d377fa0505beea (dirty) (2835 commits) x86_64 ghc-9.2.3
Current directory: /home/dewi/code/haskell-language-server
Operating system: linux
Arguments: ["--lsp","--debug"]
Cradle directory: /home/dewi/code/haskell-language-server
Cradle type: Cabal

Tool versions found on the $PATH
cabal:          3.6.2.0
stack:          2.7.5
ghc:            9.2.3

Consulting the cradle to get project GHC version...
Project GHC version: 9.2.3
haskell-language-server exe candidates: ["haskell-language-server-9.2.3","haskell-language-server"]
Launching haskell-language-server exe at:/home/dewi/.local/bin/haskell-language-server
2022-07-07T05:47:51.835218Z | Info | No log file specified; using stderr.
2022-07-07T05:47:51.835765Z | Info | haskell-language-server version: 1.7.0.0 (GHC: 9.2.3) (PATH: /home/dewi/.local/bin/haskell-language-server) (GIT hash: a32db0b296d16611def15fb1d7d377fa0505beea)
2022-07-07T05:47:51.836403Z | Info | Directory: /home/dewi/code/haskell-language-server
2022-07-07T05:47:51.836692Z | Info | Starting (haskell-language-server) LSP server...
  GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}
  PluginIds: [ pragmas
             , floskell
             , fourmolu
             , ormolu
             , stylish-haskell
             , rename
             , callHierarchy
             , class
             , eval
             , importLens
             , qualifyImportedNames
             , refineImports
             , moduleName
             , hlint
             , alternateNumberFormat
             , selectionRange
             , changeTypeSignature
             , gadt
             , ghcide-hover-and-symbols
             , ghcide-code-actions-imports-exports
             , ghcide-code-actions-type-signatures
             , ghcide-code-actions-bindings
             , ghcide-code-actions-fill-holes
             , ghcide-completions
             , ghcide-type-lenses
             , ghcide-core
             , LSPRecorderCallback ]
2022-07-07T05:47:51.839520Z | Info | Logging heap statistics every 60.00s
 2022-07-07T05:47:51.846751Z | Info | Staring LSP server...
If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option!

The problem is seemingly only apparent when trying to get emacs to work with it. It seems to be a problem client-side. Any suggestions? thanks :)

yyoncho commented 2 years ago

@dewijones92 the server does not infer project dir - it receives it through initialize message.

dewijones92 commented 2 years ago

@dewijones92 the server does not infer project dir - it receives it through initialize message.

is there a working combination of a stack project and HLS you can link me to? ideally where the versions are explicit thanks v much

michaelpj commented 2 years ago

@dewijones92 please follow the troubleshooting guide I linked.