Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions elixir-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@
(eval-when-compile
(defconst elixir-rx-constituents
`(
;; Match `@doc' or `@moduledoc' syntax, with or without triple quotes.
(heredocs . ,(rx symbol-start
(or "@doc" "@moduledoc" "~s")
symbol-end))
(keywords . ,(rx symbol-start
(or "->" "bc" "lc" "in" "inbits" "inlist" "quote"
"unquote" "unquote_splicing" "var" "do" "after" "for"
Expand Down Expand Up @@ -328,6 +332,10 @@
(group module-names))
1 font-lock-type-face)

;; Heredoc
(,(elixir-rx (group heredocs))
1 font-lock-builtin-face)

;; Keywords
(,(elixir-rx (group keywords))
1 font-lock-keyword-face)
Expand Down
2 changes: 1 addition & 1 deletion elixir-smie.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
(modify-syntax-entry ?\[ "(]" table)
(modify-syntax-entry ?\] ")[" table)
(modify-syntax-entry ?\: "'" table)
(modify-syntax-entry ?\@ "'" table)
(modify-syntax-entry ?@ "_" table)
table)
"Elixir mode syntax table.")

Expand Down
25 changes: 25 additions & 0 deletions test/elixir-mode-font-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,28 @@ end"
end"
(should (eq (elixir-test-face-at 5) 'font-lock-function-name-face))
(should (eq (elixir-test-face-at 8) 'font-lock-function-name-face))))

(ert-deftest elixir-mode-syntax-table/fontify-heredoc/1 ()
:tags '(fontification heredoc syntax-table)
(elixir-test-with-temp-buffer
"@doc \"\"\""
(should (eq (elixir-test-face-at 1) 'font-lock-builtin-face))
(should (eq (elixir-test-face-at 2) 'font-lock-builtin-face))
(should (eq (elixir-test-face-at 6) 'font-lock-string-face))))

(ert-deftest elixir-mode-syntax-table/fontify-heredoc/2 ()
:tags '(fontification heredoc syntax-table)
(elixir-test-with-temp-buffer
"@moduledoc \"\"\""
(should (eq (elixir-test-face-at 1) 'font-lock-builtin-face))
(should (eq (elixir-test-face-at 2) 'font-lock-builtin-face))
(should (eq (elixir-test-face-at 12) 'font-lock-string-face))))

(ert-deftest elixir-mode-syntax-table/fontify-heredoc/3 ()
:tags '(fontification heredoc syntax-table)
(elixir-test-with-temp-buffer
"~s\"\"\""
(should (eq (elixir-test-face-at 1) 'font-lock-builtin-face))
(should (eq (elixir-test-face-at 2) 'font-lock-builtin-face))
(should (eq (elixir-test-face-at 3) 'font-lock-string-face))))

25 changes: 25 additions & 0 deletions test/elixir-mode-indentation-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -437,3 +437,28 @@ end"
end
end
end")

(elixir-def-indentation-test indent-heredoc
(:expected-result :failed)
"
defmodule Foo do
@doc \"\"\"
this is a heredoc string

\"\"\"
def convert do
x = 15
end
end
"
"
defmodule Foo do
@doc \"\"\"
this is a heredoc string

\"\"\"
def convert do
x = 15
end
end
")