Add support for Haskell

This commit is contained in:
Sameer Rahmani 2024-05-20 19:12:39 +01:00
parent 701d2ec9d8
commit 25bd1636c9
Signed by: lxsameer
GPG Key ID: 8741FACBF412FFA5
4 changed files with 127 additions and 5 deletions

View File

@ -34,6 +34,7 @@ let
./c-family
./python
./clojure
./haskell
./wm
./verilog
./workspace

View File

@ -0,0 +1,60 @@
# Fg42 - Emacs Editor for advance users
#
# Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# 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, version 2.
#
# 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/>.
# This is the home manager module that exposes FG42. It differs
# from FG42 modules that are structurally the same but used in
# different context
# A list of default FG42 modules to build FG42 with.
{ lib, config, pkgs, makeFG42Drv, ... }:
with lib;
let
cfg = config.fg42.haskell;
deps =
(with pkgs.emacsPackages; [
haskell-mode
]);
drv = makeFG42Drv {
pname = "haskell";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
in
{
imports = [
../language-server
];
options.fg42.haskell.enable = mkAndEnableOption "haskell";
config = mkIf cfg.enable {
fg42.elispPackages = [ drv ] ++ deps;
fg42.paths = (with pkgs;[
haskell-language-server
ghc
]);
fg42.requires = [ drv.pname ];
meta = {
maintainers = [ maintainers.lxsameer ];
doc = ./README.md;
};
};
}

View File

@ -0,0 +1,59 @@
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; URL: https://devheroes.codes/FG42/FG42
;; Version: 4.0.0
;;
;; 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/>.
;;
;;; Commentary:
;;; Code:
(eval-when-compile
(require 'fpkg))
(cl-defmethod fg42/setup-lang-server-for ((mode (eql haskell-mode)))
"Setup the language server for MODE `haskell-mode'."
(require 'eglot)
;; This is just a referece for the future
;; (setq-default eglot-workspace-configuration
;; '((haskell
;; (plugin
;; (stan
;; (globalOn . :json-false))))))
(eglot-ensure))
(use! haskell-mode
"Haskell support for FG42."
:mode ("\\.hs\\'" "\\.lhs\\'" "\\.hsc\\'" "\\.cpphs\\'" "\\.c2hs\\'")
:custom
(eglot-autoshutdown t) ;; shutdown language server after closing last file
(eglot-confirm-server-initiated-edits nil) ;; allow edits without confirmation
:hook
(haskell-mode . fg42/ensure-lang-server)
(haskell-mode . fg42/setup-completion)
(haskell-mode . flyspell-prog-mode))
(use! haskell-cabal-mode
"Cabal integration."
:mode ("\\.cabal\\'"))
(provide 'fg42/haskell)
;;; haskell.el ends here

View File

@ -213,18 +213,20 @@ For more info on ~org-mode~ check out `https://orgmode.org/'"
:bind ("C-<f6>" . org-roam-capture)
:hook (server-mode . (lambda () (require 'org-roam-protocol)))
:config
(let ((roam-path (path-join (fg42/org-home) "notes")))
(let ((roam-path (fg42/org-home)))
(make-directory roam-path t)
(setq-default
org-roam-directory (file-truename roam-path)
org-roam-db-update-on-save t
org-roam-completion-everywhere t
org-roam-capture-templates
'(("f" "Feeliting Note" entry
:target (file+heading (path-join roam-path "inbox.org") "Fleeting Notes")
"* TODO %^{Note title}\nContext: %a\n%?" :empty-lines-before 1)
'(("n" "Note" plain "%?"
:if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${Title}\n")
:unnarrowed t
:empty-lines-before 1)
("r" "Reference Note" entry
:target (file+heading (path-join roam-path "inbox.org") "Litrature Notes")
:target (file+heading (path-join roam-path "refs" "${citekey}.org") "Litrature Notes")
"* TODO %^{Note title}\nREF: %(org-cite-insert)\n%?\n%?")))
;; Since we control Emacs itself, we can be sure
;; that it is built with SQLite support