I’d like to open a discussion of what additional features text editors might offer in the way of support for Elm developers. My only suggestion for the moment has to do with large files, with which I have made my peace. The project I am working with illustrates this. There are 14 files, 4400 loc in all, with Main.elm at 2600, and a good bit of code off-loaded in libraries I’ve written for apps of this kind. It all looks pretty normal except or Main. I’ve found the key to keeping sane is to post section headers as guideposts along the way, e.g. – MODEL, – MSG, --DOCUMENT HELPERS, etc. This way it is easy to find things. If one keeps like things together and set off by section headings, just like in normal well-structured document, the size of the file is not a problem. I recently collected the guideposts/section headings in a table of contents neear the beginning of the file. This also helps.
But it strikes me that things could be much better with proper editor support. Here is short list of possbilities
The editor automatically generates the table of contents (TOC)
The entries in the act as live links to the topis in the body of the code.
Topic headings could be written in Markdownish form, say, – # MODEL, – ## Some doc utlities,
etc. to give more structure, both in the body and the TOC.
Sections of the code can be expanded/collapsed, so as to make navigation and getting an overview still easier.
Perhaps this sort of thing could be done with a plug-in.
Hi. I fell in love with Emacs. Because I work from iPad I’m limited to terminal code editors. My colleague recently told me that it would be nice to have opportunity to fold Elm code at global -- comments. It appears that Emacs supports it out of the box with 1 line of configuration. That’s called outline mode. And it has support to fold/unfold blocks of code, jump between headings and much more.
Personally I use different way of navigating file. I use go to definition at a point (Emacs way to call cursor) or jump to definition by name. Because most of the time I know where I want to go.
What are your thoughts about this implementation of navigating sections? It supports navigation using the keyboard and also clicking on the section headers to jump there. I think a video explains it better than I could with words:
As you can see in the video, I used the trick to model the section headings as Elm type declarations. This makes standard tooling pick them up and include it in the TOC for the types and functions in the Elm code file. By giving the section types a distinctive name, we make it easy to filter this TOC down to just the section headings.
For the same two points (1 and 2), in Atom there is elm-navigator which kind of does that. Maybe worth looking at or getting some inspiration from?
(I have used it but then uninstalled it because I rarely used it. A TOC is just not how I navigate through my code.)
I use Visual Studio Code, remoting into WSL. The elm plugin is pretty good.
A small change would be opening the file currently being worked on using Elm Reactor.
A larger change would be updating the syntax highlighting as the file is being edited–not just when it gets saved.
I’ve found that “Go to/Peek Definition” doesn’t work at all–no symbols found–whether in the same file or in another package. Could be a quirk of my environment, or it could be a bug.
I think that code folding would make a ToC feature redundant.
Supporting markdown in the comments is an interesting idea.
Idris has some good editor features that I haven’t come across in other languages. It supports a command which can expand a symbol into cases - for instance if you have a case myMaybe it can generate the Just and Nothing clauses for you. Pretty nice for a big case statement in your update function, when you’ve added some new message types.
The JetBrains IDEs (aka Intellij/WebStorm etc.) calls this Structure View. It’s a common interface that any language plugin can write an implementation for. It supports nesting/collapsing too, although the Elm plugin currently only provides a flat view.