Add support for Nix lang

This commit is contained in:
Sameer Rahmani 2024-04-18 12:45:28 +01:00
parent 78a89763ba
commit 09a545edc1
Signed by: lxsameer
GPG Key ID: 8741FACBF412FFA5
10 changed files with 371 additions and 391 deletions

View File

@ -66,7 +66,7 @@ This function is meant to be used with hooks."
;; to company mode, then we can setup them here rather than walking ;; to company mode, then we can setup them here rather than walking
;; around fixing downstream modules. ;; around fixing downstream modules.
(interactive) (interactive)
(company-model t)) (company-mode t))
(provide 'fg42/autocomplete) (provide 'fg42/autocomplete)

View File

@ -29,6 +29,8 @@ let
./graphics ./graphics
./noether ./noether
./autocomplete ./autocomplete
./language-server
./nix
]; ];
pkgsModule = { config, ... }: { pkgsModule = { config, ... }: {

View File

@ -54,146 +54,151 @@
(use! origami (use! origami
"A text folding minor mode for Emacs." "A text folding minor mode for Emacs."
:bind :bind
(("C-c TAB" . origami-toggle-node)) (("C-c TAB" . origami-toggle-node))
:config :config
(global-origami-mode t)) (global-origami-mode t))
(use! which-key (use! which-key
"which-key is a minor mode for Emacs that displays the key bindings following "which-key is a minor mode for Emacs that displays the key bindings following
your currently entered incomplete command (a prefix) in a popup. For example, your currently entered incomplete command (a prefix) in a popup. For example,
after enabling the minor mode if you enter ~C-x~ and wait for the default of after enabling the minor mode if you enter ~C-x~ and wait for the default of
1 second the minibuffer will expand with all of the available key bindings 1 second the minibuffer will expand with all of the available key bindings
that follow ~C-x~ (or as many as space allows given your settings). that follow ~C-x~ (or as many as space allows given your settings).
This includes prefixes like ~C-x 8~ which are shown in a different face." This includes prefixes like ~C-x 8~ which are shown in a different face."
:config :config
(which-key-setup-side-window-bottom) (which-key-setup-side-window-bottom)
(which-key-mode)) (which-key-mode))
(use! projectile (use! projectile
"Projectile is a project interaction library for Emacs. Its goal is to provide "Projectile is a project interaction library for Emacs. Its goal is to provide
a nice set of features operating on a project level without introducing a nice set of features operating on a project level without introducing
external dependencies." external dependencies."
:hook (emacs-startup . projectile-mode) :hook (emacs-startup . projectile-mode)
:config :config
;; We don't want the auto discovery on startup ;; We don't want the auto discovery on startup
(setq projectile-auto-discover nil) (setq projectile-auto-discover nil)
(setq projectile-enable-caching t) (setq projectile-enable-caching t)
:bind (:map projectile-mode-map :bind (:map projectile-mode-map
("s-p" . projectile-command-map) ("s-p" . projectile-command-map)
("C-c p" . projectile-command-map))) ("C-c p" . projectile-command-map)))
(use! projectile-ripgrep (use! projectile-ripgrep
"Use ripgrep with projectile" "Use ripgrep with projectile"
:after projectile) :after projectile)
(use! pkg-info (use! pkg-info
"`pkg-info' integration.") "`pkg-info' integration.")
(use! expand-region (use! expand-region
"Expand region increases the selected region by semantic units. "Expand region increases the selected region by semantic units.
Just keep pressing the key until it selects what you want." Just keep pressing the key until it selects what you want."
:bind ("C-=" . er/expand-region)) :bind ("C-=" . er/expand-region))
(use! helpful (use! helpful
"Helpful is an alternative to the built-in Emacs help that provides much more "Helpful is an alternative to the built-in Emacs help that provides much more
contextual information." contextual information."
:bind :bind
(("C-h f" . helpful-callable) (("C-h f" . helpful-callable)
("C-h v" . helpful-variable) ("C-h v" . helpful-variable)
("C-h k" . helpful-key) ("C-h k" . helpful-key)
("C-h x" . helpful-command) ("C-h x" . helpful-command)
("C-c C-d" . helpful-at-point))) ("C-c C-d" . helpful-at-point)))
(use! envrc (use! envrc
"Activate direnv whenever encounter a `.envrc' file" "Activate direnv whenever encounter a `.envrc' file"
:config :config
(envrc-global-mode)) (envrc-global-mode))
(use! pinentry (use! pinentry
"Pinentry cube with setup the =pinentry= program to be used within FG42." "Pinentry cube with setup the =pinentry= program to be used within FG42."
:commands pinentry-start :commands pinentry-start
:init :init
(setq epa-pinentry-mode 'loopback)) (setq epa-pinentry-mode 'loopback))
(use! imenu-list (use! imenu-list
"his Emacs minor-mode creates an automatically updated buffer "his Emacs minor-mode creates an automatically updated buffer
called `Ilist' that is populated with the current buffer's imenu entries. called `Ilist' that is populated with the current buffer's imenu entries.
The `Ilist' buffer is typically shown as a sidebar (Emacs vertically splits the window)." The `Ilist' buffer is typically shown as a sidebar (Emacs vertically splits the window)."
:bind (("C-'" . imenu-list-smart-toggle))) :bind (("C-'" . imenu-list-smart-toggle)))
(use! discover (use! discover
"Adds support for the discover.el `https://github.com/mickeynp/discover.el'.") "Adds support for the discover.el `https://github.com/mickeynp/discover.el'.")
(use! exec-path-from-shell (use! exec-path-from-shell
"This package fixes the =exec-path-from-shell= issue on MacOS." "This package fixes the =exec-path-from-shell= issue on MacOS."
:config :config
(when (memq window-system '(mac ns x)) (when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))) (exec-path-from-shell-initialize)))
(use! hl-line (use! hl-line
"Highlights the current line." "Highlights the current line."
:hook (emacs-startup . global-hl-line-mode)) :hook (emacs-startup . global-hl-line-mode))
(use! avy (use! avy
"This cube controls the different aspect of buffer navigation" "This cube controls the different aspect of buffer navigation"
:bind ("M-1" . avy-goto-word-1)) :bind ("M-1" . avy-goto-word-1))
(use! ace-window (use! ace-window
"This cube controls the different aspect of buffer navigation" "This cube controls the different aspect of buffer navigation"
:bind ("C-<tab>" . ace-window)) :bind ("C-<tab>" . ace-window))
(when-not-wm (when-not-wm
(use! flyspell
"Spell checking on the fly"
:commands (flyspell-mode flyspell-prog-mode)
:init
(setq-default ispell-program-name "aspell")
(setq-default ispell-extra-args '("--sug-mode=ultra"
"--lang=en_US"
"--camel-case")))
(use! flyspell (use! savehist
"Spell checking on the fly" "Persist history over Emacs restarts. Vertico sorts by history position."
:commands (flyspell-mode flyspell-prog-mode) :init
:init (savehist-mode))
(setq-default ispell-program-name "aspell")
(setq-default ispell-extra-args '("--sug-mode=ultra"
"--lang=en_US"
"--camel-case")))
(use! savehist (use! display-line-numbers
"Persist history over Emacs restarts. Vertico sorts by history position." "The builtin replacement of linum. It's is pretty fast."
:init :config
(savehist-mode)) (global-display-line-numbers-mode 1)))
(use! display-line-numbers
"The builtin replacement of linum. It's is pretty fast."
:config
(global-display-line-numbers-mode 1)))
(use! yasnippet (use! yasnippet
"A Snippet is a template system for Emacs. " "A Snippet is a template system for Emacs. "
:config :config
(let* ((snippet-home (let* ((snippet-home
(path-join (path-join
(file-name-directory (file-name-directory
(locate-library "yasnippet-snippets")) "snippets")) (locate-library "yasnippet-snippets")) "snippets"))
(local-snippet (path-join (file-name-directory (local-snippet (path-join (file-name-directory
(locate-library "fg42")) "../snippets")) (locate-library "fg42")) "../snippets"))
(user-snippets (path-join fg42/config-dir "snippets"))) (user-snippets (path-join fg42/config-dir "snippets")))
(setq yas-snippet-dirs `(,user-snippets ,local-snippet ,snippet-home)) (setq yas-snippet-dirs `(,user-snippets ,local-snippet ,snippet-home))
(yas-global-mode 1))) (yas-global-mode 1)))
(use! yasnippet-snippets (use! yasnippet-snippets
"Yasnippet's snippets." "Yasnippet's snippets."
:after yasnippet) :after yasnippet)
(use! flycheck (use! flycheck
"Flycheck is a modern on-the-fly syntax checking extension for GNU Emacs." "Flycheck is a modern on-the-fly syntax checking extension for GNU Emacs."
:config (global-flycheck-mode)) :config (global-flycheck-mode))
(use! rainbow-delimiters-mode
"It is a rainbow parentheses like mode which highlights delimiters such as
parentheses, brackets or braces according to their depth."
;; Enable rainbow-delimiters for programming
:hook (prog-mode-hook . rainbow-delimiters-mode))
(defun fg42/setup-editor () (defun fg42/setup-editor ()
@ -244,11 +249,11 @@ contextual information."
(defalias 'yes-or-no-p 'y-or-n-p) (defalias 'yes-or-no-p 'y-or-n-p)
;; It only applies to toolkit=no ;; It only applies to toolkit=no
(set-mouse-color (get-base16-color-or :base07 "#eeeeec")) (set-mouse-color (get-base16-color-or :base07 "#eeeeec"))
;; Switch from `dabbrev-expand' to `hippie-expand' ;; Switch from `dabbrev-expand' to `hippie-expand'
(global-set-key [remap dabbrev-expand] 'hippie-expand) (global-set-key [remap dabbrev-expand] 'hippie-expand)
@ -256,20 +261,17 @@ contextual information."
(show-paren-mode t) (show-paren-mode t)
(electric-pair-mode 1) (electric-pair-mode 1)
;; Rectangular select ;; Rectangular select
(cua-selection-mode t) (cua-selection-mode t)
;; Yank the region on type ;; Yank the region on type
(delete-selection-mode 1) (delete-selection-mode 1)
;; Deletel extra trailing white spaces on save ;; Deletel extra trailing white spaces on save
(add-hook 'before-save-hook 'delete-trailing-whitespace) (add-hook 'before-save-hook 'delete-trailing-whitespace)
;; Enable rainbow-delimiters for programming
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
;; With this section we will have two emacs server running ;; With this section we will have two emacs server running
;; this way we can interact with the wm via emacsclient as well ;; this way we can interact with the wm via emacsclient as well
(when (not (server-running-p)) (when (not (server-running-p))

View File

@ -1,61 +0,0 @@
;;; 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))
(use! diff-hl
"This package highlights changes to the current buffer in respect to the
VC status of the file. For example if you're using `git' in your project
and you've made some changes to the current buffer that are not commited
yet it will highlihgt them for you.
For more info check out `https://github.com/dgutov/diff-hl'."
:commands global-diff-hl-mode
:config
(add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh)
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh))
(use! magit
"Git magic in FG42. For more info checkout `magit's documentation."
:bind (("C-x g" . magit-status)
("C-c b" . magit-blame)
("C-c l" . magit-log))
:config
(when (featurep 'diff-hl)
(add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh)
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)))
(use! forge
"Forge allows you to work with Git forges, such as Github and Gitlab,
from the comfort of Magit and the rest of Emacs.
For more info: `https://magit.vc/manual/forge/'"
:after magit)
(provide 'fg42/git)
;;; git.el ends here

View File

@ -1,216 +0,0 @@
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
;;
;; 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)
(require 'fg42/config))
(use! vertico
"Vertico provides a performant and minimalistic vertical completion UI
based on the default completion system. The focus of Vertico is to provide
a UI which behaves correctly under all circumstances."
:config
(require 'vertico-multiform)
(require 'vertico-flat)
(require 'vertico-grid)
(require 'vertico-buffer)
(require 'vertico-indexed)
(require 'vertico-quick)
(require 'vertico-repeat)
(vertico-mode)
(vertico-multiform-mode)
;; Configure the display per command.
;; Use a buffer with indices for imenu
(setq vertico-multiform-commands
'((imenu buffer indexed)))
;; Configure the display per completion category.
;; Use the grid display for files and a buffer
;; for the consult-grep commands.
(setq vertico-multiform-categories
'((file grid)))
(setq vertico-count 10)
(setq vertico-cycle t)
(when-wm
(setq vertico-multiform-commands
'((t flat)))
(setq vertico-multiform-categories
'((file flat)))))
(use! orderless
"This package provides an orderless completion style that divides the
pattern into space-separated components, and matches candidates that
match all of the components in any order."
:init
(setq completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides '((file (styles partial-completion)))))
(use! marginalia
"Adds useful info to minibuffers completions."
:commands marginalia-mode
:hook (emacs-startup . marginalia-mode))
(when-not-wm
(use! ctrlf
"Single buffer text search."
:config
(ctrlf-mode +1)))
(use! consult
"Consult provides search and navigation commands based on the Emacs completion
function completing-read. "
;; C-c bindings in `mode-specific-map'
:bind (("C-c M-x" . consult-mode-command)
("C-c h" . consult-history)
("C-c k" . consult-kmacro)
("C-c m" . consult-man)
("C-c i" . consult-info)
([remap Info-search] . consult-info)
;; C-x bindings in `ctl-x-map'
("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command
("C-x b" . consult-buffer) ;; orig. switch-to-buffer
("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
("C-x t b" . consult-buffer-other-tab) ;; orig. switch-to-buffer-other-tab
("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
;; Custom M-# bindings for fast register access
("M-#" . consult-register-load)
("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
("C-M-#" . consult-register)
;; Other custom bindings
("M-y" . consult-yank-pop) ;; orig. yank-pop
;; M-g bindings in `goto-map'
("M-g f" . consult-flymake) ;; Alternative: consult-flycheck
("M-g g" . consult-goto-line)
("M-g M-g" . consult-goto-line)
("M-g o" . consult-outline) ;; Alternative: consult-org-heading
("M-g m" . consult-mark)
("M-g k" . consult-global-mark)
;; M-s bindings in `search-map'
("M-s d" . consult-fd)
("M-s c" . consult-locate)
("M-s g" . consult-grep)
("M-s G" . consult-git-grep)
("M-s r" . consult-ripgrep)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
("M-s k" . consult-keep-lines)
("M-s u" . consult-focus-lines)
;; Isearch integration
("M-s e" . consult-isearch-history)
:map isearch-mode-map
("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s l" . consult-line) ;; needed by consult-line to detect isearch
("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch
;; Minibuffer history
:map minibuffer-local-map
("M-s" . consult-history) ;; orig. next-matching-history-element
("M-r" . consult-history)) ;; orig. previous-matching-history-element
;; Enable automatic preview at point in the *Completions* buffer. This is
;; relevant when you use the default completion UI.
:hook (completion-list-mode . consult-preview-at-point-mode)
:init
;; Configure the register formatting. This improves the register
;; preview for `consult-register', `consult-register-load',
;; `consult-register-store' and the Emacs built-ins.
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format)
;; Tweak the register preview window.
;; This adds thin lines, sorting and hides the mode line of the window.
(advice-add #'register-preview :override #'consult-register-window)
:config
(when-wm
(consult-customize
;; Set preview for `consult-buffer' to key `M-.'
consult-buffer :preview-key nil))
;; For some reason `consult's autoloads do not work
(require 'consult-xref)
;; Use Consult to select xref locations with preview
(setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)
;; Configure preview. The default value
;; is 'any, such that any key triggers the preview.
;; (setq consult-preview-key 'any)
;; (setq consult-preview-key "M-.")
;; (setq consult-preview-key '("S-<down>" "S-<up>"))
;; For some commands and buffer sources it is useful to configure the
;; :preview-key on a per-command basis using the `consult-customize' macro.
(consult-customize
consult-theme :preview-key '(:debounce 0.2 any)
consult-ripgrep consult-git-grep consult-grep
consult-bookmark consult-recent-file consult-xref
consult--source-bookmark consult--source-file-register
consult--source-recent-file consult--source-project-recent-file
;; :preview-key "M-."
:preview-key '(:debounce 0.4 any))
;; Configure the narrowing key.
;; Both < and C-+ work reasonably well.
(setq consult-narrow-key "<") ;; "C-+"
(autoload 'projectile-project-root "projectile")
(setq consult-project-function (lambda (_) (projectile-project-root)))
;; Optionally make narrowing help available in the minibuffer.
;; You may want to use `embark-prefix-help-command' or which-key instead.
;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
)
;; For some reason `consult's autoloads do not work
(use! consult-imenu
"Setup the `consult-imenu' stuff."
:after consult
:bind (("M-i" . consult-imenu)
("M-I" . consult-imenu-multi)))
(use! consult-compile
"Setup the `consult-compile' stuff."
:after consult
:bind (("M-g e" . consult-compile-error)))
;; (use! nerd-icons-completion
;; "Nerd icons in marginalia"
;; :after marginalia
;; :config
;; (nerd-icons-completion-mode)
;; (add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup))
(provide 'fg42/minibuffer)
;;; minibuffer.el ends here

View File

@ -0,0 +1,63 @@
# 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.language-server;
deps =
(with pkgs.emacsPackages; [
eglot
# For eldoc rendering of markdown
markdown-mode
eldoc-box
]);
drv = makeFG42Drv {
pname = "language-server";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
in
{
options.fg42.language-server.enable = mkAndEnableOption "language-server";
options.fg42.language-server.backends = mkOption {
type = types.attrsOf types.anything;
default = { };
description = ''
A map from major modes to either :lsp or :eglot.
'';
};
config = mkIf cfg.enable {
fg42.elispPackages = [ drv ] ++ deps;
fg42.requires = [ drv.pname ];
fg42.vars = [
(defVar "language-server" cfg.enable "Is language server feature enabled.")
];
};
}

View File

@ -0,0 +1,72 @@
;;; 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)
(require 'fg42/config))
;; Language Servers and friends
(use! eglot
"Eglot is a minimalistic yet powerful LSP replacement
shipped with Emacs."
:commands eglot-ensure)
(use! eldoc-box
"View eldoc stuff in a frame."
:commands eldoc-box-hover-mode)
(use! markdown-mode
"Renders markdown in Emacs.")
;;;###autoload
(defun fg42/ensure-lang-server ()
"Setup the appropriate language server for the current buffer.
This function is supposed to be run using a hook.
For example:
(add-hook 'foo-mode-hook #'fg42/enruse-lang-server)
or via `use!' `:hook'."
(interactive)
;; TODO: Configure LSP here as an alternative here by looking at
;; the configs in `fg42/config'
(add-hook 'eglot-managed-mode-hook #'eldoc-box-hover-mode t)
(eglot-ensure))
;;;###autoload
(defun fg42/lang-server-format ()
"Format the current buffer using the current language server.
This function is supposed to be run as a hook handler."
(interactive)
(cond
((and (boundp 'eglot-managed-p) (eglot-managed-p))
(eglot-format-buffer))))
(provide 'fg42/language-server)
;;; language-server.el ends here

View File

@ -0,0 +1,59 @@
# 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.nix;
deps =
(with pkgs.emacsPackages; [
nix-mode
rainbow-delimiters
]);
drv = makeFG42Drv {
pname = "nix";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
in
{
imports = [
../language-server
];
options.fg42.nix.enable = mkAndEnableOption "nix";
config = mkIf cfg.enable {
fg42.elispPackages = [ drv ] ++ deps;
fg42.paths = (with pkgs;[
nix
nixpkgs-fmt
# LSP for Nix
nil
]);
fg42.requires = [ "${drv.pname}-support" ];
};
}

View File

@ -0,0 +1,64 @@
;;; 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)
(require 'fg42/config))
(use! nix-mode
"Nix language support for Emacs."
:mode ("\\.nix\\'" "\\.nix.in\\'")
:hook
(nix-mode . fg42/ensure-lang-server)
(nix-mode . fg42/autocomplete)
(nix-mode . flyspell-prog-mode)
:config
(with-eval-after-load 'eglot
;; Force nil to use nixpkgs-fmt for formatting
(let ((nil-lsp '(nix-mode . ("nil"
:initializationOptions
(:formatting (:command ["nixpkgs-fmt"]))))))
(add-to-list 'eglot-server-programs nil-lsp))))
(use! nix-drv-mode
"Highlight the drv files."
:ensure nix-mode
:mode "\\.drv\\'")
(use! nix-shell
"Basic integration with Nix shells"
:ensure nix-mode
:commands (nix-shell-unpack nix-shell-configure nix-shell-build))
(use! nix-repl
"Basic integration with Nix repl"
:ensure nix-mode
:commands (nix-repl))
(provide 'fg42/nix-support)
;;; nix-support.el ends here

View File

@ -118,11 +118,6 @@
(or (getenv "FG42_CONFIG_FILE") (or (getenv "FG42_CONFIG_FILE")
(path-join fg42/config-dir "fg42.el"))) (path-join fg42/config-dir "fg42.el")))
;; Change the eln file cache to leave Emacs alone.
(startup-redirect-eln-cache
(or (getenv "FG42_ELN_DIR")
(path-join fg42/cache-dir "fg42.el")))
;; Load the customization file. In FG42 it is different than ;; Load the customization file. In FG42 it is different than
;; the default `user-init-file' ;; the default `user-init-file'
(if (file-exists-p custom-file) (if (file-exists-p custom-file)