rundis / elm-light

Elm language plugin for Light Table
https://rundis.gitbooks.io/elm-light-guide/content/
MIT License
133 stars 10 forks source link

Support eval all in REPL #35

Open Spenhouet opened 8 years ago

Spenhouet commented 8 years ago

cmd (strg) + shift + enter should evaluate the current file not only the current line. At the moment, it doesn't do anything.

I'm not sure if this is a elm-light or a light table problem or if this should normaly work and just doesn't on my pc.

I'm using a fresh installation with elm 0.18, lighttable 0.8.1, elm-light 0.5, node v6.9.1 on Win10 with german keymap.

rundis commented 8 years ago

Yeah, well that feature isn't supported. It's also somewhat tricky because the elm-repl doesn't support type annotations and comments etc. So it's not a bug, but if you think it would be really useful please by all means create a feature request and I can look into it.

(I tend to open an anonymous repl in the project and just import the modules I want to interact with in a repl session.)

Spenhouet commented 8 years ago

Okay, good to know. I don't know if i especially need this feature. In the end i would like to evaluate my code and check for errors.

If i do a evaluation for one line, it doesn't work because it doesn't know any variable at this line. For example the following isn't working:

testVar = 1
1 + testVar
-- NAMING ERROR ---------------------------------------------- repl-temp-000.elm

Cannot find variable `testVar`

3|   1 + testVar
         ^^^^^

If i do any of :elm.make, :elm-format, :elm.lint i don't get any inline error message (only red or yellow underlining). And most of the time i only get really useless error messages like:

I ran into something unexpected when parsing your code!

So is there any way to evaluate the elm code with helpfull inline error messages like :elm.browse gives but inline?

rundis commented 8 years ago

Hmm... screen shot 2016-11-21 at 18 45 05

For validating/linting your Modules you should use the Elm: Lint selected file command (as per https://rundis.gitbooks.io/elm-light-guide/content/linting.html). I have enabled linting enabled on save so it's just a cmd/ctrl-s away.

You view the detalls of warnings/errors by placing the cursor somewhere in the range of the squiggly lines and invoke the command Linter: Show details at cursor (you obviously want a keyboard shortcut set up for that ! )

Spenhouet commented 8 years ago

Oh i didn't know that. Yes, that does help 👍 I just added a keymap for :editor.linter.details in a intellij style:

[:editor.elm "ctrl-s" :save :clear-console :elm-format :elm.lint :elm.browse :refresh-connected-browser]
[:editor.elm "alt-enter" :editor.linter.details]

Thank you again. Eventually you should add recomendet keymaps to your elm-light tutorial :)

rundis commented 8 years ago

Hehe it's deliberately light on keymaps (I wouldn't recommend my current personal mapping which is rather evolutionary caotic), but maybe I should nick something from atom/vscode or intellij and provide a suggestion people can copy paste.

I did create this reference chapter to at least give people an overview of mappable commands though: https://rundis.gitbooks.io/elm-light-guide/content/reference.html#commands

Spenhouet commented 8 years ago

Oh i missed that chapter. A shame, it would have solved my problems and saved your time if i had seen it. Thanks for pointing it out.

Yes, some intellij like keymappings would probably help some elm-light beginners like me.