[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode bc93c3d 224/385: very alpha hsinspect sup
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode bc93c3d 224/385: very alpha hsinspect support |
Date: |
Tue, 5 Oct 2021 23:59:35 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit bc93c3d1282d4ff00fa04b572148a315475e9da6
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
very alpha hsinspect support
---
Cask | 1 +
README.md | 34 +++++++++++++++++-
haskell-tng-contrib-company.el | 25 ++++++++++++++
haskell-tng-contrib-smartparens.el | 1 +
haskell-tng-font-lock.el | 1 +
haskell-tng-hsinspect.el | 70 ++++++++++++++++++++++++++++++++++++++
haskell-tng-mode.el | 1 +
7 files changed, 132 insertions(+), 1 deletion(-)
diff --git a/Cask b/Cask
index f6e916e..eb2614c 100644
--- a/Cask
+++ b/Cask
@@ -27,6 +27,7 @@
(package-file "haskell-tng-mode.el")
(development
+ (depends-on "company")
(depends-on "faceup")
(depends-on "ert-runner")
;;(depends-on "undercover")
diff --git a/README.md b/README.md
index aa394c0..d0ee04b 100644
--- a/README.md
+++ b/README.md
@@ -58,13 +58,43 @@ Giving the following commands
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).
+## `hsinspect`
+
+The optional command line tool `hsinspect` provides semantic information by
using the `ghc` api.
+
+`hsinspect` must be installed separately for each version of `ghc` that you
are using.
+
+At the moment only one version of `ghc` is supported at a time (change
`ghc-8.4.4` to your current `ghc` version):
+
+```
+git clone https://gitlab.com/tseenshe/hsinspect.git
+cd hsinspect
+cabal v2-install -O2 hsinspect --overwrite-policy=always -w ghc-8.4.4
+```
+
+<!-- TODO these installation instructions don't work
https://github.com/haskell/cabal/issues/6179 -->
+<!-- ```bash -->
+<!-- for v in ghc-8.4.4 ghc-8.6.5 ; do -->
+<!-- cabal v2-install hsinspect --program-suffix=-$v -w $v -->
+<!-- done -->
+<!-- ``` -->
+
+with recommended binding
+
+```lisp
+ :bind
+ (:map haskell-tng-mode-map
+ ("C-c C-i s" . haskell-tng-fqn-at-point))
+```
+
## Contrib
-Integrations are provided for common libraries (installed separately), enable
them from `use-package` with
+Integrations are provided for common libraries and external applications
(installed separately), enable them from `use-package` with
```lisp
:config
(require 'haskell-tng-contrib)
+ (require 'haskell-tng-contrib-company)
(require 'haskell-tng-contrib-projectile)
(require 'haskell-tng-contrib-smartparens)
(require 'haskell-tng-contrib-yasnippet)
@@ -131,6 +161,8 @@ Semantic tooling will likely take the form of a standalone
cli tool that is call
- expand import list into explicit list (perhaps via `:browse` but better as
standalone tool) for symbol-at-point (assuming no shadowing).
- convert wildcard import to explicit list
- remove unused imports
+- Exports
+ - visual indicator of what has been exported (hsinspect could do this for
compilable code)
- Hoogle integration
- build local hoogle database for a project
- local cli jump-to-source of symbol-at-point / type-at-point (i.e. explicit
fully qualified name)
diff --git a/haskell-tng-contrib-company.el b/haskell-tng-contrib-company.el
new file mode 100644
index 0000000..b98c099
--- /dev/null
+++ b/haskell-tng-contrib-company.el
@@ -0,0 +1,25 @@
+;;; haskell-tng-contrib-company.el --- company mode integration -*-
lexical-binding: t -*-
+
+;; Copyright (C) 2019 Tseen She
+;; License: GPL 3 or any later version
+
+;;; Commentary:
+;;
+;; Integration with `company-mode' completions for
+;;
+;; 1. keywords
+;; 2. `hsinspect' contextual completions
+;;
+;;; Code:
+
+(require 'company)
+
+(require 'haskell-tng-hsinspect)
+
+;; TODO keywords
+;; TODO completions for imports (needs to know project wide module list)
+;; TODO completions for symbols (can this be made more contextual)
+;; TODO add-hook and a TNG specific list of default backends
+
+(provide 'haskell-tng-contrib-company)
+;;; haskell-tng-contrib-company.el ends here
diff --git a/haskell-tng-contrib-smartparens.el
b/haskell-tng-contrib-smartparens.el
index 23d4e29..a8ffc11 100644
--- a/haskell-tng-contrib-smartparens.el
+++ b/haskell-tng-contrib-smartparens.el
@@ -17,6 +17,7 @@
(sp-local-pair 'haskell-tng-mode (car pair) (cdr pair)
:post-handlers '(("| " "SPC"))))
+;; TODO use advise instead of redefining the function
;; WORKAROUND smartparens indenting all the time
(defun sp--indent-region (start end &optional column)
(unless (or
diff --git a/haskell-tng-font-lock.el b/haskell-tng-font-lock.el
index d7830d5..84f415a 100644
--- a/haskell-tng-font-lock.el
+++ b/haskell-tng-font-lock.el
@@ -124,6 +124,7 @@
(1 'haskell-tng-keyword-face)
(2 'haskell-tng-module-face)
(3 'haskell-tng-keyword-face))
+ ;; TODO combinations of as and hiding
(,(rx-to-string `(: word-start (group "as") word-end (+ space)
word-start (group ,conid) word-end))
(haskell-tng--font-lock-multiline-anchor-rewind) nil
diff --git a/haskell-tng-hsinspect.el b/haskell-tng-hsinspect.el
new file mode 100644
index 0000000..75a4c64
--- /dev/null
+++ b/haskell-tng-hsinspect.el
@@ -0,0 +1,70 @@
+;;; haskell-tng-hsinspect.el --- hsinspect integration -*- lexical-binding: t
-*-
+
+;; Copyright (C) 2019 Tseen She
+;; License: GPL 3 or any later version
+
+;;; Commentary:
+;;
+;; `hsinspect' is a companion tool to `haskell-tng' that uses the `ghc' api to
+;; extract semantic information. This file provides an integration layer and
+;; some features.
+;;
+;;; Code:
+
+(require 'haskell-tng-compile)
+
+;; TODO automatically installing hsinspect under hsinspect-ghc-X
+
+(defcustom haskell-tng-hsinspect
+ '("cabal" "v2-exec" "-v0" "--")
+ "Launch command for the `hsinspect' external tool."
+ :type 'listp
+ :group 'haskell-tng)
+
+(defun haskell-tng-fqn-at-point ()
+ "Consult the imports in scope and display the fully qualified
+name of the symbol at point in the minibuffer."
+ (interactive)
+ (if-let* ((sym (symbol-name (symbol-at-point)))
+ (found (seq-find
+ (lambda (names) (member sym names))
+ (haskell-tng--hsinspect-imports))))
+ ;; TODO multiple hits
+ (message "%s" (car (last found)))
+ (message "<not imported>")))
+
+;; TODO invalidate cache when imports section has changed
+;; TODO is there a way to tell Emacs not to render this in `C-h v'?
+;; (suggestion is to advise around describe-key)
+(defvar-local haskell-tng--hsinspect-imports nil
+ "Cache for the last `imports' call for this buffer.
+t means the process failed.")
+(defun haskell-tng--hsinspect-imports ()
+ (if haskell-tng--hsinspect-imports
+ (or (eq t haskell-tng--hsinspect-imports)
+ haskell-tng--hsinspect-imports)
+ (setq haskell-tng--hsinspect-imports t) ;; avoid races
+ (ignore-errors (kill-buffer "*hsinspect*"))
+ (let ((default-directory
+ (or
+ (haskell-tng--util-locate-dominating-file
+ haskell-tng--compile-dominating-file)
+ default-directory)))
+ (if (/= 0 (apply
+ #'call-process
+ ;; TODO launching the correct hsinspect-ghc-X version
+ ;; TODO is there a way to pipe into a string not a buffer?
+ ;; TODO async
+ (car haskell-tng-hsinspect) nil "*hsinspect*" nil
+ (append (cdr haskell-tng-hsinspect)
+ `("hsinspect" "imports" ,buffer-file-name))))
+ (message "hsinspect failed, semantic support disabled")
+ (setq haskell-tng--hsinspect-imports
+ (with-current-buffer "*hsinspect*"
+ (goto-char (point-min))
+ (re-search-forward (rx "(") nil t) ;; sometimes there is junk
from the launcher
+ (goto-char (match-beginning 0))
+ (read (current-buffer))))))))
+
+(provide 'haskell-tng-hsinspect)
+;;; haskell-tng-hsinspect.el ends here
diff --git a/haskell-tng-mode.el b/haskell-tng-mode.el
index 2c33e6c..470f2d6 100644
--- a/haskell-tng-mode.el
+++ b/haskell-tng-mode.el
@@ -20,6 +20,7 @@
(require 'haskell-tng-compile)
(require 'haskell-tng-font-lock)
+(require 'haskell-tng-hsinspect)
(require 'haskell-tng-imenu)
(require 'haskell-tng-smie)
(require 'haskell-tng-syntax)
- [nongnu] elpa/haskell-tng-mode 5892c04 232/385: small things, (continued)
- [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
- [nongnu] elpa/haskell-tng-mode b2e2c3a 293/385: stop stack from being an asshole, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ee07f6d 172/385: type indentation tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 59354b6 198/385: support hanging type alignment, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode a788ab2 209/385: more efficient layout caching, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f7e8040 213/385: = ends a type sig, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode fe9d65d 222/385: helper for yatemplates, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode bc93c3d 224/385: very alpha hsinspect support,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode 658ddb6 251/385: docs, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 73a60f5 309/385: cache `which hsinspect` per project, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 5707166 365/385: use new ghcflags-provided PATH, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b1c664b 364/385: allow hsinspect population in the background, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ce17d96 376/385: new hsinspect release, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode eb6b487 357/385: test fqn-at-point and fix a longstanding bug, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 103e758 325/385: expose some more hsinspect-0.0.8 index info, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 374835c 355/385: a test for interactive commands, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e3c6dc6 336/385: follow re-exports, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 9904e72 366/385: jump-to-definition works inside the project, ELPA Syncer, 2021/10/06