commit f140e7763ff619427a3e0660c15a0fe9b6583715 Author: Artur Manuel Date: Wed Jul 17 04:09:08 2024 +0100 repository: init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..64b061c --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/* +/**/*~ +!/flake.* +!/overlay +!/.gitignore +!/README.org diff --git a/README.org b/README.org new file mode 100644 index 0000000..922e9a8 --- /dev/null +++ b/README.org @@ -0,0 +1,13 @@ +#+ATTR_ORG: :align right +[[./media/panko.gif][fatfatpankocat the fat fat panko cat]] + +*** Pankomacs +****** opinionated opinionated emacs configuration (ft. flakes) + +----- + +*** What is this configuration? + +This is a Nix flake for my Emacs configuration, similar to [[https://github.com/nix-community/kickstart-nix.nvim][kickstart-nix.nvim]]. +This was put in my =~/.emacs.d/= so I added some files to exclude in my =.gitignore=. + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..228962f --- /dev/null +++ b/flake.lock @@ -0,0 +1,120 @@ +{ + "nodes": { + "emacs": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1721063376, + "narHash": "sha256-di+YqstcANGipdJP+lQ/vPOlB+UIFNSZjg6rlpMOyFs=", + "owner": "nix-community", + "repo": "emacs-overlay", + "rev": "7c521a93160b3f3deb2325ba5485eabaecc76100", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "emacs-overlay", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1721016451, + "narHash": "sha256-Cypl9ORr5UjtBsbjXMTJRepTe362yNVrPrntUvHiTaw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a14c5d651cee9ed70f9cd9e83f323f1e531002db", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1720954236, + "narHash": "sha256-1mEKHp4m9brvfQ0rjCca8P1WHpymK3TOr3v34ydv9bs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "53e81e790209e41f0c1efa9ff26ff2fd7ab35e27", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719994518, + "narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "root": { + "inputs": { + "emacs": "emacs", + "nixpkgs": "nixpkgs", + "parts": "parts" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2016fe4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,37 @@ +{ + description = "Plusmacs"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; + emacs = { + url = "github:nix-community/emacs-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + outputs = inputs: + inputs.parts.lib.mkFlake { inherit inputs; } { + systems = [ + "x86_64-linux" + ]; + flake = { + overlays.default = final: _prev: import ./overlay final.pkgs; + }; + perSystem = { pkgs, self', config, system, ... }: { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ + inputs.emacs.overlays.default + inputs.self.overlays.default + ]; + }; + packages.pankomacs = pkgs.pankomacs; + packages.default = self'.packages.pankomacs; + + apps.pankomacs.program = "${self'.packages.pankomacs}/bin/emacs"; + apps.default = config.apps.pankomacs; + }; + }; +} diff --git a/overlay/default.nix b/overlay/default.nix new file mode 100644 index 0000000..1aa0655 --- /dev/null +++ b/overlay/default.nix @@ -0,0 +1,3 @@ +pkgs: { + pankomacs = pkgs.callPackage ./package { }; +} diff --git a/overlay/package/config.org b/overlay/package/config.org new file mode 100644 index 0000000..dddac5b --- /dev/null +++ b/overlay/package/config.org @@ -0,0 +1,251 @@ +#+title: PANKOMACS +#+author: Artur Manuel +#+PROPERTY: header-args :tangle config.el + +[[./panko.gif][the fat fat panko cat]] + +* Emacs window stuff +things like turning off the menubar, etc. +#+BEGIN_SRC emacs-lisp + (use-package emacs + :config + (menu-bar-mode -1) + (scroll-bar-mode -1) + (tool-bar-mode -1) + (recentf-mode 1) + :custom + (inhibit-startup-message t) + (initial-scratch-message nil) + (org-startup-with-inline-images t)) +#+END_SRC + +* Theming +using doom-themes here because tokyo night isn't on melpa +#+BEGIN_SRC emacs-lisp + (use-package doom-themes + :config + (setq doom-themes-enable-bold t + doom-themes-enable-italic t) + (load-theme 'doom-tokyo-night t) + + (doom-themes-visual-bell-config) + (doom-themes-neotree-config) + (setq doom-themes-treemacs-theme "doom-tokyo-night") + (doom-themes-treemacs-config) + (doom-themes-org-config)) +#+END_SRC + +also may or may not need doom modeline +#+BEGIN_SRC emacs-lisp + (use-package doom-modeline + :ensure t + :hook (after-init . doom-modeline-mode)) + +#+END_SRC + +* Vertico, Orderless, and more stuff +personal favourite emacs completer +#+BEGIN_SRC emacs-lisp + (use-package vertico + :custom + (vertico-count 5) + :init + (vertico-mode) + (keymap-set vertico-map "?" #'minibuffer-completion-help) + (keymap-set vertico-map "M-RET" #'minibuffer-force-complete-and-exit) + (keymap-set vertico-map "M-TAB" #'minibuffer-complete)) + + (use-package orderless + :custom + (completion-styles '(orderless basic)) + (completion-category-defaults nil) + (completion-category-overrides '((file (styles partial-completion)))) + :init + (setq completion-in-region-function + (lambda (&rest args) + (apply (if vertico-mode + #'consult-completion-in-region + #'completion--in-region) + args)))) + + (use-package marginalia + :bind (:map minibuffer-local-map + ("M-A" . marginalia-cycle)) + :init + (marginalia-mode)) + + (use-package embark + :ensure t + :bind + (("C-." . embark-act) + ("C-;" . embark-dwim) + ("C-h B" . embark-bindings)) + :init + (setq prefix-help-command #'embark-prefix-help-command) + (add-hook 'eldoc-documentation-functions #'embark-eldoc-first-target) + (setq eldoc-documentation-strategy #'eldoc-documentation-compose-eagerly) + :config + (add-to-list 'display-buffer-alist + '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" + nil + (window-parameters (mode-line-format . none))))) + + ;; Example configuration for Consult + (use-package consult + ;; Replace bindings. Lazily loaded by `use-package'. + :bind (;; C-c bindings in `mode-specific-map' + ("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 e" . consult-compile-error) + ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck + ("M-g g" . consult-goto-line) ;; orig. goto-line + ("M-g M-g" . consult-goto-line) ;; orig. goto-line + ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ("M-g m" . consult-mark) + ("M-g k" . consult-global-mark) + ("M-g i" . consult-imenu) + ("M-g I" . consult-imenu-multi) + ;; M-s bindings in `search-map' + ("M-s d" . consult-find) ;; Alternative: 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) + + ;; The :init configuration is always executed (Not lazy) + :init + + ;; Optionally 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) + + ;; Optionally 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) + + ;; Use Consult to select xref locations with preview + (setq xref-show-xrefs-function #'consult-xref + xref-show-definitions-function #'consult-xref) + + ;; Configure other variables and modes in the :config section, + ;; after lazily loading the package. + :config + + ;; Optionally 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-" "S-")) + ;; 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)) + + ;; Optionally configure the narrowing key. + ;; Both < and C-+ work reasonably well. + (setq consult-narrow-key "<") ;; "C-+" + + ;; Optionally make narrowing help available in the minibuffer. + ;; You may want to use `embark-prefix-help-command' or which-key instead. + ;; (keymap-set consult-narrow-map (concat consult-narrow-key " ?") #'consult-narrow-help) + ) + + (use-package embark-consult + :ensure t ; only need to install it, embark loads it after consult if found + :hook + (embark-collect-mode . consult-preview-at-point-mode)) + + + (use-package consult-dir + :ensure t + :bind (("C-x C-d" . consult-dir) + :map minibuffer-local-completion-map + ("C-x C-d" . consult-dir) + ("C-x C-j" . consult-dir-jump-file))) + + (use-package consult-dir + :ensure t + :bind (("C-x C-d" . consult-dir) + :map vertico-map + ("C-x C-d" . consult-dir) + ("C-x C-j" . consult-dir-jump-file))) + + ;; Configure directory extension. + (use-package vertico-directory + :after vertico + :ensure nil + ;; More convenient directory navigation commands + :bind (:map vertico-map + ("RET" . vertico-directory-enter) + ("DEL" . vertico-directory-delete-char) + ("M-DEL" . vertico-directory-delete-word)) + ;; Tidy shadowed file names + :hook (rfn-eshadow-update-overlay . vertico-directory-tidy)) + +#+END_SRC + +* Setting up languages +** GENERAL LANGUAGES +*** Flycheck +I will of course need flycheck for syntax highlighting reasons! +#+BEGIN_SRC emacs-lisp + (use-package flycheck + :ensure t + :config + (add-hook 'after-init-hook #'global-flycheck-mode)) + +#+END_SRC +** SPECIFIC LANGUAGES +*** Nix +#+BEGIN_SRC emacs-lisp + (use-package nix-ts-mode + :mode "\\.nix\\'") + +#+END_SRC + diff --git a/overlay/package/default.nix b/overlay/package/default.nix new file mode 100644 index 0000000..b0d93aa --- /dev/null +++ b/overlay/package/default.nix @@ -0,0 +1,25 @@ +{ emacsWithPackagesFromUsePackage, emacs-pgtk }: +emacsWithPackagesFromUsePackage { + package = emacs-pgtk; + config = ./config.org; + defaultInitFile = true; + alwaysEnsure = true; + alwaysTangle = true; + extraEmacsPackages = + e: with e; [ + treesit-grammars.with-all-grammars + nix-ts-mode + doom-themes + vertico + orderless + marginalia + embark + consult + embark-consult + consult-dir + doom-modeline + nerd-icons + flycheck + ]; + override = _: prev: { use-package = prev.emacs; }; +} diff --git a/overlay/package/panko.gif b/overlay/package/panko.gif new file mode 100644 index 0000000..9af7db9 Binary files /dev/null and b/overlay/package/panko.gif differ