emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/haskell-tng-mode 04ebec6 204/385: third party integrations


From: ELPA Syncer
Subject: [nongnu] elpa/haskell-tng-mode 04ebec6 204/385: third party integrations
Date: Tue, 5 Oct 2021 23:59:32 -0400 (EDT)

branch: elpa/haskell-tng-mode
commit 04ebec664ff81e46fdcaae509dd00486b32858eb
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>

    third party integrations
---
 Cask                            |  4 +++-
 README.md                       | 16 ++++++++++++++--
 haskell-tng-mode.el             | 27 ++++++++++++++++++++++++++-
 haskell-tng-util.el             |  6 ++++++
 snippets/.nosearch              |  0
 snippets/haskell-tng-mode/i     |  5 +++++
 snippets/haskell-tng-mode/iq    |  5 +++++
 snippets/haskell-tng-mode/lang  |  5 +++++
 test/haskell-tng-indent-test.el |  7 +++----
 test/haskell-tng-testutils.el   |  8 +-------
 10 files changed, 68 insertions(+), 15 deletions(-)

diff --git a/Cask b/Cask
index 13a428a..68f409a 100644
--- a/Cask
+++ b/Cask
@@ -27,6 +27,8 @@
 (development
  (depends-on "faceup")
  (depends-on "ert-runner")
- (depends-on "undercover"))
+ (depends-on "undercover")
+ (depends-on "smartparens")
+ (depends-on "yasnippet"))
 
 ;;; Cask ends here
diff --git a/README.md b/README.md
index 30eb87c..cd14894 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,17 @@ Check out the source code repository and add to your load 
path:
 (require 'haskell-tng-contrib) ;; optional
 ```
 
+Integrations are provided for common libraries, enable them with
+
+```lisp
+(add-hook
+ 'haskell-tng-mode-hook
+ (lambda ()
+   (prettify-symbols-mode 1)
+   (smartparens-mode 1)
+   (yas-minor-mode 1))
+```
+
 ## Commands
 
 ### Core
@@ -69,9 +80,9 @@ This is the status of core features:
   - [ ] `imenu` population
 - Editing:
   - [x] indentation
-  - [ ] `abbrev` table
-  - [ ] `yasnippet` templates
   - [x] `prettify-symbols` emulating `UnicodeSyntax`
+  - [x] `smartparens` rules
+  - [x] `yasnippet` templates
   - [x] `stylish-haskell` support
 - Compiling:
   - [x] `haskell-tng-compile` for `cabal` batch commands
@@ -119,6 +130,7 @@ Blue sky features:
   - and [`hlint`](https://github.com/ndmitchell/hlint)
   - and for faster feedback, [`ghcid`](https://github.com/ndmitchell/ghcid)
 - [visualise values as 
types](https://twitter.com/jyothsnasrin/status/1039530556080283648)
+- are there any sensible `abbrev-mode` defaults?
 - [`djinn`](https://hackage.haskell.org/package/djinn) / 
[`justdoit`](https://hackage.haskell.org/package/ghc-justdoit) integration
 - [`pointfree`](https://hackage.haskell.org/package/pointfree) integration
 - is there a solution to thinking "right to left" vs writing "left to right"? 
(easy left token movement?)
diff --git a/haskell-tng-mode.el b/haskell-tng-mode.el
index 954350b..e2ee51f 100644
--- a/haskell-tng-mode.el
+++ b/haskell-tng-mode.el
@@ -102,7 +102,32 @@ Load `prettify-symbols-mode' in `haskell-tng-mode-hook'."
 ;;;###autoload
 (progn
   (add-to-list 'auto-mode-alist '("\\.hs\\'" . haskell-tng-mode))
-  (modify-coding-system-alist 'file "\\.hs\\'" 'utf-8))
+  (modify-coding-system-alist 'file "\\.hs\\'" 'utf-8)
+
+  ;; optional dependency
+  (require 'yasnippet nil t)
+  (when (boundp yas-minor-mode)
+    (add-hook
+     'yas-minor-mode-hook
+     (lambda ()
+       (add-to-list
+        'yas-snippet-dirs
+        (expand-file-name
+         "snippets"
+         (haskell-tng--util-this-lisp-directory)))
+       (yas-reload-all nil t))))
+
+  ;; optional dependency
+  (require 'smartparens nil t)
+  (when (fboundp 'sp-local-pair)
+    (dolist (pair '(("(" . ")")
+                    ("[" . "]")
+                    ("{" . "}")
+                    ("{-" . "-}")
+                    ("{-#" . "#-}")))
+      (sp-local-pair 'haskell-tng-mode (car pair) (cdr pair)
+                     :post-handlers '(("| " "SPC")))))
+  )
 
 (provide 'haskell-tng-mode)
 ;;; haskell-tng-mode.el ends here
diff --git a/haskell-tng-util.el b/haskell-tng-util.el
index 4155bd7..b8fad4c 100644
--- a/haskell-tng-util.el
+++ b/haskell-tng-util.el
@@ -71,5 +71,11 @@ and taking a regexp."
        (while (not (setq ,res ,test)) ,@body)
        ,res)))
 
+(defmacro haskell-tng--util-this-lisp-directory ()
+  (expand-file-name
+   (if load-file-name
+       (file-name-directory load-file-name)
+     default-directory)))
+
 (provide 'haskell-tng-util)
 ;;; haskell-tng-util.el ends here
diff --git a/snippets/.nosearch b/snippets/.nosearch
new file mode 100644
index 0000000..e69de29
diff --git a/snippets/haskell-tng-mode/i b/snippets/haskell-tng-mode/i
new file mode 100644
index 0000000..e35d89d
--- /dev/null
+++ b/snippets/haskell-tng-mode/i
@@ -0,0 +1,5 @@
+# -*- mode: snippet -*-
+# name: import
+# key: i
+# --
+import           
\ No newline at end of file
diff --git a/snippets/haskell-tng-mode/iq b/snippets/haskell-tng-mode/iq
new file mode 100644
index 0000000..eb928d5
--- /dev/null
+++ b/snippets/haskell-tng-mode/iq
@@ -0,0 +1,5 @@
+# -*- mode: snippet -*-
+# name: import qualified
+# key: iq
+# --
+import qualified 
\ No newline at end of file
diff --git a/snippets/haskell-tng-mode/lang b/snippets/haskell-tng-mode/lang
new file mode 100644
index 0000000..c34001c
--- /dev/null
+++ b/snippets/haskell-tng-mode/lang
@@ -0,0 +1,5 @@
+# -*- mode: snippet -*-
+# name: language
+# key: lang
+# --
+{-# LANGUAGE $1 #-}
\ No newline at end of file
diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el
index 6e6d913..cde166e 100644
--- a/test/haskell-tng-indent-test.el
+++ b/test/haskell-tng-indent-test.el
@@ -12,11 +12,10 @@
 (require 'haskell-tng-testutils
          "test/haskell-tng-testutils.el")
 
-;; FIXME implement more indentation rules
-;;
-;; TODO records of functions tests
-;; TODO ImplicitParams in type signatures (without parens)
+;; TODO records assigning / copy by label
+;; TODO records of functions
 ;; TODO if/then/else
+;; TODO ImplicitParams in type signatures (without parens)
 
 ;; Three indentation regression tests are possible:
 ;;
diff --git a/test/haskell-tng-testutils.el b/test/haskell-tng-testutils.el
index e9520c7..6d16a44 100644
--- a/test/haskell-tng-testutils.el
+++ b/test/haskell-tng-testutils.el
@@ -11,12 +11,6 @@
 
 (require 'faceup)
 
-(defmacro haskell-tng--testutils-this-lisp-directory ()
-  (expand-file-name
-   (if load-file-name
-       (file-name-directory load-file-name)
-     default-directory)))
-
 (defun haskell-tng--testutils-assert-file-contents
     (file mode to-string suffix)
   "For FILE, enable MODE and run TO-STRING and compare with the golden data in 
FILE.SUFFIX.
@@ -47,7 +41,7 @@ Alternatively, if MODE is a buffer object, run TO-STRING 
there instead."
 (defun testdata (file)
   (expand-file-name
    file
-   (haskell-tng--testutils-this-lisp-directory)))
+   (haskell-tng--util-this-lisp-directory)))
 
 (defun is-comment-at-point ()
   ;; this could be sped up by storing all comment regions in an alist



reply via email to

[Prev in Thread] Current Thread [Next in Thread]