Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add elm support #613

Closed
razzeee opened this issue Jun 13, 2019 · 46 comments
Closed

Add elm support #613

razzeee opened this issue Jun 13, 2019 · 46 comments

Comments

@razzeee
Copy link
Contributor

razzeee commented Jun 13, 2019

Hey there,

it would be awesome to get Elm support via https://github.com/elm-tooling/elm-language-server

I tried this config, but that doesn't seem to be enough:

	"clients":
	{
		"elm-language-server":
		{
			"command":
			[
				"elm-language-server"
			],
			"enabled": true,
			"languageId": "elm",
			"scopes":
			[
				"source.elm"
			]
		}
	}

Thanks

@rwols
Copy link
Member

rwols commented Jun 13, 2019

Did you try this command too?

"command": ["elm-language-server", "--stdio"],

Also make sure to open the SublimeText Console and check to see if the LSP initialize request gets a response.

@razzeee
Copy link
Contributor Author

razzeee commented Jun 13, 2019

Hrm, I think my problem might be that the file doesn't even get recognized as an elm file? Do I need another extension just to get that working, as I can't choose elm from the file type selector.

@rwols
Copy link
Member

rwols commented Jun 13, 2019

Yes, first order of business would be to have an Elm syntax. You'll probably also need to set the "syntaxes" key of your "client" config to the path of that Elm syntax, once installed. Although I don't use the Elm language personally, I browsed around a bit and found this one: https://github.com/elm-community/SublimeElmLanguageSupport/blob/master/Syntaxes/Elm.sublime-syntax

(from: https://packagecontrol.io/packages/Elm%20Language%20Support)

It looks like this Elm plugin tries to do a lot more than just syntax-highlighting, unfortunately.

@razzeee
Copy link
Contributor Author

razzeee commented Jun 14, 2019

Yeah, it's a full blown plugin, so I would need a plugin that just does syntax highlighting?

@rwols
Copy link
Member

rwols commented Jun 14, 2019

so I would need a plugin that just does syntax highlighting?

Well, you could also use the plugin mentioned above. I don't know if any functionality might interfere with each other. But in theory all you need is a .sublime-syntax file.

I haven't tested this, but when using that plugin your config should look something like this:

    "elm-language-server":
    {
      "enabled": true,
      "command": ["elm-language-server", "--stdio"],
      "scopes": ["source.elm"],
      // borrowed from https://packagecontrol.io/packages/Elm%20Language%20Support
      "syntaxes": ["Packages/Elm Language Support/Syntaxes/Elm.sublime-syntax"],
      // there is no standard for Elm yet: https://microsoft.github.io/language-server-protocol/specification#textdocumentitem
      "languageId": "elm"
    },

@predragnikolic
Copy link
Member

predragnikolic commented Jul 16, 2019

here is the config that works for me.

"elm":
{
	"command":
	[
		"elm-language-server",
		"--stdio"
	],
	"enabled": true,
	"languageId": "elm",
	"scopes":
	[
		"source.elm",
	],
	"syntaxes":
	[
		"Packages/Elm Language Support/Syntaxes/Elm.sublime-syntax"
	],
	"initializationOptions": {
		"runtime": "node",
		"elmPath": "elm",
	        "elmFormatPath": "elm-format",
	        "elmTestPath": "elm-test"
	},
}

And you need to install Elm Language Support from package control for syntax highlighting, as it doesn't come with the default sublime installation.

I tried elm language server, but as far as I can see only the diagnostics are working in LSP for sublime.
I would need to see why :)

@razzeee
Copy link
Contributor Author

razzeee commented Jul 16, 2019

If you can dig into it, that would be awesome. As we don't seem to be able to figure it out: elm-tooling/elm-language-server#99

@predragnikolic
Copy link
Member

Here is a sample elm project if someone is interested in debugging this:
In LSP-settings enable:

"log_debug": true,
"log_payloads": true,
"log_stderr": true,

Next, in the terminal:

//install elm
npm install -g elm elm-test elm-format @elm-tooling/elm-language-server


// setup an example elm project
git clone https://github.com/evancz/elm-architecture-tutorial.git
cd elm-architecture-tutorial
subl .

Here is what happens when I open an elm file:

LSP: starting ['elm-language-server', '--stdio']
LSP:  --> initialize
LSP: window 3 added session elm
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage

// lot of unhandled `window/logMessage`...

LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage

// finaly we get a response back from the server and see what the server capabilities are
// NOTE here that the `completionProvider` is an empty dict

LSP:      {'capabilities': {'documentFormattingProvider': True, 'workspaceSymbolProvider': True, 'hoverProvider': True, 'referencesProvider': True, 'codeActionProvider': True, 'documentSymbolProvider': True, 'textDocumentSync': 1, 'executeCommandProvider': {'commands': ['elmLS.elmAnalyseFixer', 'elmLS.elmAnalyseFixer.fixAll']}, 'renameProvider': True, 'codeLensProvider': {'resolveProvider': True}, 'completionProvider': {}, 'definitionProvider': True, 'foldingRangeProvider': True}}
LSP:  --> initialized
LSP:  --> textDocument/didOpen

// Another unhandled request for `client/registerCapability`

LSP: <--  client/registerCapability
LSP:      {'registrations': [{'registerOptions': {}, 'method': 'workspace/didChangeConfiguration', 'id': '0384bd6e-7154-40e7-a252-c66cb266c90e'}]}
LSP: Unhandled request client/registerCapability
LSP: <--  textDocument/publishDiagnostics
LSP:      {'uri': 'file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm', 'diagnostics': []}

I made a NOTE that the completionProvider is an empty dict.

https://github.com/tomv564/LSP/blob/99c2493bb98bc7a57499a85cb659e40026b971b7/plugin/completion.py#L73-L77

Here we get the completionProvider from session.get_capability( 'completionProvider').
The return value is an empty dict,
which means that if completionProvider: is always False in this case.

A Solution for this is to ask if completionProvider is not None:


Another thing that I noticed is
as soon as I start typing,
I get error messages like this:

LSP:  --> textDocument/didChange
LSP: <--  textDocument/publishDiagnostics
LSP:      {'uri': 'file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm', 'diagnostics': []}
elm: Changed text document, going to parse it. file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm
(node:21154) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm':
at Object.openSync (fs.js:438:3):
at Object.readFileSync (fs.js:343:35):
at ASTProvider.<anonymous> (/home/predrag/.npm-global/lib/node_modules/@elm-tooling/elm-language-server/out/providers/astProvider.js:24:42):
at Generator.next (<anonymous>):
at /home/predrag/.npm-global/lib/node_modules/@elm-tooling/elm-language-server/out/providers/astProvider.js:7:71:
at new Promise (<anonymous>):
at __awaiter (/home/predrag/.npm-global/lib/node_modules/@elm-tooling/elm-language-server/out/providers/astProvider.js:3:12):
at DocumentEvents.ASTProvider.handleChangeTextDocument (/home/predrag/.npm-global/lib/node_modules/@elm-tooling/elm-language-server/out/providers/astProvider.js:19:53):
at DocumentEvents.emit (events.js:194:15):
at DocumentEvents.connection.onDidChangeTextDocument.event (/home/predrag/.npm-global/lib/node_modules/@elm-tooling/elm-language-server/out/util/documentEvents.js:7:58):
(node:21154) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2):
LSP:  --> textDocument/codeAction
LSP:      []


Changed text document, going to parse it. file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm
(node:21154) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm':


This is all I could figure out for now,
And I would love is someone else could have a look at this :)

@rwols
Copy link
Member

rwols commented Jul 17, 2019

I would like to note that the "unhandled notification" messages from window/logMessage seem correct. Quoting from the specification:

Until the server has responded to the initialize request with an InitializeResult, the client must not send any additional requests or notifications to the server. In addition the server is not allowed to send any requests or notifications to the client until it has responded with an InitializeResult

@predragnikolic
Copy link
Member

predragnikolic commented Jul 17, 2019

Until the server has responded to the initialize request with an InitializeResult, the client must not send any additional requests or notifications to the server. In addition the server is not allowed to send any requests or notifications to the client until it has responded with an InitializeResult,with the exception that during the initialize request the server is allowed to send the notifications window/showMessage, window/logMessage and telemetry/event as well as the window/showMessageRequest request to the client.

:D

@predragnikolic
Copy link
Member

@rwols do you think that the UnhandledPromiseRejectionWarning is a server related problem?

@rwols
Copy link
Member

rwols commented Jul 17, 2019

:D

I guess I should read more than one sentence ahead :)

do you think that the UnhandledPromiseRejectionWarning is a server related problem?

It seems to be coming from Object.readFileSync which is a Node.JS thing. I don't know Javascript.

@predragnikolic
Copy link
Member

You don't know JavaScript, I don't know JavaScript... Nobody knows :D

This is what sublime sends to the server for the textDocument/didChange.

DidChangeTextDocumentParams
{
  'contentChanges': [{'text': '...'}], 
  'textDocument': {
    'uri': 'file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm', 
    'version': 1
  }
}

Here is what happens when I try to readFileSync the "'file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm" file in node.

> fs.readFileSync('file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm')
{ Error: ENOENT: no such file or directory, open 'file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm'
    at Object.openSync (fs.js:438:3)
    at Object.readFileSync (fs.js:343:35)
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path:
   'file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm' }

// If I remove the `file://`, `readFileSync` works.

> fs.readFileSync('/home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm')
<Buffer 69 6d 70 6f 72 74 20 42 72 6f 77 73 65 72 0a 69 6d 70 6f 72 74 20 48 74 6d 6c 20 65 78 70 6f 73 69 6e 67 20 28 48 74 6d 6c 2c 20 41 74 74 72 69 62 75 ... >
> 

@predragnikolic
Copy link
Member

hello @razzeee,
I think (I might be wrong, but) that the elm server need to handle textDocument uri correctly when it contains file:// :)

@razzeee
Copy link
Contributor Author

razzeee commented Jul 17, 2019

I think it does. Here's a screenshot from me debugging the VSCode version.
Take it with a grain of salt as it's against master.
Screenshot from 2019-07-17 23-47-50

And yes, startup is a mess. Sorry for that, will work on that. Still I don't think that that should break anything.

@rwols
Copy link
Member

rwols commented Jul 17, 2019

Let's summarize the discussion so far:

  • We should handle empty completionProvider dict (Account for empty dict as completionProvider #652)
  • We should wire up the three special notification handlers before sending the initialize request
  • There's something fishy going on with the URIs in textDocument/didChange

As it turns out I seem to have the node executable on my machine :)

> fs.readFileSync("/home/raoul/Documents/gintonic2/build/build.ninja")
<Buffer 23 20 43 4d 41 4b 45 20 67 65 6e 65 72 61 74 65 64 20 66 69 6c 65 3a 20 44 4f 20 4e 4f 54 20 45 44 49 54 21 0a 23 20 47 65 6e 65 72 61 74 65 64 20 62 ... >
> fs.readFileSync("file:///home/raoul/Documents/gintonic2/build/build.ninja")
{ Error: ENOENT: no such file or directory, open 'file:///home/raoul/Documents/gintonic2/build/build.ninja'
    at Object.openSync (fs.js:439:3)
    at Object.readFileSync (fs.js:344:35)
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: 'file:///home/raoul/Documents/gintonic2/build/build.ninja' }
> fs.readFileSync(new URL("file:///home/raoul/Documents/gintonic2/build/build.ninja"))
<Buffer 23 20 43 4d 41 4b 45 20 67 65 6e 65 72 61 74 65 64 20 66 69 6c 65 3a 20 44 4f 20 4e 4f 54 20 45 44 49 54 21 0a 23 20 47 65 6e 65 72 61 74 65 64 20 62 ... >
> 

wrapping the URI string into a new URL(...) seems to fix the problem.

@razzeee
Copy link
Contributor Author

razzeee commented Jul 17, 2019

It would be really helpful to get the logs, that the server sends.

https://github.com/elm-tooling/elm-language-server/blob/master/src/providers/astProvider.ts#L33 is the problematic part, but I can't get master branch with vscode to go into that if branch.

So it seems like your forest var does not get populated.
That should only be able to happen if we fail to find your elm.json in the elmWorkspace path you provided.
https://github.com/elm-tooling/elm-language-server/blob/master/src/server.ts#L129

Did you open the folder that has the elm.json or a parent?
So we should probably set the elmWorkspace. https://github.com/elm-tooling/elm-language-server/blob/master/src/server.ts#L76
Still it's weird that the fallback doesn't work.

@predragnikolic
Copy link
Member

I cloned the latest master for elm language server now.
The logs changed a bit, there are less unhandled notification window/logMessage and more of those elm: Adding XXX.elm

LSP: window 2 requests elm for /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm
LSP: starting in /home/predrag/Documents/sandbox/elm-architecture-tutorial
LSP: starting ['node', '/home/predrag/Documents/elm/elm-language-server/out/index.js', '--stdio']
LSP:  --> initialize
LSP: window 2 added session elm
reloading settings Packages/User/Package Syncing.sublime-settings
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP:      {'capabilities': {'renameProvider': True, 'executeCommandProvider': {'commands': ['elmLS.elmAnalyseFixer-9d69137d73b2fca70605bd7437835365', 'elmLS.elmAnalyseFixer.fixAll-9d69137d73b2fca70605bd7437835365', 'elmLS.elmMakeFixer-7f5de75f6322f494c1e1e6ac61819e73']}, 'codeActionProvider': True, 'referencesProvider': True, 'workspaceSymbolProvider': True, 'definitionProvider': True, 'foldingRangeProvider': True, 'documentFormattingProvider': True, 'textDocumentSync': 1, 'codeLensProvider': {'resolveProvider': True}, 'completionProvider': {}, 'documentSymbolProvider': True, 'hoverProvider': True}}
LSP:  --> initialized
LSP:  --> textDocument/didOpen
(node:17910) [DEP0091] DeprecationWarning: crypto.DEFAULT_ENCODING is deprecated.:
(node:17910) [DEP0010] DeprecationWarning: crypto.createCredentials is deprecated. Use tls.createSecureContext instead.:
(node:17910) [DEP0011] DeprecationWarning: crypto.Credentials is deprecated. Use tls.SecureContext instead.:
LSP: <--  client/registerCapability
LSP:      {'registrations': [{'method': 'workspace/didChangeConfiguration', 'registerOptions': {}, 'id': 'f3644278-ae91-427f-9c62-a60ccfd28075'}]}

// could this be the problem??

LSP: Unhandled request client/registerCapability
elm: initializing - folder: "file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/"
elm: Elm version 0.19.0 detected.
elm: Reading elm.json from /home/predrag/Documents/sandbox/elm-architecture-tutorial/elm.json
elm: 2 source-dirs found
elm: Found 52 files to add to the project
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/01-button.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/02-field.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/03-form.elm
...
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser/Internal.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser/Query.elm
elm: Done parsing all files.

The UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory is gone,
But the completion still doesn't work (I set if completionProvider is not None:),
Plus, I noticed that the diagnostics are not working now too.

@predragnikolic
Copy link
Member

predragnikolic commented Jul 17, 2019

I opened the folder that contains the elm.json file, that can be seen in the log I provided above:
elm: Reading elm.json from /home/predrag/Documents/sandbox/elm-architecture-tutorial/elm.json

2019-07-18-005024_653x421_scrot

Here are further logs when the client tries to interact with the server

LSP:  --> textDocument/didChange
LSP:  --> textDocument/didSave
LSP: getting completions, location 860 prefix 
LSP:  --> textDocument/completion
elm: A completion was requested
LSP:      None
LSP:  --> textDocument/codeAction
elm: A code action was requested
LSP:      []
LSP:  --> textDocument/didChange
LSP:  --> textDocument/codeAction
elm: A code action was requested
LSP:      []

LSP:  --> textDocument/didChange
LSP:  --> textDocument/codeAction
elm: A code action was requested
LSP:      []
LSP:  --> textDocument/didChange
LSP:  --> textDocument/didChange
LSP: getting completions, location 1005 prefix o
LSP:  --> textDocument/completion
elm: A completion was requested
LSP:      None
LSP: could not find completion item for inserted "onInput"
LSP:  --> textDocument/didSave
LSP:  --> textDocument/didChange
LSP:  --> textDocument/codeAction
elm: A code action was requested
LSP:      []
LSP:      None
LSP:  --> textDocument/hover
elm: A hover was requested
LSP:      None
LSP:  --> textDocument/codeAction
elm: A code action was requested
LSP:      []
LSP:  --> textDocument/references
elm: References were requested
LSP:      None

No textDocument/publishDiagnostics is send from the server to the client.

@predragnikolic
Copy link
Member

predragnikolic commented Jul 24, 2019

I have some news.
I allowed window/logMessage from the server while initializing.

LSP: starting ['elm-language-server', '--stdio']
LSP:  --> initialize
LSP: window 2 added session elm
elm: Rebuilding tree-sitter for local Electron version
elm: Fetching tree-sitter
elm: Downloading (or using local cache for) https://github.com/tree-sitter/node-tree-sitter/releases/download/v0.14.0/tree-sitter-v0.14.0-node-v64-linux-x64.tar.gz
elm: Fetching tree-sitter-elm
elm: Downloading (or using local cache for) https://github.com/razzeee/tree-sitter-elm/releases/download/v2.2.4/tree-sitter-elm-v2.2.4-node-v64-linux-x64.tar.gz
elm: Rebuild succeeded!
elm: Starting language server for folder: no workspaceFolders
LSP:      {'capabilities': {'codeLensProvider': {'resolveProvider': True}, 'referencesProvider': True, 'hoverProvider': True, 'renameProvider': True, 'definitionProvider': True, 'executeCommandProvider': {'commands': ['elmLS.elmAnalyseFixer-d7294d2dfb41897af7d50f04d1e0ed6a', 'elmLS.elmAnalyseFixer.fixAll-d7294d2dfb41897af7d50f04d1e0ed6a', 'elmLS.elmMakeFixer-0f132a29c6d6968152375ed687c64470']}, 'documentSymbolProvider': True, 'foldingRangeProvider': True, 'codeActionProvider': True, 'completionProvider': {}, 'documentFormattingProvider': True, 'workspaceSymbolProvider': True, 'textDocumentSync': 1}}
LSP:  --> initialized
(node:9690) [DEP0091] DeprecationWarning: crypto.DEFAULT_ENCODING is deprecated.:
(node:9690) [DEP0010] DeprecationWarning: crypto.createCredentials is deprecated. Use tls.createSecureContext instead.:
(node:9690) [DEP0011] DeprecationWarning: crypto.Credentials is deprecated. Use tls.SecureContext instead.:
LSP:  --> textDocument/didOpen
LSP:  --> workspace/didChangeConfiguration
LSP: <--  client/registerCapability
LSP:      {'registrations': [{'id': '5141e58a-f1a7-48e6-aa2e-3649c9a26519', 'method': 'workspace/didChangeConfiguration', 'registerOptions': {}}]}
LSP: Unhandled request client/registerCapability
elm: initializing - folder: "file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/"
elm: Elm version 0.19.0 detected.
elm: Reading elm.json from /home/predrag/Documents/sandbox/elm-architecture-tutorial/elm.json
elm: 2 source-dirs found
elm: Found 52 files to add to the project
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/01-button.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/02-field.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/03-form.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/05-http.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/06-json.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/07-random.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/08-time.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/AnimationManager.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Dom.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Events.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Navigation.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Expando.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/History.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Main.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Metadata.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Overlay.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Report.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Array.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Basics.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Bitwise.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Char.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Debug.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Dict.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Elm/JsArray.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/List.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Maybe.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform/Cmd.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform/Sub.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Process.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Result.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Set.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/String.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Task.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Tuple.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Attributes.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Events.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Keyed.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Lazy.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/http/2.0.0/src/Http.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/json/1.1.1/src/Json/Decode.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/json/1.1.1/src/Json/Encode.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/random/1.0.0/src/Random.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/time/1.0.0/src/Time.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Builder.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser/Internal.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser/Query.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/AnimationManager.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Dom.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Events.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Navigation.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Expando.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/History.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Main.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Metadata.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Overlay.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Report.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Array.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Basics.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Bitwise.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Char.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Debug.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Dict.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Elm/JsArray.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/List.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Maybe.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform/Cmd.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform/Sub.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Process.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Result.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Set.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/String.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Task.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Tuple.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Attributes.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Events.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Keyed.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Lazy.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/http/2.0.0/src/Http.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/json/1.1.1/src/Json/Decode.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/json/1.1.1/src/Json/Encode.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/random/1.0.0/src/Random.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/time/1.0.0/src/Time.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Builder.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser/Internal.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser/Query.elm
elm: Done parsing all files.
LSP: no config found or enabled for view None

@razzeee
Copy link
Contributor Author

razzeee commented Jul 24, 2019

Seems to work for me too, at least what I can tell without ever having used an lsp for sublime :)
🎊

@predragnikolic
Copy link
Member

Well it doesn't work for me
I don't get any errors, but the completions doesn't work, the diagnostics doesn't work...
Nothing is working and I can't figure out why. :D

@razzeee
Copy link
Contributor Author

razzeee commented Jul 24, 2019

Try updating the server version, even if it might "break" things for you. Fingers crossed

@predragnikolic
Copy link
Member

Installing the latest version of elm-lanugage-server allows me to start the elm server successfully.

I get diagnostics and code actions :)
But the goto definition, completions, and references seem to work partially (I will write tomorrow what I mean by that)

Anyway @razzeee thanks :) we are one step closer to bringing elm support to sublime

2019-07-25-005519_1366x768_scrot

@razzeee
Copy link
Contributor Author

razzeee commented Jul 31, 2019

@predragnikolic ping :)
not trying to bug you, but you might have forgotten about it :)
Also there is a new version of the server you might want to check out.

You can also drop the runtime option with the new version, as it is not needed anymore :)

@predragnikolic
Copy link
Member

@razzeee, thanks for reminding me
I tried it now and yes, it is working now :)

@razzeee
Copy link
Contributor Author

razzeee commented Aug 1, 2019

@predragnikolic
Thank you, would you be willing to help me extend the readme? https://github.com/elm-tooling/elm-language-server#editor-support

Or at least share your up to date config :)

@predragnikolic
Copy link
Member

@razzeee I opened a PR for adding elm to the LSP sublime docs :)
You can use that as a reference, but if you need more details, feel free to ping me.

@razzeee
Copy link
Contributor Author

razzeee commented Aug 1, 2019

Thank you, added it to the ls docs.
https://github.com/elm-tooling/elm-language-server#sublime
https://github.com/elm-tooling/elm-language-server#editor-support

The only thing that I did not manage to get to work were code lenses.

@razzeee razzeee closed this as completed Aug 1, 2019
@predragnikolic
Copy link
Member

No, thank you!

Sublime lsp doesn't, yet, support code lens... Yet :-)

@predragnikolic
Copy link
Member

Also I spotted a typo in your docs :-D

Firnt install the language server via npm

@razzeee
Copy link
Contributor Author

razzeee commented Aug 1, 2019

Fixed

rwols pushed a commit that referenced this issue Aug 2, 2019
@razzeee
Copy link
Contributor Author

razzeee commented Aug 2, 2019

I would like to reopen this, as we should find a solution for elm-tooling/elm-language-server#121

@razzeee razzeee reopened this Aug 2, 2019
@predragnikolic
Copy link
Member

predragnikolic commented Aug 3, 2019

Update: The same setup I had done on Linux, which works,
I did this morning on Mac
the server successfully initializes,
but I get no completion, code actions... only the diagnostics work.

elm: Activating tree-sitter...
elm: Starting language server for folder: no workspaceFolders
LSP:      {'capabilities': {'foldingRangeProvider': True, 'hoverProvider': True, 'completionProvider': {}, 'codeLensProvider': {'resolveProvider': True}, 'documentSymbolProvider': True, 'executeCommandProvider': {'commands': ['elmLS.elmAnalyseFixer-0b75aadfce331cd520c34d9797d27441', 'elmLS.elmAnalyseFixer.fixAll-0b75aadfce331cd520c34d9797d27441', 'elmLS.elmMakeFixer-d483956e4a43acec6097129028889eca']}, 'referencesProvider': True, 'codeActionProvider': True, 'documentFormattingProvider': True, 'renameProvider': True, 'workspaceSymbolProvider': True, 'definitionProvider': True, 'textDocumentSync': 1}}
LSP:  --> initialized
LSP:  --> textDocument/didOpen
elm: initializing - folder: "file:///Users/predrag/Documents/sanbox/elm-architecture-tutorial/"
elm: Reading elm.json from /Users/predrag/Documents/sanbox/elm-architecture-tutorial/elm.json
elm: 2 source-dirs found
elm: Found 52 files to add to the project
elm: Adding /Users/predrag/Documents/sanbox/elm-architecture-tutorial/examples/01-button.elm
elm: Adding /Users/predrag/Documents/sanbox/elm-architecture-tutorial/examples/02-field.elm
elm: Adding /Users/predrag/Documents/sanbox/elm-architecture-tutorial/examples/03-form.elm
elm: Adding /Users/predrag/Documents/sanbox/elm-architecture-tutorial/examples/04-maybe.elm
elm: Adding /Users/predrag/Documents/sanbox/elm-architecture-tutorial/examples/05-http.elm
elm: Adding /Users/predrag/Documents/sanbox/elm-architecture-tutorial/examples/06-json.elm
elm: Adding /Users/predrag/Documents/sanbox/elm-architecture-tutorial/examples/07-random.elm
elm: Adding /Users/predrag/Documents/sanbox/elm-architecture-tutorial/examples/08-time.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/AnimationManager.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Dom.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Events.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Navigation.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Expando.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/History.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Main.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Metadata.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Overlay.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Report.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Array.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Basics.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Bitwise.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Char.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Debug.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Dict.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Elm/JsArray.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/List.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Maybe.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform/Cmd.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform/Sub.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Process.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Result.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Set.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/String.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Task.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Tuple.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Attributes.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Events.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Keyed.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Lazy.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/http/2.0.0/src/Http.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/json/1.1.1/src/Json/Decode.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/json/1.1.1/src/Json/Encode.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/random/1.0.0/src/Random.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/time/1.0.0/src/Time.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Builder.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser/Internal.elm
elm: Adding /Users/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser/Query.elm
elm: Adding imports file:///Users/predrag/Documents/sanbox/elm-architecture-tutorial/examples/08-time.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/AnimationManager.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Dom.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Events.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Navigation.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Expando.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/History.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Main.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Metadata.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Overlay.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Report.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Array.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Basics.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Bitwise.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Char.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Debug.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Dict.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Elm/JsArray.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/List.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Maybe.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform/Cmd.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform/Sub.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Process.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Result.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Set.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/String.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Task.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Tuple.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Attributes.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Events.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Keyed.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Lazy.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/http/2.0.0/src/Http.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/json/1.1.1/src/Json/Decode.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/json/1.1.1/src/Json/Encode.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/random/1.0.0/src/Random.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/time/1.0.0/src/Time.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Builder.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser/Internal.elm
elm: Adding imports file:///Users/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser/Query.elm
elm: Done parsing all files.
elm: Diagnostics were requested due to a file open or save

Does no support for workspaceFolders has anything to do with this?

@razzeee
Copy link
Contributor Author

razzeee commented Aug 4, 2019

Hrm, no in your case the workspace folder is the root folder you've opend. That case works, it starts to be problematic, if you have multiple elm.json files or a elm.json file that's not in the root folder.

@rwols
Copy link
Member

rwols commented Aug 4, 2019

If we implement workspaceFolders (and populate that with Sublime's "project folders") , and we update the instructions for the user to say "make sure the folder where elm.json lives is one of your project folders", then the elm-language-server can iterate those workspaceFolders and search for the elm.json file. Does this strategy sound OK?

@rwols
Copy link
Member

rwols commented Aug 4, 2019

The elm language server could also watch for a keyvalue pair in the initializationOptions that points to the elm.json file. I'm not sure wether the initializationOptions can be overridden per Sublime project.

@razzeee
Copy link
Contributor Author

razzeee commented Aug 4, 2019

I'm not sure that that's the way to go. At the moment we're doing it the other way around and it seems to also be what other IDE support packages do.
The client decides when to start / stop the server (see Server Lifetime here https://microsoft.github.io/language-server-protocol/specification ) and there is a server for every topmost elm.json we find. Servers starting servers doesn't sound very fitting.

@rwols
Copy link
Member

rwols commented Aug 6, 2019

The client decides when to start / stop the server and there is a server for every topmost elm.json we find. Servers starting servers doesn't sound very fitting.

I don't understand what you mean by this sentence. Could you clarify what you're envisioning?

There is one connection maintained to a language-server per language per window. So if you have a window open which contains python files and bash scripts, the plugin will maintain a connection to one instance of the python-language-server, and one instance of the bash-language-server.

The concept of rootPatterns is a workaround for neovim because it doesn't have the concept of (multiple) workspaces, whereas VSCode and ST do have workspaces: https://github.com/neoclide/coc.nvim/wiki/Using-workspaceFolders

There is also the desire to have less configuration options, not more.

@razzeee
Copy link
Contributor Author

razzeee commented Aug 6, 2019

AS far as I understood the spec especially the Server Lifetime heading here https://microsoft.github.io/language-server-protocol/specification and the implementation here https://github.com/microsoft/vscode-extension-samples/blob/master/lsp-multi-server-sample/client/src/extension.ts#L104

The client should start a server per workspace, I guess that's already happening now. Our way of thinking about workspaces was probably off. As we thought, we would best only start a server when we're sure that there is an elm.json but maybe it makes sense to let a client still start it and look for an elm.json on the server and either process it or shut down the server again, if we're unable to find one.

@rwols
Copy link
Member

rwols commented Aug 7, 2019

Even without an elm.json the server should still try to make useful suggestions IMO.
For example, clangd can work without a compilation database (but not optimally). If the user notices bogus diagnostics he/she can then decide to invest more time into the docs and learn how to set up a compilation database.
The same can be said for elm-language-server.
Besides, with a textDocument/didOpen notification, can't you just walk up the file tree and search for an elm.json file? That's at least what clangd does when trying to find a compile_commands.json file.

@razzeee
Copy link
Contributor Author

razzeee commented Aug 7, 2019

Yeah, your right, that would be the best thing to do.

@razzeee
Copy link
Contributor Author

razzeee commented Aug 19, 2019

I implemented everything that I think is necessary now, haven't created a release yet, but it's in master. Just FYI.

@predragnikolic
Copy link
Member

@razzeee
Hello I tried again :)
I pulled the latest master
and opened up elm-architecture-tutorial repository in sublime

git clone https://github.com/evancz/elm-architecture-tutorial.git
cd elm-architecture-tutorial
subl .

I opened 07-random.elm the server started to initialize.
After the Elm server initialized.
I got completion suggestions only in one file 04-maybe.elm.
In any other file I got no completions.

output

From the logs I saw something that maybe relates to this.

Notice the section when elm started to add imports.
It only added imports for /04-maybe.elm.
elm: Adding imports file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm

It didn't add imports for the other files in the project, like 07-random.elm.

(node:17159) [DEP0091] DeprecationWarning: crypto.DEFAULT_ENCODING is deprecated.:
(node:17159) [DEP0010] DeprecationWarning: crypto.createCredentials is deprecated. Use tls.createSecureContext instead.:
(node:17159) [DEP0011] DeprecationWarning: crypto.Credentials is deprecated. Use tls.SecureContext instead.:
elm: Elm version 0.19.0 detected.
elm: Reading elm.json from /home/predrag/Documents/sandbox/elm-architecture-tutorial/elm.json
elm: 2 source-dirs and test folders found
elm: Found 52 files to add to the project
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/01-button.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/02-field.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/03-form.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/05-http.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/06-json.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/07-random.elm
elm: Adding /home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/08-time.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/AnimationManager.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Dom.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Events.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Navigation.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Expando.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/History.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Main.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Metadata.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Overlay.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Report.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Array.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Basics.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Bitwise.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Char.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Debug.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Dict.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/List.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Maybe.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Process.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Result.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Set.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/String.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Task.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Tuple.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Elm/JsArray.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform/Cmd.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform/Sub.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Attributes.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Events.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Keyed.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Lazy.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/http/2.0.0/src/Http.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/json/1.1.1/src/Json/Decode.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/json/1.1.1/src/Json/Encode.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/random/1.0.0/src/Random.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/time/1.0.0/src/Time.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Builder.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser/Internal.elm
elm: Adding /home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser/Query.elm
elm: Adding imports file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/04-maybe.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/AnimationManager.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Dom.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Events.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Browser/Navigation.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Expando.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/History.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Main.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Metadata.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Overlay.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/browser/1.0.0/src/Debugger/Report.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Array.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Basics.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Bitwise.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Char.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Debug.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Dict.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/List.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Maybe.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Process.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Result.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Set.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/String.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Task.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Tuple.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Elm/JsArray.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform/Cmd.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/core/1.0.2/src/Platform/Sub.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Attributes.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Events.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Keyed.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/html/1.0.0/src/Html/Lazy.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/http/2.0.0/src/Http.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/json/1.1.1/src/Json/Decode.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/json/1.1.1/src/Json/Encode.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/random/1.0.0/src/Random.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/time/1.0.0/src/Time.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Builder.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser/Internal.elm
elm: Adding imports file:///home/predrag/.elm/0.19.0/package/elm/url/1.0.0/src/Url/Parser/Query.elm
elm: Done parsing all files.
elm: Received open for file:///home/predrag/Documents/sandbox/elm-architecture-tutorial/examples/07-random.elm
elm: Diagnostics were requested due to a file open or save
Package Control: Skipping automatic upgrade, last run at 2019-08-20 23:23:25, next run at 2019-08-21 00:23:25 or after

BTW, the Elm Language Support is no longer on package control.
so I installed Elm Syntax Higlighting.

Here is my lsp elm config:

"elm": {
    "command": [
        "node",
        "/home/predrag/Documents/elm/elm-language-server/out/index.js",
        "--stdio"
    ],
    "enabled": true,
    "languageId": "elm",
    "scopes":
    [
        "source.elm"
    ],
    "syntaxes":
    [
        "Packages/Elm Syntax Highlighting/src/elm.sublime-syntax"
    ],
    "initializationOptions": {
        "elmPath": "elm",
        "elmFormatPath": "elm-format",
        "elmTestPath": "elm-test"
    }
},

@razzeee
Copy link
Contributor Author

razzeee commented Aug 20, 2019

The files in that project do not have module declarations, that's a case, that we don't handle well. So that seems to be the reason.

Yes, the package has been renamed. I already updated the readme in master https://github.com/elm-tooling/elm-language-server#sublime

Thank you for looking at this.

@tomv564
Copy link
Contributor

tomv564 commented Aug 26, 2019

Updated our documentation pointing to the new syntax package as well. Closing as it appears to be working in general, for specific Sublime-related discussions please open a new issue.

@tomv564 tomv564 closed this as completed Aug 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants