diff --git a/flake.nix b/flake.nix index 20fee02..7ae93d3 100644 --- a/flake.nix +++ b/flake.nix @@ -36,13 +36,14 @@ runtimeInputs = [ pkgs.xorg.xorgserver ]; text = '' - ${pkgs.xorg.xorgserver.out}/bin/Xephyr -br -ac -noreset -screen 800x600 :1 + ${pkgs.xorg.xorgserver.out}/bin/Xephyr -br -ac -noreset -screen 800x600 :1 ''; }; noether = inputs.noether.outputs.packages.${system}.default; factory = params: pkgs.callPackage ./nix/factory.nix ({ inherit noether; } // params); - default = (factory {}); - in { + default = (factory { }); + in + { packages = { default = default.fg42; } // (pkgs.lib.optionalAttrs (system == "x86_64-linux") { diff --git a/lisp/fg42/editor.el b/lisp/fg42/editor.el index 8c31207..e946644 100644 --- a/lisp/fg42/editor.el +++ b/lisp/fg42/editor.el @@ -26,6 +26,7 @@ ;; Language support (require 'fg42/autocomplete) (require 'fg42/langs/langs) + (require 'fg42/eglot) (require 'fg42/langs/cpp) (require 'fg42/langs/verilog) (require 'fg42/langs/python) @@ -197,12 +198,6 @@ contextual information." "Yasnippet's snippets." :after yasnippet) - ;; Language Servers and friends - (use! eglot - "Eglot is a minimalistic yet powerful LSP replacement -shipped with Emacs." - :commands eglot - :autoload eglot-ensure) (use! flycheck "Flycheck is a modern on-the-fly syntax checking extension for GNU Emacs." diff --git a/lisp/fg42/eglot.el b/lisp/fg42/eglot.el new file mode 100644 index 0000000..b91977f --- /dev/null +++ b/lisp/fg42/eglot.el @@ -0,0 +1,39 @@ +;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors +;; +;; Author: Sameer Rahmani +;; 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 . +;; +;;; Commentary: +;;; Code: +(eval-when-compile + (require 'fpkg)) + + +;; Language Servers and friends +(use! eglot + "Eglot is a minimalistic yet powerful LSP replacement +shipped with Emacs." + :hook + (prog-mode . eglot-ensure) + (prog-mode . (lambda () + (add-hook 'before-save-hook 'eglot-format nil t)))) + + +(provide 'fg42/eglot) +;;; eglot.el ends here diff --git a/lisp/fg42/langs/nix.el b/lisp/fg42/langs/nix.el index 4fcbddd..b9ed6b8 100644 --- a/lisp/fg42/langs/nix.el +++ b/lisp/fg42/langs/nix.el @@ -24,13 +24,26 @@ (eval-when-compile (require 'fpkg)) + + (use! nix-mode "Nix language support for Emacs." :mode "\\.nix\\'" + :hook (nix-mode . eglot-ensure) (nix-mode . company-mode) - (nix-mode . flyspell-prog-mode)) + (nix-mode . flyspell-prog-mode) + + :init + :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)))) + (provide 'fg42/langs/nix) ;;; nix.el ends here diff --git a/nix/fg42.nix b/nix/fg42.nix index 874b6c2..f70179d 100644 --- a/nix/fg42.nix +++ b/nix/fg42.nix @@ -14,8 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . { lib, stdenv, elispPkgs, srcDir, emacsPackagesFor, ourPackages, direnv -, makeFontsConf, nix - +, makeFontsConf, nix, nixpkgs-fmt , nil, # nix lsp server # python deps @@ -44,7 +43,7 @@ let dicts = aspellWithDicts (dicts: with dicts; [ en en-computers en-science ]); runtimeBins = [ - ripgrep git tree-sitter direnv nix nil dicts fd + ripgrep git tree-sitter direnv nix nil dicts fd nixpkgs-fmt ] ++ (lib.optional (!stdenv.buildPlatform.isRiscV) [ # Not supported on Risc-V