godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.56k stars 20.72k forks source link

LanguageServer only works with VSCode #34523

Closed onur closed 4 years ago

onur commented 4 years ago

Godot version: Godot Engine v3.2.beta4.official

OS/device including version: Debian GNU/Linux sid

Issue description:

I tried to use Godot Language Server with coc.nvim and LanguageClient-neovim clients. Godot is returning this error when clients sends initialize method:

ERROR: _parse_request: Not enough response headers, got: 1, expected >= 4.
   At: modules/websocket/wsl_server.cpp:49.

This is the assert line it's failing: wsl_server.cpp:49. Both clients are only sending Content-Lenght header and nothing else and godot is expecting more.

This is the request client is sending:
T 127.0.0.1:54458 -> 127.0.0.1:6008 [AP] #94
  Content-Length: 2601....                                                                                                                                                                  
##
T 127.0.0.1:54458 -> 127.0.0.1:6008 [AP] #96
  {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":1522387,"rootPath":"/home/onur/gamedev/04-tycoon","rootUri":"file:///home/onur/gamedev/04-tycoon","capabilities":{"wor
  kspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"didChangeConfiguration":{"
  dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,1
  8,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true},
  "synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"s
  nippetSupport":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]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true
  ,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"definition":{"dynamicRegistration":true},"references":{"dyna
  micRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,1
  8,19,20,21,22,23,24,25,26]}},"codeAction":{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inli
  ne","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":tr
  ue},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"documentLink":{"dynamicRegistration":true},"typeDefinition":{"dynamicRegi
  stration":true},"implementation":{"dynamicRegistration":true},"declaration":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration
  ":true,"rangeLimit":5000,"lineFoldingOnly":true}}},"initializationOptions":{},"trace":"verbose","workspaceFolders":[{"uri":"file:///home/onur/gamedev/04-tycoon","name":"04-tycoon"}]}}   
#

cc @Faless

kovasap commented 3 years ago

Has anyone gotten this to work with neovim's native LSP (not CoC), for instance like these language servers: https://github.com/neovim/nvim-lspconfig?

beyarkay commented 1 year ago

Anyone coming from Godot 4, note that the port has changed to 6005 and you'll want to use the filetype "gdscript":

  "languageserver": {
    "godot": {
      "host": "127.0.0.1",
      "filetypes": ["gd", "gdscript"],
      "port": 6005
    }
  }

You can change your LSP settings for godot by going to Editor > Editor Settings > Network > Language Server.

And you can setup neovim as an external editor for godot by:

  1. Navigating to the directory containing project.godot and running the command nvim --listen ./godothost
  2. Going to the settings menu at Editor > Editor Settings > General > Text Editor > External
  3. Tick Use external editor
  4. Set Exec Path to either nvim or the full nvim path. My full nvim path is /opt/homebrew/bin/nvim
  5. Set the Exec Flags to --server ./godothost --remote-send "<C-\><C-N>:n {file}<CR>{line}G{col}|"

Now, when you click to open a gdscript file in Godot, neovim will jump to that location.