Add eglot-format to before-save-hook

This commit is contained in:
Sameer Rahmani 2024-04-11 20:04:49 +01:00
parent 980566ea70
commit 7659a028f7
Signed by: lxsameer
GPG Key ID: 8741FACBF412FFA5
5 changed files with 60 additions and 13 deletions

View File

@ -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") {

View File

@ -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."

39
lisp/fg42/eglot.el Normal file
View File

@ -0,0 +1,39 @@
;;; 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))
;; 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

View File

@ -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

View File

@ -14,8 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{ 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