elm-tooling / elm-language-server Goto Github PK
View Code? Open in Web Editor NEWLanguage server implementation for Elm
Home Page: https://www.npmjs.com/package/@elm-tooling/elm-language-server
License: MIT License
Language server implementation for Elm
Home Page: https://www.npmjs.com/package/@elm-tooling/elm-language-server
License: MIT License
At the moment features like completions etc will make it seem like they work if you import the correct things, even if that is from the testing dependencies or vice versa.
Doesn't seem right, should always be on the level of the elm.json
There are issues with timeouts, and jankiness on formatting. But it looks like the root cause is that formatting itself is slow, and therefore execution leads to timeouts. Depending on if the plugin runs the format actions asynchronous or synchronous, the result is either no buffer update or blocking the editor for > 1s. So maybe there is something wrong, or something that can be improved. Maybe changes trigger diagnostics, and format, and format changes the text, which triggers diagnostics again? :)
Related neoclide/coc.nvim#895
These are basically done from my POV, but i really want feedback on the symbols we're recognizing and how we are mapping them.
This is how we map them currently.
This is a list of SymbolKind we're using:
+
or |>
)These are also available in the languague server spec:
I would really like feedback here.
Hello
I ran all the commands from the readme with yarn and I get:
rlopez ~/R/p/elm-language-server *master λ y link
yarn link v1.16.0
success Registered "@elm-tooling/elm-language-server".
info You can now run `yarn link "@elm-tooling/elm-language-server"` in the projects where you want to use this package and it will be used instead.
Done in 0.07s.
And using: elm-language-server --stdio
gives:
fish: Unknown command elm-language-server
add: Int -> Int -> Int
add a b =
a + b
rename a to x -> no changes
[Trace - 3:38:42 PM] Sending request 'textDocument/rename - (31)'.
Params: {
"textDocument": {
"uri": "file:///home/as/Dev/repository/vim-emulation/src/Main.elm"
},
"position": {
"line": 689,
"character": 4
},
"newName": "x"
}
[Trace - 3:38:42 PM] Received response 'textDocument/rename - (31)' in 2ms.
Result: {
"changes": {}
}
Coc / Vim
I haven't been able to fully track down why, but settings in elm-analyse.json
are getting ignored. As an example, if you have:
{
"checks": {
"ImportAll": false
},
}
elm-ls
still reports ImportAll
warnings.
From my digging, it looks like the port that loads elm-analyse.json
is getting initialized correctly:
From file-loading-ports to context.
I haven't poked the internals of elm-analyse to understand why it's ignoring them.
Find the correct source of definitions for:
Even from other files or when they're prefixed/aliased
This is pretty similiar to the hoverProvider, so they could likely share big parts of their code. https://github.com/Razzeee/elm-language-server/issues/8
elm-tooling/elm-language-server#editor-support
There's quite a lot of repetitive types that are inlined within generic types, such as arrays.
For instance:
private findElmFilesInFolders(
elmFolders: Array<{ path: string; writable: boolean }>,
): Array<{ path: string; writable: boolean }> {
let elmFilePaths: Array<{ path: string; writable: boolean }> = [];
for (const element of elmFolders) {
elmFilePaths = elmFilePaths.concat(this.findElmFilesInFolder(element));
}
return elmFilePaths;
}
private findElmFilesInFolder(element: {
path: string;
writable: boolean;
}): Array<{ path: string; writable: boolean }> {
return glob
.sync(`${element.path}/**/*.elm`)
.map(a => ({ path: a, writable: element.writable }));
}
The following type appears 4 times in snippet above.
{ path: string; writable: boolean }
This could be extracted into a separate interface. This will improve readability and reduce code duplication.
The format provider uses elm-format
and should be done.
It works fine for me on windows, but linux says it doesn't find a global installation, I do have one. So it might be my linux or a problem in general.
No idea about macOS
If we use the web assembly version, we can probably get rid of rebuilder and the needed download logic.
https://github.com/georgewfraser/vscode-tree-sitter can be used as a reference on how to do this.
UNKNOWN IMPORT - The MainTest module has a bad import: import Test I cannot find that module! Is there a typo in the module name? The "source-directories" field of your elm.json tells me to only look in the src directory, but it is not there. Maybe it is in a package that is not installed yet?
Currently direct dependencies are read, but test-dependencies
are not. This will lead to
elm-language-server/src/providers/astProvider.ts
Lines 89 to 92 in e43252a
"dependencies": {
"direct": {
},
"indirect": {
}
},
"test-dependencies": {
"direct": {
},
"indirect": {
}
}
For now it's probably an improvement to add test-dependencies
. In the long term there needs to be some distinction between dependency types, to disallow importing test dependencies in source files.
Shows if a function or type is exposed or not. Doesn't offer anything more right now.
Other things we could do:
There is no mention of installing the elm-language-server
executable in the readme, there's no releases available either. The closest thing there to install instructions is the editor support section, but without the executable available those wont work (I've tried).
Installation instructions seem like a pretty standard thing to include in a readme, some might say its the most important thing. If there's a reason they are not present, than this readme should at least include a note addressing the exclusion of them.
At the moment we error out on analytics creation.
We currently have two ways diagnostics are generated, there might be more in the future:
elm make
elm analyse
Testing
Bugfixes
Possibility to give the path to both if they're not installed global
Elm analyse works fine on windows for me.
Elm make tries to open the generated elm.js
every time it runs. Pretty weird, hopefully just something that happens when you run the dev version.
Linux says it doesn't global installations, I do have them. So it might be my linux or a problem in general.
No idea about macOS.
We want to autocomplete on everything that is imported like:
Keep in mind most can be prefixed/aliased
Stuff we need utils and core extension for:
Later:
We might also want a list of other available functions, types that are not imported yet.
We basically want all that applies from here https://code.visualstudio.com/api/language-extensions/programmatic-language-features
I crossed out the ones I think don't make sense, please comment if you disagree. We can still decide in each issue if any of these don't work for elm
Find the all references for:
Even from other files or when they're prefixed/aliased
Commands supplied by the old vscode implementation
name | Description | Keyboard |
---|---|---|
elm.replStart | Elm: REPL - Start | |
elm.replSendLine | Elm: REPL - Send Line | Alt+/ |
elm.replSendSelection | Elm: REPL - Send Selection | Alt+Enter |
elm.replSendFile | Elm: REPL - Send File | |
elm.reactorStart | Elm: Reactor - Start | |
elm.reactorStop | Elm: Reactor - Stop | |
elm.make | Elm: Make | Ctrl+F5 |
elm.makeWarn | Elm: Make --warn | |
elm.install | Elm: Install packages/dependencies | |
elm.browsePackage | Elm: Browse packages/dependencies documentation | |
elm.clean | Elm: Clean build artifact | |
elm.analyseStart | Elm: Start elm-analyse | |
elm.analyseStop | Elm: Stop elm-analyse |
We need to figure out which ones we want to have. The elm analyse ones could be ignored for now.
The first open document doesn't get most features. We need to wait for the inital parsing to be done before kicking off all other tasks.
Hi.
I tried to use @elm-tooling/elm-language-server - npm with coc.nvim.
$ npm i -g @elm-tooling/elm-language-server
"elmLS": {
"command": "elm-language-server",
"args": [
"--stdio"
],
"filetypes": [
"elm"
],
"rootPatterns": [
"elm.json"
],
"initializationOptions": {
"runtime": "node",
"elmPath": "elm",
"elmFormatPath": "elm-format",
"elmTestPath": "elm-test"
}
},
I opened elm file, err occurred.
[coc.nvim] Server elmLS failed to start: Request initialize failed unexpectedly without providing any details.
This language server has outputted this message(:CocCommand workspace.showOutput
).
[Trace - 5:27:44 PM] Sending request 'shutdown - (1)'.
[Trace - 5:27:44 PM] Received response 'shutdown - (1)' in 2ms.
No result returned.
[Trace - 5:27:44 PM] Sending notification 'exit'.
No parameters provided.
My env is as follows.
$ node -v
v11.12.0
$ npm --version
6.7.0
$ elm --version
0.19.0
$ elm-format --help
elm-format 0.8.1
$ elm-test --version
0.19.0-rev6
$ vim -v
NVIM v0.4.0-dev
This language server works correctly if I create binary as described in README.
$ npm install
$ npm run compile
$ npm link
Hi! I'm trying to use it with NeoVim and Coc, but it doesn't work.
Here is the error that pops up whenever I open an Elm file:
[coc.nvim] Server elm failed to start: Command "elm-ls" of languageserver.elm is not executable: Error: not found: elm-ls
And here is the Coc configuration file:
{
"suggest.minTriggerInputLength": 1,
"languageserver": {
"elm": {
"command": "elm-ls",
"args": ["--stdio"],
"filetypes": ["elm"],
"rootPatterns": ["elm.json"],
"initializationOptions": {
"runtime": "node",
}
}
}
}
It doesn't find the elm-ls
executable, but there are no standalone install instructions. What am I missing?
Thanks in advance :)
With the new way we're doing snippets, we can use markdown for the descriptions now.
recordtype
should become typeAlias
etcFind all renames for:
Even from other files or when they're prefixed/aliased.
This is pretty similiar to the hoverProvider & definitionProvider, so they could likely share big parts of their code.
But be aware, there are even places that probably don't show up in our definition (or references) provider, that we want to rename. Like a functions type definition.
Make sure we don't edit files outside of our scope, that are in our package cache or similar.
At the moment strings are concatenated in two ways:
+
operatorI'd say code should support just one of these for the sake of consistency and enforce that using https://palantir.github.io/tslint/rules/prefer-template/ to allow just template literals.
format ranges isn't something that is supported by elm-format
. Why is the capability true
?
We might not need this, as the tree sitter should also be able to provide us with errors or at least check if there are errors.
It looks like it is downloading treesitter on start. Is it cached? Can we move this to the npm install
step? (coc/vim)
[Trace - 10:45:18 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "Rebuilding tree-sitter for local Electron version"
}
[Info - 10:45:18 PM] Rebuilding tree-sitter for local Electron version
[Trace - 10:45:18 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "Fetching tree-sitter"
}
[Info - 10:45:18 PM] Fetching tree-sitter
[Trace - 10:45:18 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "Downloading from https://github.com/tree-sitter/node-tree-sitter/releases/download/v0.14.0/tree-sitter-v0.14.0-node-v67-linux-x64.tar.gz"
}
[Info - 10:45:18 PM] Downloading from https://github.com/tree-sitter/node-tree-sitter/releases/download/v0.14.0/tree-sitter-v0.14.0-node-v67-linux-x64.tar.gz
[Trace - 10:45:18 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "Fetching tree-sitter-elm"
}
[Info - 10:45:18 PM] Fetching tree-sitter-elm
[Trace - 10:45:18 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "Downloading from https://github.com/razzeee/tree-sitter-elm/releases/download/v2.2.4/tree-sitter-elm-v2.2.4-node-v67-linux-x64.tar.gz"
}
[Info - 10:45:18 PM] Downloading from https://github.com/razzeee/tree-sitter-elm/releases/download/v2.2.4/tree-sitter-elm-v2.2.4-node-v67-linux-x64.tar.gz
[Trace - 10:45:19 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "Rebuild succeeded!"
}
[Info - 10:45:19 PM] Rebuild succeeded!
[Trace - 10:45:19 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "initializing - folder: \"file:///home/as/Dev/repository/vim-emulation/\""
}
@antew Windows seems to report the whole path here:
https://github.com/elm-tooling/elm-language-server/blob/master/server/src/providers/diagnostics/elmAnalyseDiagnostics.ts#L76
Like: message.file == "..\..\..\c:\development\Weiterbildung\elm-spa-example\src\Main.elm"
Some change broke the elm format diffing.
At least on linux, it pretty much inlines the whole file as a diff on every save.
Show hovers for
Even from other files or when they're prefixed/aliased
This is pretty similiar to the definitionProvider, so they could likely share big parts of their code. https://github.com/Razzeee/elm-language-server/issues/9
Context sensitive completions:
This is a ticket for later, when things stabalize and we want to try it with other clients
At the moment we add completions for sub types/functions to a list, e.g. Html.div
But that doesn't really play nice with the spec, as you might end up typing Html.
then auto complete. Under certain prerequisites this leads to Html.Html.div
which is not what we want.
Typescript or C# would first let you choose Html
then would detect that the completion your expanding on is in the Html package and only send the correct functions.
Hi, I'm really excited about this thing because I love Elm, and I'd like to use it in my preferred environment, which is actually emacs.
This may just be me being dumb, but I keep getting:
[Trace - 06:25:31 PM]
Received notification 'window/logMessage'.
Params:
{
"message": "Rebuilding tree-sitter for local Electron version",
"type": 3
}
and then nothing after that. I've run npm install in the root directory, and in the client directory and server directory. Is there anything else that I need to do to get tree-sitter/the server to work?
Thanks for this project, and thanks in advance for any help you can give me!
Currently we are only loading all files on import. We need to figure out a way how to do this after elm.json
changes and elm make
downloaded the new deps.
Repro steps:
elm-make
error and no elm-analyse
warning.elm-make
error.Expected:
No errors reported.
Observed:
Last elm-make error still appears in diagnostics.
This doesn't happen if the last error is an elm-analyse
warning.
(Note: observed in both VSCode and vim)
This is a quite open-ended provider that would be the main place for us to integrate refactoring capabilities.
The codeAction
spec has some pre-defined Code Action namespaces. I think some editors may display the code actions to the user differently based on the namespace of each action. Some features to support (and their corresponding namespaces) would be:
Base kind for quickfix actions: 'quickfix'
import
(if a user uses a value from a package they haven't imported yet, add an import line)Base kind for refactoring extraction actions: 'refactor.extract'
let
statementBase kind for refactoring inline actions: 'refactor.inline'
let
statementBase kind for refactoring rewrite actions: 'refactor.rewrite'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.