[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode b7cb5b9 214/385: starting to create imenu
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode b7cb5b9 214/385: starting to create imenu |
Date: |
Tue, 5 Oct 2021 23:59:34 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit b7cb5b91a57aa6c9d4215a7379edadb06c2df638
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
starting to create imenu
---
README.md | 4 +++-
haskell-tng-imenu.el | 22 ++++++++++++++++++++++
haskell-tng-mode.el | 9 +++++++--
test/haskell-tng-imenu-test.el | 29 +++++++++++++++++++++++++++++
test/src/layout.hs.imenu | 1 +
5 files changed, 62 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index b1fa039..6de2218 100644
--- a/README.md
+++ b/README.md
@@ -56,6 +56,8 @@ Giving the following commands
- `C-- C-c c` clean project
- `C-c e` jump to error
+Built-in navigation commands such as `forward-symbol`, `forward-sexp` and
`imenu` work as expected (although
[`popup-imenu`](https://github.com/ancane/popup-imenu) is recommended).
+
## Contrib
Integrations are provided for common libraries (installed separately), enable
them from `use-package` with
@@ -103,7 +105,7 @@ This is the status of core features:
- [x] performance-minded `syntax-table`
- [x] `font-lock` to visually distinguish types and values
- [x] `sexp` navigation
- - [ ] `imenu` population
+ - [ ] `imenu` population (IN PROGRESS)
- Editing:
- [x] indentation
- [x] `prettify-symbols` to emulate `UnicodeSyntax`
diff --git a/haskell-tng-imenu.el b/haskell-tng-imenu.el
new file mode 100644
index 0000000..4ab1a56
--- /dev/null
+++ b/haskell-tng-imenu.el
@@ -0,0 +1,22 @@
+;;; haskell-tng-imenu.el --- imenu support -*- lexical-binding: t -*-
+
+;; Copyright (C) 2019 Tseen She
+;; License: GPL 3 or any later version
+
+;;; Commentary:
+;;
+;; Creates a summary of the current file for navigation purposes.
+;;
+;;; Code:
+
+(defun haskell-tng--imenu-create ()
+ "Creates a `imenu--index-alist' for the current buffer."
+ ;; Simple elements in the alist look like (INDEX-NAME . POSITION).
+ ;; A nested sub-alist element looks like (INDEX-NAME . SUB-ALIST).
+
+ ;; FIXME implement imenu
+ '(("*Rescan*" . -99))
+ )
+
+(provide 'haskell-tng-imenu)
+;;; haskell-tng-imenu.el ends here
diff --git a/haskell-tng-mode.el b/haskell-tng-mode.el
index eb3ec62..2c33e6c 100644
--- a/haskell-tng-mode.el
+++ b/haskell-tng-mode.el
@@ -15,12 +15,14 @@
;;; Code:
(require 'dabbrev)
+(require 'imenu)
(require 'rx)
-(require 'haskell-tng-syntax)
+(require 'haskell-tng-compile)
(require 'haskell-tng-font-lock)
+(require 'haskell-tng-imenu)
(require 'haskell-tng-smie)
-(require 'haskell-tng-compile)
+(require 'haskell-tng-syntax)
(defgroup haskell-tng ()
"Haskell support: The Next Generation."
@@ -72,6 +74,9 @@ Load `prettify-symbols-mode' in `haskell-tng-mode-hook'."
font-lock-multiline t
font-lock-extend-region-functions
haskell-tng--font-lock-extend-region-functions
+ imenu-auto-rescan t
+ imenu-create-index-function #'haskell-tng--imenu-create
+
prettify-symbols-alist haskell-tng-prettify-symbols)
;; whitespace is meaningful, disable electric indentation. Note that
diff --git a/test/haskell-tng-imenu-test.el b/test/haskell-tng-imenu-test.el
new file mode 100644
index 0000000..7a54cd0
--- /dev/null
+++ b/test/haskell-tng-imenu-test.el
@@ -0,0 +1,29 @@
+;;; haskell-tng-imenu-test.el --- Tests for imenu generation -*-
lexical-binding: t -*-
+
+;; Copyright (C) 2019 Tseen She
+;; License: GPL 3 or any later version
+
+(require 'ert)
+
+(require 'haskell-tng-mode)
+
+(require 'haskell-tng-testutils
+ "test/haskell-tng-testutils.el")
+
+(ert-deftest haskell-tng-lexer-file-tests:layout ()
+ (should (have-expected-imenu (testdata "src/layout.hs"))))
+
+(defun have-expected-imenu (file)
+ (haskell-tng--testutils-assert-file-contents
+ file
+ #'haskell-tng-mode
+ (lambda ()
+ (imenu "*Rescan*")
+ (let ((entries imenu--index-alist))
+ (with-temp-buffer
+ (pp entries (current-buffer))
+ (buffer-string))))
+ "imenu"))
+
+(provide 'haskell-tng-imenu-test)
+;;; haskell-tng-imenu-test.el ends here
diff --git a/test/src/layout.hs.imenu b/test/src/layout.hs.imenu
new file mode 100644
index 0000000..b6b2fda
--- /dev/null
+++ b/test/src/layout.hs.imenu
@@ -0,0 +1 @@
+(("*Rescan*" . -99))
- [nongnu] elpa/haskell-tng-mode f429326 327/385: thots, (continued)
- [nongnu] elpa/haskell-tng-mode f429326 327/385: thots, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 8bb3c34 363/385: the in-memory cache doesn't have to cache nil, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f5977b6 339/385: bugfix for source downloading, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 9359c7b 349/385: cl-loop, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f5d76fc 348/385: tidy docs, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3b37524 360/385: bugfix for qualified imports when the cache was bad, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode fe2b164 372/385: fix the build, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 63225d5 374/385: use .ghc.path to find hsinspect, build tool agnostic, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3d1122b 116/385: notes on regexps, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode c3793b2 176/385: canonical until macro, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b7cb5b9 214/385: starting to create imenu,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode 5306ae2 217/385: fix type faces with constraints, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 5f81d6b 219/385: bump python version, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 8f4d7fc 225/385: advice around smartparens workaround, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 4cbf702 205/385: move third party deps to -contrib, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3ff278e 227/385: ability to not continue comments, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode dbcef71 235/385: workaround the env file situation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 5892c04 232/385: small things, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 44dc467 248/385: notes on motivation, contributing and collaboration, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6f2b5ee 266/385: font lock CPP, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode fdbd0a2 239/385: updates for hsinspect, ELPA Syncer, 2021/10/06