2016-06-24 15:37:01 +00:00
|
|
|
|
;;; funcs.el --- Haskell Layer funcs File for Spacemacs
|
|
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
|
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
|
2016-06-24 15:37:01 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
|
;;
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
;;
|
2021-03-24 03:31:44 +00:00
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
;;
|
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
;;
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
2016-06-24 15:37:01 +00:00
|
|
|
|
|
2019-04-16 20:35:42 +00:00
|
|
|
|
|
2018-11-04 17:57:07 +00:00
|
|
|
|
;; Completion setup functions
|
|
|
|
|
|
|
|
|
|
(defun spacemacs-haskell//setup-backend ()
|
|
|
|
|
"Conditionally setup haskell backend."
|
2021-04-04 16:46:03 +00:00
|
|
|
|
(pcase haskell-completion-backend
|
2021-03-18 04:14:53 +00:00
|
|
|
|
('lsp (spacemacs-haskell//setup-lsp))
|
|
|
|
|
('dante (spacemacs-haskell//setup-dante))))
|
2018-11-04 17:57:07 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs-haskell//setup-company ()
|
2019-04-10 07:52:10 +00:00
|
|
|
|
"Conditionally setup haskell completion backend."
|
2021-04-04 16:46:03 +00:00
|
|
|
|
(when (eq haskell-completion-backend 'dante)
|
2021-03-18 04:14:53 +00:00
|
|
|
|
(spacemacs-haskell//setup-dante-company)))
|
2018-11-04 17:57:07 +00:00
|
|
|
|
|
2019-04-16 20:35:42 +00:00
|
|
|
|
|
2019-01-22 12:51:24 +00:00
|
|
|
|
;; LSP functions
|
|
|
|
|
|
|
|
|
|
(defun spacemacs-haskell//setup-lsp ()
|
|
|
|
|
"Setup lsp backend"
|
|
|
|
|
(if (configuration-layer/layer-used-p 'lsp)
|
|
|
|
|
(progn
|
|
|
|
|
;; The functionality we require from this is not an autoload, but rather some
|
|
|
|
|
;; top-level code that registers a LSP server type. So we need to load it
|
|
|
|
|
;; directly and can't rely on it being autoloaded.
|
|
|
|
|
(require 'lsp-haskell)
|
2021-06-06 20:25:00 +00:00
|
|
|
|
(lsp-deferred))
|
2019-01-22 12:51:24 +00:00
|
|
|
|
(message "`lsp' layer is not installed, please add `lsp' layer to your dotfile.")))
|
|
|
|
|
|
2019-04-16 20:35:42 +00:00
|
|
|
|
|
2018-11-04 17:57:07 +00:00
|
|
|
|
;; Dante functions
|
|
|
|
|
|
|
|
|
|
(defun spacemacs-haskell//setup-dante ()
|
|
|
|
|
(dante-mode)
|
2019-05-12 20:22:17 +00:00
|
|
|
|
(add-to-list 'spacemacs-jump-handlers 'xref-find-definitions))
|
2018-11-04 17:57:07 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs-haskell//setup-dante-company ()
|
|
|
|
|
(spacemacs|add-company-backends
|
|
|
|
|
:backends (dante-company company-dabbrev-code company-yasnippet)
|
|
|
|
|
:modes haskell-mode))
|
2017-05-27 20:57:22 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs-haskell//dante-insert-type ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(dante-type-at :insert))
|
|
|
|
|
|
2019-09-30 04:49:44 +00:00
|
|
|
|
|
|
|
|
|
;; misc
|
|
|
|
|
|
|
|
|
|
(defun spacemacs-haskell//disable-electric-indent ()
|
|
|
|
|
"Disable electric indent mode if available"
|
|
|
|
|
;; use only internal indentation system from haskell
|
|
|
|
|
(if (fboundp 'electric-indent-local-mode)
|
|
|
|
|
(electric-indent-local-mode -1)))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs/haskell-format-imports ()
|
|
|
|
|
"Sort and align import statements from anywhere in the source file."
|
|
|
|
|
(interactive)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(haskell-navigate-imports)
|
|
|
|
|
(haskell-mode-format-imports)))
|