[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode de48840 030/385: multiline import anchors
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode de48840 030/385: multiline import anchors |
Date: |
Tue, 5 Oct 2021 23:58:55 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit de488407754696fee891a6edac6cab173abb0fc4
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
multiline import anchors
---
README.md | 6 ++--
haskell-tng-font-lock.el | 74 +++++++++++++++++++++++++++---------------------
haskell-tng-syntax.el | 2 ++
3 files changed, 47 insertions(+), 35 deletions(-)
diff --git a/README.md b/README.md
index 36cfd4f..48cb224 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ This is an exploratory alternative to
[`haskell-mode`](https://github.com/haskel
`haskell-mode` is almost 30 years old and has accumulated more than 25,000
lines of code. It's too much to handle.
-Meanwhile, the GNU Emacs ecosystem has evolved to provide many features that
`haskell-mode` independently implemented, such as
[`projectile`](https://github.com/bbatsov/projectile),
[`comint`](https://masteringemacs.org/article/comint-writing-command-interpreter),
[`highlight-symbol`](https://melpa.org/##/highlight-symbol),
[`pretty-symbols`](https://github.com/drothlis/pretty-symbols),
[`company`](http://company-mode.github.io),
[`yasnippet`](http://joaotavora.github.io/yasnippet/), [`p [...]
+Meanwhile, the GNU Emacs ecosystem has evolved to provide many features that
`haskell-mode` independently implemented, such as
[`projectile`](https://github.com/bbatsov/projectile),
[`comint`](https://masteringemacs.org/article/comint-writing-command-interpreter),
[`highlight-symbol`](https://melpa.org/##/highlight-symbol),
[`pretty-symbols`](https://github.com/drothlis/pretty-symbols),
[`company`](http://company-mode.github.io),
[`yasnippet`](http://joaotavora.github.io/yasnippet/), [`p [...]
## Approach
@@ -41,7 +41,7 @@ This is the status of core features:
- Navigation:
- [x] performance-minded `syntax-table`
- - [ ] `font-lock` to visually distinguish types and values
+ - [x] `font-lock` to visually distinguish types and values
- [ ] `sexp` navigation (SMIE)
- [ ] `projectile` / [`fast-tags`](https://github.com/elaforge/fast-tags)
integration for `TAGS`
- [ ] hoogle CLI jump-to-source
@@ -50,7 +50,7 @@ This is the status of core features:
- [ ] indentation (SMIE)
- [ ] `abbrev` table
- [ ] `yasnippet` templates
- - [ ] `smartparens` compatibility (or something from stdlib)
+ - [ ] `smartparens` / `paredit` rules
- [ ] `LANGUAGE` management
- [ ] `import` management (via hoogle and
[`hsimport`](https://hackage.haskell.org/package/hsimport))
- Compiling:
diff --git a/haskell-tng-font-lock.el b/haskell-tng-font-lock.el
index 2024919..c110e17 100644
--- a/haskell-tng-font-lock.el
+++ b/haskell-tng-font-lock.el
@@ -68,7 +68,7 @@
(: symbol-start
"--"
(+ (not (syntax comment-end)))
- (+ (syntax comment-end))))
+ (syntax comment-end)))
"Newline or line comment.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -81,7 +81,8 @@
(let ((conid haskell-tng:rx:conid)
(qual haskell-tng:rx:qual)
(consym haskell-tng:rx:consym)
- (toplevel haskell-tng:rx:toplevel))
+ (toplevel haskell-tng:rx:toplevel)
+ (bigspace `(| space ,haskell-tng:rx:newline)))
`(;; reservedid / reservedop
(,(rx-to-string
'(|
@@ -113,28 +114,26 @@
(group (opt ,qual) (| ,conid ,consym))))
(1 'haskell-tng:type))
- ;; modules
- ;; (,(rx-to-string `(: symbol-start "module" symbol-end (+ space)
- ;; symbol-start (group (opt ,qual) ,conid)
symbol-end))
- ;; 1 'haskell-tng:module)
+ ;; TODO modules
;; imports
- ;; (,(rx-to-string '(: word-start "import" word-end)) ;; anchor matcher
- ;; (,(rx-to-string `(: point (+ space) (group word-start "qualified"
word-end)))
- ;; nil nil (1 'haskell-tng:keyword))
- ;; (,(rx-to-string `(: point
- ;; (opt (+ space) word-start "qualified" word-end)
- ;; (+ space) word-start (group (opt ,qual) ,conid)
word-end))
- ;; nil nil (1 'haskell-tng:module))
- ;; (,(rx-to-string `(: point (+? (not (any ?\()))
- ;; word-start (group (| "hiding" "as")) word-end
- ;; (opt (+ space) word-start (group ,conid)
word-end)))
- ;; nil nil (1 'haskell-tng:keyword) (2 'haskell-tng:module nil t))
- ;; (,(rx-to-string `(: symbol-start (group (| ,conid ,consym)) symbol-end
- ;; (* space) "(..)"))
- ;; nil nil (1 'haskell-tng:constructor))
- ;; (,(rx-to-string `(: symbol-start (group (| ,conid ,consym))
symbol-end))
- ;; nil nil (1 'haskell-tng:type)))
+ (haskell-tng:font:import:keyword
+ (,(rx-to-string
+ `(: line-start "import" (+ space)
+ (group (opt word-start "qualified" word-end)) (* space)
+ ;; TODO PackageImports
+ ;; TODO Safe / Trustworthy / Unsafe
+ (group symbol-start (* ,conid ".") ,conid symbol-end) (*
,bigspace)
+ (group (opt word-start "as" word-end (* space)))
+ (group (opt word-start "hiding" word-end (* space)))))
+ (haskell-tng:font:multiline:pre) nil
+ (1 'haskell-tng:keyword)
+ (2 'haskell-tng:module)
+ (3 'haskell-tng:keyword)
+ (4 'haskell-tng:keyword))
+ ;; TODO constructors vs types in import brackets
+ ;; TODO ExplicitNamespaces
+ )
;; TODO: pragmas
;; TODO: numeric / char primitives?
@@ -154,6 +153,11 @@
)))
+(defun haskell-tng:font:multiline:pre ()
+ "Multiline MATCH-ANCHORED forms must move point and return LIMIT."
+ (goto-char (match-beginning 0))
+ (match-end 0))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Here are `function' matchers for use in `font-lock-keywords' and
;; `font-lock-extend-region-functions' procedures for extending the region.
@@ -236,15 +240,15 @@ succeeds and may further restrict the FIND search limit."
haskell-tng:indent-close-previous)
(haskell-tng:font:multiline topdecl
- (rx line-start (| "data" "newtype" "class" "instance") symbol-end)
- (rx line-start (| "data" "newtype" "class" "instance") symbol-end
+ (rx line-start (| "data" "newtype" "class" "instance") word-end)
+ (rx line-start (| "data" "newtype" "class" "instance") word-end
(group (+? anything))
(| (: line-start symbol-start)
(: symbol-start (| "where" "=") symbol-end))))
(haskell-tng:font:multiline type
- (rx line-start "type" symbol-end)
- (rx line-start "type" symbol-end (+ space) (group (+ anything)))
+ (rx line-start "type" word-end)
+ (rx line-start "type" word-end (group (+ anything)))
haskell-tng:indent-close)
;; DeriveAnyClass
@@ -253,15 +257,21 @@ succeeds and may further restrict the FIND search limit."
;; TODO DerivingVia
;; TODO StandaloneDeriving
(haskell-tng:font:multiline deriving
- (rx symbol-start "deriving" symbol-end)
- (rx symbol-start "deriving" symbol-end
- (+ space) (group (opt (| "anyclass" "stock" "newtype")))
+ (rx word-start "deriving" word-end)
+ (rx word-start "deriving" word-end
+ (+ space) (group (opt (| "anyclass" "stock" "newtype") word-end))
(* space) ?\( (group (* anything)) ?\))
haskell-tng:indent-close)
-;; TODO modules
-;; TODO imports
-;; TODO ExplicitNamespaces
+(haskell-tng:font:multiline import
+ (rx line-start "import" word-end)
+ (rx line-start "import" word-end (group (+ anything)))
+ haskell-tng:indent-close)
+
+(haskell-tng:font:multiline module
+ (rx line-start "module" word-end)
+ (rx line-start "module" word-end (group (+ anything)))
+ haskell-tng:indent-close)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Helpers
diff --git a/haskell-tng-syntax.el b/haskell-tng-syntax.el
index 48b073f..92cd0fe 100644
--- a/haskell-tng-syntax.el
+++ b/haskell-tng-syntax.el
@@ -90,5 +90,7 @@
(put-text-property (- (point) 1) (point)
'syntax-table '(9 . ?\\)))))
+;; TODO newlines should be whitespace if there is no comment to close
+
(provide 'haskell-tng-syntax)
;;; haskell-tng-syntax.el ends here
- [nongnu] elpa/haskell-tng-mode 489e4c9 124/385: document explicit export fontification bug, (continued)
- [nongnu] elpa/haskell-tng-mode 489e4c9 124/385: document explicit export fontification bug, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 91a1d08 136/385: creating small scenarios for indentation specs, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ec39a64 133/385: improvements to indentation alts and compilation info, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f67557b 142/385: fix a layout corner case, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 20f4091 152/385: support dollars in indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 0d5e020 151/385: support LambdaCase, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 08a3946 163/385: records indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3449847 162/385: no need to special-case dollar, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 8b5a4d4 177/385: improve indentation tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode cb801b4 015/385: moar multiline type search, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode de48840 030/385: multiline import anchors,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode 5c50be0 044/385: remove redundant TODOs, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 174c63b 046/385: laying the foundations for SMIE, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 97ce717 058/385: improve the testing, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 2a2afee 064/385: cache invalidation and tests for layout invalidation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3ca869f 067/385: code reorganisation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 0ffb885 071/385: a thought, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 79aeb82 076/385: most of the grammar, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 7eaef51 078/385: optimisation in the sexp test, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode cb0f3d2 082/385: starting indentation rules, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode cfbdae1 084/385: simplify the lexer assertion language, ELPA Syncer, 2021/10/06