Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Multiples issues on Sublime Text 3 LSP #34

Closed
faustinoaq opened this issue Oct 22, 2017 · 4 comments
Closed

Multiples issues on Sublime Text 3 LSP #34

faustinoaq opened this issue Oct 22, 2017 · 4 comments
Labels

Comments

@faustinoaq
Copy link
Member

faustinoaq commented Oct 22, 2017

Hi community!

Requirements to reproduce this issue:

Currently Sublime Text 3 has full LSP support

screenshot_20171022_054522

I tried LSP on ST3 using https://github.com/tomv564/LSP with this settings:

// Settings in here override those in "LSP/LSP.sublime-settings",

{
  "clients":
  {
    // Each new client must have the following structure.
    "crystal":
    {
  
      // The command line required to run the server.
      "command": ["/home/main/Projects/scry/bin/linux/scry"],
  
      // Use: "Show Scope Name" from Sublime's Developer menu
      "scopes": ["source.crystal"],
  
      // Run: view.settings().get("syntax") in console
      "syntaxes": ["Packages/Crystal/Crystal.sublime-syntax"],
  
      // See: https://github.com/Microsoft/language-server-protocol/issues/213
      "languageId": "crystal",
  
      // Sent to server once using workspace/didConfigurationChange notification
      "settings": { },
  
      // Sent once to server in initialize request
      "initializationOptions": { },
  
      // Extra variables to override/add to language server's environment.
      "env": { },
    }
  },
  "auto_show_diagnostics_panel": false,
  "show_diagnostics_phantoms": true
}

However I found some issues trying scry:

1. Formatting doesn't work:

See issue #35

2. Diagnostics doesn't work well.

See issue #36

3. GoTo Definition works!

The only feature that currently works well!, To try Scry GoTo Definition first disable default GoTo Definition on ST3 settings:

{
	"index_files": false
}

bug03

As you can see GoToDef works almost perfectly :)

Conclusion

I think these issues related to formatting and diagnostics would be configuration errors, maybe on initialize protocol. Latest contributions by @bmulvihill could be trying to fix some of these issues.

Next features to support will be Hover information (using crystal tool context) and Completion using Cracker (maybe embedded on Scry WDYT @TechMagister ?).

Also I'm thinking on use crystal commandline tools instead of require "compiler/crystal/**" this would reduce Scry size a ton and should allow us to implement features easily. However I still think require "compiler/crystal/syntax" will be useful to implement features like List & Rename Symbols.

/cc @keplersj @kofno @bcardiff

@kofno
Copy link
Contributor

kofno commented Oct 22, 2017

Seems like we should break up this issue into a few issues and spin those out to be worked independently.

@faustinoaq
Copy link
Member Author

Yeah, I agree, I'll split this issue

Also here is one of the scry logs:

I, [2017-10-22 05:58:47 -0500 #17072]  INFO -- : Scry is looking into your code...
D, [2017-10-22 05:58:47 -0500 #17072] DEBUG -- : Content-Length: 351
D, [2017-10-22 05:58:47 -0500 #17072] DEBUG -- : 
D, [2017-10-22 05:58:47 -0500 #17072] DEBUG -- : {"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"capabilities": {"workspace": {"applyEdit": true}, "textDocument": {"completion": {"completionItem": {"snippetSupport": true}}, "synchronization": {"didSave": true}}}, "rootUri": "file:///home/main/Projects/experiments", "rootPath": "/home/main/Projects/experiments", "processId": 17072}}
D, [2017-10-22 05:58:47 -0500 #17072] DEBUG -- : initialize
D, [2017-10-22 05:58:47 -0500 #17072] DEBUG -- : Content SEND: Content-Length: 133

{"jsonrpc":"2.0","id":1,"result":{"capabilities":{"textDocumentSync":1,"documentFormattingProvider":true,"definitionProvider":true}}}
D, [2017-10-22 05:58:47 -0500 #17072] DEBUG -- : Content-Length: 57
D, [2017-10-22 05:58:47 -0500 #17072] DEBUG -- : 
D, [2017-10-22 05:58:47 -0500 #17072] DEBUG -- : {"jsonrpc": "2.0", "method": "initialized", "params": {}}
D, [2017-10-22 05:58:47 -0500 #17072] DEBUG -- : Content SEND: Content-Length: 374

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Couldn't parse (Scry::NotificationMessage | Scry::RequestMessage) from {\"jsonrpc\":\"2.0\",\"method\":\"initialized\",\"params\":{}} at 0:0","data":["0xc41a05: ??? at ??","0x1107a18: ??? at ??","0x679cc8: ??? at ??","0x639c33: main at ??","0x7fd71df824ca: __libc_start_main at ??","0x6139cc: ??? at ??","0x0: ??? at ??"]}}
D, [2017-10-22 05:58:47 -0500 #17072] DEBUG -- : Content-Length: 733
D, [2017-10-22 05:58:47 -0500 #17072] DEBUG -- : 
D, [2017-10-22 05:58:47 -0500 #17072] DEBUG -- : {"jsonrpc": "2.0", "method": "textDocument/didOpen", "params": {"textDocument": {"languageId": "crystal", "version": 0, "uri": "file:///home/main/Projects/experiments/crystal/count_lines.cr", "text": "record FileObject, name : String, lines : Int32\nchannel = Channel(FileObject).new\ntotal_lines = 0\nfiles = Dir.glob(\"/usr/lib/crystal/**/*.cr\")\n\nfiles.each do |f|\n  spawn do\n    lines = File.read(f).lines.size\n    channel.send FileObject.new(f, lines)\n  end\nend\n\ncount = [] of FileObject\nfiles.size.times do\n  count << channel.receive\nend\n\ncount = count.sort_by(&.lines)\n\ncount.each do |f|\n  p [f.name, f.lines]\nend\n\np count.sum(&.lines) # => 134025 (0.23.1)\n\ndef foo(a : String)\n\t\nend\n\nfoo(1.0)\n"}}}
D, [2017-10-22 05:58:47 -0500 #17072] DEBUG -- : textDocument/didOpen
D, [2017-10-22 05:58:48 -0500 #17072] DEBUG -- : Content SEND: Content-Length: 366

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/main/Projects/experiments/crystal/count_lines.cr","diagnostics":[{"range":{"start":{"line":29,"character":0},"end":{"line":29,"character":3}},"severity":1,"source":"Scry [Crystal]","message":"no overload matches 'foo' with type Float64\nOverloads are:\n - foo(a : String)"}]}}
D, [2017-10-22 05:58:57 -0500 #17072] DEBUG -- : Content-Length: 154
D, [2017-10-22 05:58:57 -0500 #17072] DEBUG -- : 
D, [2017-10-22 05:58:57 -0500 #17072] DEBUG -- : {"jsonrpc": "2.0", "method": "textDocument/didSave", "params": {"textDocument": {"uri": "file:///home/main/Projects/experiments/crystal/count_lines.cr"}}}
D, [2017-10-22 05:58:57 -0500 #17072] DEBUG -- : Content SEND: Content-Length: 475

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Couldn't parse (Scry::NotificationMessage | Scry::RequestMessage) from {\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didSave\",\"params\":{\"textDocument\":{\"uri\":\"file:///home/main/Projects/experiments/crystal/count_lines.cr\"}}} at 0:0","data":["0xc41a05: ??? at ??","0x1107a18: ??? at ??","0x679cc8: ??? at ??","0x639c33: main at ??","0x7fd71df824ca: __libc_start_main at ??","0x6139cc: ??? at ??","0x0: ??? at ??"]}}
D, [2017-10-22 05:58:58 -0500 #17072] DEBUG -- : 
W, [2017-10-22 05:58:58 -0500 #17072]  WARN -- : Connection with client lost
D, [2017-10-22 05:58:58 -0500 #17072] DEBUG -- : Content SEND: Content-Length: 276

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Content-Length header is required. Ex: Content-Length: 132\\r\\n","data":["0x1104d35: ??? at ??","0x6797d0: ??? at ??","0x639c33: main at ??","0x7fd71df824ca: __libc_start_main at ??","0x6139cc: ??? at ??","0x0: ??? at ??"]}}
E, [2017-10-22 05:58:59 -0500 #17072] ERROR -- : Error writing file: Broken pipe
0x618415: ??? at ??
0x61c845: ??? at ??
0x61c23b: ??? at ??
0x11230c8: ??? at ??
0x679a29: ??? at ??
0x639c33: main at ??
0x7fd71df824ca: __libc_start_main at ??
0x6139cc: ??? at ??
0x0: ??? at ??

@keplersj
Copy link
Contributor

keplersj commented Mar 8, 2018

Should this be closed?

@keplersj keplersj closed this as completed Mar 8, 2018
@keplersj keplersj reopened this Mar 8, 2018
@keplersj
Copy link
Contributor

keplersj commented Mar 8, 2018

Sorry wrong button

@faustinoaq faustinoaq added the bug label Mar 31, 2018
@faustinoaq faustinoaq added this to To do in Crystal Tools Apr 6, 2018
@bcardiff bcardiff closed this as completed Jun 1, 2023
Crystal Tools automation moved this from To do to Done Jun 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Crystal Tools
  
Done
Development

No branches or pull requests

4 participants