jcollard / elm-mode Goto Github PK
View Code? Open in Web Editor NEWElm mode for emacs
License: GNU General Public License v3.0
Elm mode for emacs
License: GNU General Public License v3.0
One of the things I love with haskell-mode is the ability to view the various indentation levels available for a given cycle without necessarily cycling through them. For example:
When my cursor is on the second line of code here (cursor not shown in the screenshot), the various indentation levels available are shown by rendering _
's underneath the relevant characters, and cycling through them works the same way as in elm-mode. This is a lovely feature, and I'd be thrilled to have the option to display this in elm-mode as well.
This is listed as a requirement for installing from source:
Currently 404s. Still a requirement? new repo? help?
It would be nice if some of the variables in elm-mode
were declared with defcustom
rather than defvar
to simplify customization. For example, I'd like to be able to customize elm-compile-arguments
sometimes. I'd be happy to provide patches, but I wanted to see if you were interested in such changes before I went to the effort.
Also, thanks for elm-mode
! It's great, and it's really made learning elm a joy :)
It seems that triple-quoted strings (http://elm-lang.org/docs/syntax#literals) are not handled correctly. For example, this single literal
"""foo"bar"""
seems to be interpreted by elm-mode as if it were these four elements (three literals and bar
as an identifier:
""
"foo"
bar
""
just getting started with elm and elm-mode
Oracle auto-completion is working (although I can't yet see how C-c C-t is supposed to work)
However, when I tried to use only company, not Oracle:
(add-to-list 'company-backends 'company-elm)
with debugging enabled, I get the following stack trace after entering three characters "cou" of
an existing symbol:
Hi.
Thank you for you work on elm-mode!
Would you be willing to contribute a properly configured layer for Spacemacs?
http://spacemacs.org/
https://github.com/syl20bnr/spacemacs
It is probably the most widely used configuration for Emacs now.
I tried out sublime today and I must say I really the way they display elm-oracle. So once turned on, it will display the entire elm-oracle output in the split window below for the word under the cursor. In this example, my cursor was on show
.
I know it's a big ask, but can you do this for emacs as well??
Would be nice to have this on melpa stable
I can't figure out how to get auto-complete working. I prefer auto-complete to company because the screenshot of it in action is great. I'm using spacemacs.
I follow the instruction and added the following to .spacemacs file.
(add-hook 'elm-mode-hook #'elm-oracle-setup-completion)
(add-hook 'elm-mode-hook #'elm-oracle-setup-ac)
Then I use M-x auto-complete-mode
. It tells me that auto-complete-mode
is enabled. But I don't get the autocomplete like you shown in the screenshot.
I noticed when I do M-x auto-complete
gives me this error.
Error in post-command-hook (evil-repeat-post-hook): (wrong-type-argument number-or-marker-p nil)
If I write main = div [] []
then elm-format will render it as
main =
div
[]
[]
When I try to enter code that way using elm-mode I cannot get the arguments to div
to be indented by 2 relative to it no matter how I cycle by hitting the tab key. The closest I can get is this:
main =
div
[]
[]
I'm using elm-mode-20160104.233.
Running elm-format on a buffer which hasn't been saved yet spits the following
Could not find any .elm files on the specified paths:
/home/caleb/dumb.elm
Please check the given paths.
out at your cursor.
Similarly, formatting a file with a syntax error places
Processing file /home/caleb/dumb.elm
ERRORS
at your cursor.
To reproduce, create a new empty file test.elm
and then hit C-c C-f
.
Also, save the file and hit C-c C-f
.
When I lounch "elm-preview-buffer" appear this message:
"If is part of a 3rd party library, its need to be declared as a dependency of your project's elm_depencies.json"
The elm bindings are great to start up an elm reactor and navigate to it in a browser, but I'm having issues once I'm navigating to new projects. I'm finding that I have to manually kill the process otherwise it will continue to open the previously opened project. Perhaps I missing something how to kill the proccess or something?
Running the command comment-region
in elm-mode prompts the user to provide a comment syntax. This should be built into the mode.
At the top level, writing
foo = 1
foo' = 2
foo
is colored, and the foo
in foo'
is also colored, but the '
is not. Identifiers like foo'
and foo'bar'
should all be colored correctly.
Similarly, type'
has type
highlighted as a keyword and then the '
colored as normal text, when type'
is a normal identifier.
Problem seems to be in how the argument list is modified in elm-compile--command
. Compile output below. PR forthcoming.
elm-make HelloWorld.elm --output=~/gdrive/src/elm_by_example/HelloWorld.html --yes --warn --output=elm.js
elm-make 0.16 (Elm Platform 0.16.0)
Usage: elm-make [FILES...] [--output FILE] [--yes] [--report FORMAT] [--warn]
[--docs FILE]
build Elm projects
Available options:
-h,--help Show this help text
--output FILE Write result to the given .html or .js FILE.
--yes Reply 'yes' to all automated prompts.
--report FORMAT Format of error and warning reports (e.g.
--report=json)
--warn Report warnings to improve code quality.
--docs FILE Write documentation to FILE as JSON.
Examples:
elm-make Main.elm # compile to HTML in index.html
elm-make Main.elm --output main.html # compile to HTML in main.html
elm-make Main.elm --output elm.js # compile to JS in elm.js
elm-make Main.elm --warn # compile and report warnings
Full guide to using elm-make at <https://github.com/elm-lang/elm-make>
Compilation exited abnormally with code 1 at Wed Dec 23 22:31:10
I am not entirely sure if this is because of newer import syntax in Elm 0.15 (if any), but indentation is not working properly. In the attached screenshot you will notice that hitting ENTER after the type Coin
line indents it for no apparent reason.
When I write a multi-line doc comment just before a function I often want to use fill-paragraph
to recalculate the line breaks so that it fills neatly. But when I do that the fill-paragraph function fills the function body along with the comment text. I have to add a blank line between the doc comment and the function declaration first to get just the comment to be modified. Can we do something such that fill-paragraph can be applied directly to a doc comment?
The following code sample can be used to see the problem. If I position the emacs cursor in that multiple line comment and run (fill-paragraph)
(via M-q
) then the comment and function are wrapped together, losing the line breaks and indentation of the function.
module Test exposing (..)
{-| module comment
-}
{-| This is a comment long enough that we want to wrap it over multiple
lines. This is a comment long enough that we want to wrap it over multiple
lines. This is a comment long enough that we want to wrap it over multiple
lines.
-}
main : { a : Int, b : Int }
main =
{ a = 1
, b = 2
}
I see the following warnings when I install:
Compiling no file at Fri Dec 18 11:37:55 2015
Leaving directory `d:/dev/msys64/home/adi/.emacs.d/elpa/elm-mode-20151218.57'
Compiling file d:/dev/msys64/home/adi/.emacs.d/elpa/elm-mode-20151218.57/elm-font-lock.el at Fri Dec 18 11:37:55 2015
Entering directory `d:/dev/msys64/home/adi/.emacs.d/elpa/elm-mode-20151218.57/'
Compiling file d:/dev/msys64/home/adi/.emacs.d/elpa/elm-mode-20151218.57/elm-format.el at Fri Dec 18 11:37:56 2015
Compiling file d:/dev/msys64/home/adi/.emacs.d/elpa/elm-mode-20151218.57/elm-indent.el at Fri Dec 18 11:37:56 2015
Compiling file d:/dev/msys64/home/adi/.emacs.d/elpa/elm-mode-20151218.57/elm-interactive.el at Fri Dec 18 11:37:56 2015
In elm-oracle--completions-select:
elm-interactive.el:596:24:Warning: function `remove-if-not' from cl package
called at runtime
elm-interactive.el:683:22:Warning: reference to free variable `elm'
In elm-oracle-setup-ac:
elm-interactive.el:691:17:Warning: reference to free variable `ac-sources'
elm-interactive.el:691:17:Warning: assignment to free variable `ac-sources'
In end of data:
elm-interactive.el:713:1:Warning: the function `ac-define-source' is not known
to be defined.
Compiling file d:/dev/msys64/home/adi/.emacs.d/elpa/elm-mode-20151218.57/elm-mode.el at Fri Dec 18 11:37:56 2015
Compiling file d:/dev/msys64/home/adi/.emacs.d/elpa/elm-mode-20151218.57/elm-util.el at Fri Dec 18 11:37:56 2015
In end of data:
elm-util.el:116:1:Warning: the following functions are not known to be defined:
haskell-ds-backward-decl, haskell-ds-forward-decl,
inferior-haskell-flash-decl
Not sure if you want to do something about them, but here's an issue for tracking.
I created a new elm file in emacs with elm-mode turned on:
-- Play.elm
module Play where
import String
longestName : List String -> Maybe Int
longestName names =
List.maximum (List.map String.length names)
I ran C-c C-c to compile the file followed by C-c C-l to load the file in elm-repl.
A new buffer running elm-repl successfully imports my file
Why can't the 'Play' module be found?
The company-elm
backend does not perform checks to see if the current buffer is in elm-mode
.
This means that, if users follow the wiki-recommended technique of having all of their backends in the list at all times, they get an error on every keypress:
Completion only works inside Elm projects. Create one with
M-x elm-create-package RET
Other backends, like company-ghc
, check the buffer mode and only returns a non-nil value if the buffer is in an appropriate mode:
(defun company-ghc (command &optional arg &rest ignored)
"`company-mode' completion back-end for `haskell-mode' via ghc-mod.
Provide completion info according to COMMAND and ARG. IGNORED, not used."
(interactive (list 'interactive))
(cl-case command
(init (when (and (derived-mode-p 'haskell-mode) company-ghc-autoscan)
(company-ghc-scan-modules)
(add-hook 'after-save-hook #'company-ghc-scan-modules nil t)))
(interactive (company-begin-backend 'company-ghc))
(prefix (and (derived-mode-p 'haskell-mode)
(company-ghc-prefix)))
(candidates (company-ghc-candidates arg))
(meta (company-ghc-meta arg))
(doc-buffer (company-ghc-doc-buffer arg))
(location (company-ghc-location arg))
(annotation (company-ghc-annotation arg))
(sorted t)))
When I try C-c C-n on OS X 10.9 with aquamacs 3.0 preview (which is based on emacs24), I get the following error message:
This was for a file called Demo.elm
that contained only main = asText 42
. Do I need to add a elm_dependencies.json
file to create a "root"? Is this connected to #8?
in some simple examples, e.g.
http://elm-lang.org/examples/hello-html
there is no module declaration, which makes elm--get-module-name fail
I'm an emacs newb so perhaps it's that but I enabled the elm layer in spacemacs and when I enter a new line the indentation doesn't line up properly. I get:
module Bingo where
import Html
import String
main =
"bingo"
|> String.toUpper
|> String.trimRight
|> Html.text
Instead of the desired result:
module Bingo where
import Html
import String
title =
"bingo!"
|> String.toUpper
|> String.trimRight
|> Html.text
main =
title
Is there something i'm doing wrong here? Also using ctrl =
to auto indent makes it go out of whack as well. It produces:
module Bingo where
import Html
import String
title =
"bingo!"
|> String.toUpper
|> String.trimRight
|> Html.text
main =
title
See here: spacemacs issue thread specifically this comment. I reverted back to e0318eb and all is working fine again. So not sure if this is a bug here or in how spacemacs handles elm-mode. Any advice would be great, thanks!
Say I am in this situation:
Action = Connect String
| Send String
| Receive String
| Disconnect
update : Action -> Model -> Model -- cursor here
When I press enter, it indents the type definition according to the previous block:
Action = Connect String
| Send String
| Receive String
| Disconnect
update : Action -> Model -> Model
-- cursor here now.
I have noticed that the post line indentation is almost always wrong, so is there a way to disable it?
Several syntax changes took place from 0.12.3 to 0.13.
Every time after I update my packages with cask and there is a new version of elm-mode
when I (require 'elm-mode)
I get (void-variable elm)
. This is from my init:
Debugger entered--Lisp error: (void-variable elm) #[nil "\302�\303\304 BD\"\207" [elm elm-oracle--pattern ac-define-source (candidates elm-oracle--get-completions ac-prefix t) prefix] 5]() eval-after-load(auto-complete #[nil "\302�\303\304 BD\"\207" [elm elm-oracle--pattern ac-define-source (candidates elm-oracle--get-completions ac-prefix t) prefix] 5]) require(elm-interactive) byte-code("\300\301!\210\300\302!\210\300\303!\210\300\304!\210\300\305!\207" [require elm-tags elm-format elm-indent elm-interactive elm-font-lock] 2) require(elm-mode) eval-buffer(#<buffer *load*-256167> nil "/home/caisah/.emacs.d/config/programming/elm-config.el" nil t) ; Reading at buffer position 93 load-with-code-conversion("/home/caisah/.emacs.d/config/programming/elm-config.el" "/home/caisah/.emacs.d/config/programming/elm-config.el" nil t) require(elm-config) eval-buffer(#<buffer *load*-429947> nil "/home/caisah/.emacs.d/config/general-settings.el" nil t) ; Reading at buffer position 2796 load-with-code-conversion("/home/caisah/.emacs.d/config/general-settings.el" "/home/caisah/.emacs.d/config/general-settings.el" nil t) require(general-settings) eval-buffer(#<buffer *load*> nil "/home/caisah/.emacs.d/init.el" nil t) ; Reading at buffer position 313 load-with-code-conversion("/home/caisah/.emacs.d/init.el" "/home/caisah/.emacs.d/init.el" t t) load("/home/caisah/.emacs.d/init" t t) #[0 "�\205\262 \306=\203�\307�\310Q\202; \311=\204�\307�\312Q\202;\313\307\314\315#\203*\316\202;\313\307\314\317#\203:\320\nB�\321\202;\316\322�\323�\322\211#\210�\322=\203a\324\325\326\307�\327Q!\"\323�\322\211#\210�\322=\203
��\210�\203\243\330�!\331\232\203\243\332�!\211\333P\334�!\203}\211\202\210\334�!\203\207�\202\210\314\262��\203\241\335��"\203\237\336\337��#\210\340\341!\210��\266�\f?\205\260\314�\323\342\322\211#)\262�\207" [init-file-user system-type delayed-warnings-list user-init-file inhibit-default-init inhibit-startup-screen ms-dos "" "/_emacs" windows-nt "/.emacs" directory-files nil "^\.emacs\(\.elc?\)?$" "/.emacs" "^_emacs\(\.elc?\)?$" (initialization "_emacs' init file is deprecated, please use
.emacs'") "~/_emacs" t load expand-file-name "init" file-name-as-directory "/.emacs.d" file-name-extension "elc" file-name-sans-extension ".el" file-exists-p file-newer-than-file-p message "Warning: %s is newer than %s" sit-for 1 "default"] 7 "\n\n(fn)"]()
command-line()
normal-top-level()`
I have to delete the package and install it via package
to get it working. Do you have any ideas why this may happen? Is it a problem with elm-mode
or cask
? How could I fix it? Thanks!
I have the following project structure:
|_ elm-package.json
|_ elm-stuff
|
|_ (various depedencies)
|_ src
|_ MyFile.elm
When I compile the MyFile.elm
buffer, the process generates a new elm-package.json
and elm-stuff
directory; this also happens for previewing. When I run elm-make src/MyFile.elm
, these artifacts are not created.
I'm fairly sure that I'm missing something, I'm just not sure what it is. Thanks.
Is there a way to automatically pass certain flags to the repl? i.e. When the file loaded into the repl is in a subdirectory, have the repl activated with :flags add --src-dir=src
or something like this.
PS I'm not able to do this even manually right no (elm make complains when trying to import any module after altering --src-dir
in this way, so I guess I'm missing something...
Consider this state:
f x =
^
where ^
indicates cursor position. Starting a new line results in this state:
f x =
f
^
which is never correct. Furthermore, using tab to cycle through tab stops does not remove f
, as it did before #22 if you tabbed through this option.
Hello,
I am using Windows 8.1 x64
, my emacs version is 24.5.1
and I have the latest Elm
and elm-mode
versions. I am trying to configure elm-mode on emacs. So far everything seems to work fine.
Except that "elm-oracle" part. I cannot get it to work.
I installed elm-oracle
and then I tried adding (add-hook 'elm-mode-hook #'elm-oracle-setup-completion)
or (add-hook 'elm-mode-hook #'elm-oracle-setup-ac)
on my .emacs
file but I just cannot get it to work.
Am I missing something or there is an actual problem here?
Struggling to get elm-oracle-setup-completion
to work, though completion (using company seems to work).
This is my setup (part of a language layer I've written for Spacemcs).
https://github.com/usharf/spacemacs/blob/elm-lang-layer/contrib/!lang/elm/packages.el#L36
When trying to invoke this function I get:
command-execute: Symbol's function definition is void: elm-oracle-type-at-point
g g
I can see that the interactive functions support passing an OUTPUT file name for compilation, but not sure how to use it. Coming a buffer always yields "elm.js" rather than "<buffer/file-name>.js"...
Does elm (or this package) have support for completion of any sort?
Thx for elm-mode
I am using aquamacs and I type C-c C-l to get the interactive elm-repl buffer,
it complains about the missing symbol letrec. What should I do to get a correct
definition of this symbol?
Relevant message :
Symbol's function definition is void: letrec
Aquamacs version:
GNU Emacs 23.4.1 (x86_64-apple-darwin12.3.0, NS apple-appkit-1187.37)
of 2013-06-14 on acs-trailblazer.ist.psu.edu - Aquamacs Distribution 2.5
Relevant Messages extract
Loading /Users/cog/git/elm-mode/elm-map.el (source)...done
Invalid face reference: quote [115 times]
run-elm-repl: Symbol's function definition is void: letrecInvalid face reference: quote
Invalid face reference: quote [160 times]
After installing elm-mode
, I made a new elm file and typed:
main : Element
and then hit enter. The next line was automatically indented 5 spaces, when it shouldn't have been indented at all. I then typed main =
and hit tab twice, which unindented the line to the beginning, which is what I want. I then typed out the rest of the line, hit enter, and the line was again indented to 5 spaces.
This is obviously not the correct functionality. Are you experiencing this too, or is it just me?
I tried installing elm-mode this evening, and I received an error that let-alist-1.0.7
was required, but only 1.0.4
was found. I hit GNU ELPA and it looks like 1.0.4
is the latest available.
Would be rad to have elm-mode run elm-format on save :)
The title says it all. It'd be cool to see type signatures when near/inside of functions. This code almost does it:
(add-hook 'elm-mode-hook
(lambda ()
(set (make-local-variable 'eldoc-documentation-function)
'elm-oracle-type-at-point)))
But needs to be cleaned up:
Unknown type
. I think it's okay to just show a blank minibuffer if the type is unknownUnknown type
when pointing at something like False
I find emacs keep crashing when I try to copy and paste in Elm. This is my view code and I want to move all the styles to the bottom of the file.
view : Signal.Address Action -> Model -> Ui.NativeUi
view address model =
NativeUi.Elements.view
[ componentStyle ]
[ image
[ imageStyle
, source model.image
]
[]
, NativeUi.Elements.view
[ Ui.style [ Style.flex 1 ] ]
[ text
[ Ui.style
[ Style.fontSize 20
, Style.marginBottom 8
, Style.textAlign "center"
]
]
[ Ui.string model.title ]
, text
[ Ui.style
[ Style.textAlign "center"
]
]
[ Ui.string model.year ]
]
]
So when I try to cut and paste the following code to the bottom of file, it goes into "Indent cycle (2)" (infinite loop I guess) and Emacs just stop responding. I had to kill emacs. (I'm using spacemacs)
Ui.style
[ Style.fontSize 20
, Style.marginBottom 8
, Style.textAlign "center"
]
Thanks.
First off, let me say I really like the cycles-based indentation approach used by elm-mode. I've used a similar one in haskell-mode before, and it works really nicely with this kind of language (in fact haskell-mode renders _
's underneath the various levels in the cycle as well, which would be nice to have in this mode as well, but I digress...) :)
However, it seems the indentation level is a bit inconsistent with all of the Elm example code I see elsewhere. It seems that most example code just uses two spaces for an indentation "level", yet the various levels in the cycles provided by this plugin seem more arbitrary.
For example, here's a simple main
definition in one of my projects, indented by hand to match what I believe is the standard with Elm example code:
main =
App.program
{ init = init
, update = update
, subscriptions = \_ -> Sub.none
, view = view
}
However, when I use the levels provided by this mode, it looks like this:
main =
App.program
{ init = init
, update = update
, subscriptions = \_ -> Sub.none
, view = view
}
Notice the extra spaces in the record value lines. The only options for indentation the mode provides in the first record line (starting with {
) are either no indentation, or the indentation shown above. Before inserting the {
character, it gives me either no indentation or the position directly under the .
from the line above, which is also wrong (3 spaces from the line above instead of 2). This is just one example, but the problem seems to manifest in many places and in many different ways.
Is there a specific reason this style was chosen? It appears to be inconsistent with both other Elm code I see around, and also what haskell-mode does (though I may be wrong).
Given
|
module Foo where
...
where |
denotes point
, indentation raises an error:
Debugger entered: ((cl-assertion-failed (<= start end) nil))
cl--assertion-failed((<= start end))
elm-indent-in-comment(2 1)
elm-indent-indentation-info()
elm-indent-cycle()
indent-for-tab-command(nil)
funcall-interactively(indent-for-tab-command nil)
#<subr call-interactively>(indent-for-tab-command nil nil)
ad-Advice-call-interactively(#<subr call-interactively> indent-for-tab-command nil nil)
apply(ad-Advice-call-interactively #<subr call-interactively> (indent-for-tab-command nil nil))
call-interactively(indent-for-tab-command nil nil)
command-execute(indent-for-tab-command)
This appears to be because - in elm-indent-indentation-info
, elm-indent-start-of-def
returns a position greater than (point)
. Not obvious to me what the most correct fix for this would be, sorry.
My setup: OS X 10.9 with the latest Aquamacs (based on emacs 24)
When I open the REPL with C-c C-l, I get the following message:
> Could not parse command 'change-root "/Users/evan/Desktop/test/"':
with some more elaboration about the parse error. I took this out of the 0.2 release because I did not understand what it was for, and after that, the REPL seem to work fine despite the fact that the command fails.
Is this command needed? Is there a way to get around it?
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.