diff options
author | Azat Bahawi <azat@bahawi.net> | 2023-02-19 17:50:35 +0300 |
---|---|---|
committer | Azat Bahawi <azat@bahawi.net> | 2023-02-19 17:50:35 +0300 |
commit | 91fb4f28ef5d87e8bcf7749928d30ba4a9cbbd34 (patch) | |
tree | e07291fcb1cf62a561ffe58d1fd8e2968ff6fcb3 /modules/common/emacs | |
parent | 2023-02-15 (diff) |
2023-02-19
Diffstat (limited to 'modules/common/emacs')
-rw-r--r-- | modules/common/emacs/default.nix | 163 | ||||
-rw-r--r-- | modules/common/emacs/doom/config.el | 223 | ||||
-rw-r--r-- | modules/common/emacs/doom/init.el | 119 | ||||
-rw-r--r-- | modules/common/emacs/doom/packages.el | 17 |
4 files changed, 522 insertions, 0 deletions
diff --git a/modules/common/emacs/default.nix b/modules/common/emacs/default.nix new file mode 100644 index 0000000..7395c51 --- /dev/null +++ b/modules/common/emacs/default.nix @@ -0,0 +1,163 @@ +{ + config, + inputs, + lib, + pkgs, + pkgsStable, + this, + ... +}: +with lib; let + cfg = config.nixfiles.modules.emacs; +in { + options.nixfiles.modules.emacs.enable = mkEnableOption "GNU Emacs"; + + config = mkIf cfg.enable { + nixfiles.modules = { + fonts.enable = true; + git.client.enable = true; + gnupg.enable = true; + }; + + hm = { + xdg.configFile = { + "doom/init.el".source = ./doom/init.el; + "doom/packages.el".source = ./doom/packages.el; + "doom/config.el" = { + text = concatStringsSep "\n" [ + (let + # NOTE gopls will require the "go" executable which must be provided + # by the project's flake/shell. + extraBins = with pkgs; + [ + enchant # :checkers (spell +enchant) + (python3.withPackages (p: + with p; [ + black # :lang python :editor format + isort # :lang python + pyflakes # :lang python + python-lsp-server # :lang (python +lsp) + ])) + asmfmt # :editor format + bash-language-server # :lang (sh +lsp) + clang-tools # :lang (cc +lsp) :editor format + cmake-format # :lang cc :editor format + cmigemo # :lang japanese + css-language-server # :lang (web +lsp) + dhall-language-server # :lang (dhall +lsp) + dockerfile-language-server # :tools (docker +lsp) + editorconfig # :tools editorconfig + fd # doom! + gnuplot # :lang (org +gnuplot) + gnutls # doom! + go-language-server # :lang (go +lsp) + gomodifytags # :lang go + gore # :lang go + gotests # :lang go + gotools # :lang go + graphviz # :lang (org +roam2) :lang plantuml + html-language-server # :lang (web +lsp) + html-tidy # :lang web + jre # :lang plantuml + json-language-server # :lang (json +lsp) + nix-language-server # :lang (nix +lsp) + nixfmt # :lang nix :editor format + nodePackages.js-beautify # :lang web + nodePackages.prettier # :editor format + nodePackages.stylelint # :lang web + nodejs # :tools debugger + pandoc # :lang org markdown latex + pinentry-emacs # doom! + pre-commit # :tools magit + ripgrep # doom! + rust-analyzer # :lang (rust +lsp) + rustfmt # :lang rust + shellcheck # :lang sh + shfmt # :lang sh :editor format + sqlite # :lang (org +roam2) :tools lookup + texlab # lang (tex +lsp) + texlive.combined.scheme-full # :lang org tex + unzip # :tools debugger + wordnet # :tools (lookup +dictionary +offline) + yaml-language-server # :lang (yaml +lsp) + zls # :lang (zig +lsp) + zstd # :emacs undo + ] + ++ ( + # + # GDB doesn't support[1] Apple Silicon on MacOS. + # + # [1]: https://inbox.sourceware.org/gdb/6b48224b-9e2e-518d-793b-df4fc5514884@arm.com/ + if (this.system != "aarch64-darwin") + then [gdb] # :tools debugger + else [lldb] # :tools debugger + ) + ++ optionals (!pkgs.stdenv.isDarwin) + [ + # NOTE Haskell is pretty much broken every couple of days on + # MacOS and I usually don't write anything in Haskell while + # I'm on my work laptop, so... ShellCheck seems to be working, + # though. + haskellPackages.ormolu # :lang haskell :editor format + haskellPackages.haskell-language-server # :lang (haskell +lsp) + haskellPackages.cabal-fmt # :lang haskell :editor format + haskellPackages.cabal-install # :lang haskell + haskellPackages.hoogle # :lang haskell + ]; + in '' + ;; This will integrate packages which are required by various + ;; modules without polluting the user's profile. + (setq exec-path (append exec-path '(${ + concatMapStringsSep " " (x: ''"${x}/bin"'') extraBins + }))) + (setenv "PATH" (concat (getenv "PATH") ":${ + concatMapStringsSep ":" (x: "${x}/bin") extraBins + }")) + + ;; Font must be set to N+2 because otherwise it looks too small. + (setq doom-font (font-spec :family "${config.fontScheme.monospaceFont.family}" + :size ${toString (config.fontScheme.monospaceFont.size + 2)}) + doom-unicode-font doom-font) + + (setq user-full-name "${my.fullname}" + user-mail-address "${my.email}") + + ;; :app irc + (setq circe-default-nick "${my.username}" + circe-default-realname "${my.email}" + circe-default-user circe-default-nick) + + ;; :lang plantuml + (setq org-plantuml-jar-path "${pkgs.plantuml}/lib/plantuml.jar") + + ;; :input japanese + (setq migemo-dictionary "${pkgs.cmigemo}/share/migemo/utf-8/migemo-dict") + + ;; :input japanese + (setq skk-large-jisyo "${pkgs.skk-dicts}/share/skk/SKK-JISYO.L") + '') + (builtins.readFile ./doom/config.el) + ]; + onChange = with config.hm.programs; '' + if [[ -x "''${XDG_CONFIG_HOME:~/.config}/emacs/bin/doom" ]]; then + oldpath="$PATH" + export PATH="''${PATH:-/bin}:${emacs.package}/bin:${git.package}/bin" + + "''${XDG_CONFIG_HOME:~/.config}/emacs/bin/doom" sync + + export PATH="$oldpath" + unset oldpath + fi + ''; + }; + }; + + programs.emacs = { + enable = true; + package = pkgs.emacs28; # Pin to avoid surprises. + # For some reason latest libvterm is not picked up by Emacs. + extraPackages = _: with pkgsStable.emacsPackages; [vterm]; + }; + }; + }; +} diff --git a/modules/common/emacs/doom/config.el b/modules/common/emacs/doom/config.el new file mode 100644 index 0000000..9284e0b --- /dev/null +++ b/modules/common/emacs/doom/config.el @@ -0,0 +1,223 @@ +;; +;;; Misc +;; + +(setq display-line-numbers-type t) + +(setq scroll-margin 10 + hscroll-margin 10) + +(setq browse-url-generic-program (executable-find "firefox") + browse-url-browser-function 'browse-url-generic) + +;; +;;; Doom-specific +;; + +;; Make it more default-ey. +(setq frame-title-format '("Emacs") + icon-title-format frame-title-format) + +(setq doom-theme 'doom-tomorrow-night) + +(setq +format-on-save-enabled-modes '(not nix-mode json-mode yaml-mode)) + +;; +;;; LSP +;; + +(setq lsp-enable-suggest-server-download nil) + +;; +;;; Org +;; + +(setq org-directory "~/doc/org/") +(after! org + (setq org-todo-keywords '((sequence + "PROJ(p)" ; A master task. + "TODO(t)" ; A task that needs to be done with statues: + "STRT(s@)" ; - In progress. + "HOLD(l@/!)" ; - Paused because of me. + "WAIT(w@/!)" ; - Paused because of not me. + "|" + "DONE(d@/!)" ; Complete state. + "KILL(k@/!)")) ; Incomplete state. + org-todo-keyword-faces '(("PROJ" . +org-todo-project) + ("TODO" . +org-todo-active) + ("STRT" . +org-todo-active) + ("HOLD" . +org-todo-onhold) + ("WAIT" . +org-todo-onhold) + ("DONE" . +org-todo-cancel) + ("KILL" . +org-todo-cancel)))) + +(add-hook! 'org-mode-hook 'auto-fill-mode) + +(add-hook! 'org-mode-hook (lambda (&rest _) + (setq fill-column 80))) + +(setq org-roam-directory "~/doc/roam/" + org-roam-db-location (concat org-roam-directory ".db")) + +(use-package! org-roam-ui + :requires websocket + :after org-roam + :config + (setq org-roam-ui-sync-theme t + org-roam-ui-follow t + org-roam-ui-update-on-save t + org-roam-ui-open-on-start t)) + +;; +;;; Elisp +;; + +(setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)) + +;; +;;; Haskell +;; + +(setq lsp-haskell-formatting-provider "ormolu") + +;; +;;; Nix +;; + +(after! lsp-mode + (add-to-list 'lsp-language-id-configuration '(nix-mode . "nix")) + (lsp-register-client + (make-lsp-client :new-connection (lsp-stdio-connection '("rnix-lsp")) + :major-modes '(nix-mode) + :server-id 'nix))) + +;; +;;; YAML +;; + +(add-hook! 'yaml-mode-hook + (defun +disable-flycheck-for-yaml-helm-templates () + (when (and buffer-file-name + (string-match-p "/templates/" buffer-file-name) + (or (string-suffix-p ".yaml" buffer-file-name) + (string-suffix-p ".yml" buffer-file-name))) + (remove-hook! 'yaml-mode-local-vars-hook #'lsp!) + (pushnew! flycheck-disabled-checkers 'yaml-jsyaml 'yaml-ruby 'yaml-yamllint)))) + +(setq-hook! 'yaml-mode-hook +format-with-lsp nil) + +;; +;;; Elfeed +;; + +(setq elfeed-db-directory "~/.elfeed" + elfeed-enclosure-default-dir (concat elfeed-db-directory "/enclosures") + rmh-elfeed-org-files (list (concat elfeed-db-directory "/index.org")) + elfeed-goodies/powerline-default-separator nil + elfeed-goodies/entry-pane-size 0.75 + elfeed-goodies/entry-pane-position 'bottom) + +;; +;;; mu4e +;; + +(setq mu4e-root-maildir "~/mail" + mu4e-context-policy 'ask-if-none + mu4e-compose-context-policy 'always-ask + mu4e-compose--org-msg-toggle-next nil + mu4e-update-interval 60 + sendmail-program (executable-find "msmtp") + send-mail-function #'smtpmail-send-it + message-sendmail-f-is-evil t + message-sendmail-extra-arguments '("--read-envelope-from") + message-send-mail-function #'message-send-mail-with-sendmail + +mu4e-personal-addresses (list "frodo@gondor.net" + "frodo@rohan.net" + "azahi@shire.me" + "admin@shire.me" + "ceo@shire.me" + "a.gondor@yahoo.com" + "a.gondor@yahoo.com")) + +(set-email-account! "shire" + '((mu4e-drafts-folder . "/shire/Drafts") + (mu4e-refile-folder . "/shire/Archive") + (mu4e-sent-folder . "/shire/Sent") + (mu4e-trash-folder . "/shire/Trash") + (smtpmail-smtp-user . "azahi")) + t) + +(set-email-account! "yahoo" + '((mu4e-sent-folder . "/yahoo/Sent") + (mu4e-drafts-folder . "/yahoo/Drafts") + (mu4e-trash-folder . "/yahoo/Trash") + (mu4e-refile-folder . "/yahoo/Archive") + (smtpmail-smtp-user . "a.gondor")) + t) + +(setq +mu4e-compose-org-msg-toggle-next nil) + +;; +;;; Circe +;; + +(defun nixfiles/irc-bouncer-password-f (&rest _) + (+pass-get-secret "server/soju.manwe.shire.me/azahi")) + +(set-irc-server! "libera" + `(:host "shire.me" + :port 6667 + :user "azahi/libera" + :pass nixfiles/irc-bouncer-password-f)) + +(set-irc-server! "oftc" + `(:host "shire.me" + :port 6667 + :user "azahi/oftc" + :pass nixfiles/irc-bouncer-password-f)) + +(set-irc-server! "hackint" + `(:host "shire.me" + :port 6667 + :user "azahi/hackint" + :pass nixfiles/irc-bouncer-password-f)) + +(set-irc-server! "rizon" + `(:host "shire.me" + :port 6667 + :user "azahi/rizon" + :pass nixfiles/irc-bouncer-password-f)) + +;; (use-package! hledger-mode +;; :mode ("\\.journal\\'") +;; :hook ((hledger-view-mode . hl-line-mode) +;; (hledger-view-mode . center-text-for-reading)) +;; :init +;; (setq hledger-jfile "~/doc/accounting/current.journal") +;; :config +;; (set-company-backend! 'hledger-mode 'hledger-company) +;; (add-hook! 'hledger-mode-hook +;; (lambda (&rest _) +;; (make-local-variable 'company-backends) +;; (add-to-list 'company-backends 'hledger-company)))) + +;; (use-package! hledger-input +;; :hook ((hledger-input-post-commit . hledger-show-new-balances) +;; (hledger-input-mode . auto-fill-mode) +;; (hledger-input-mode . (lambda (&rest _) +;; (make-local-variable 'compay-idle-delay) +;; (setq-local company-idle-delay 0.1)))) +;; :init +;; (setq hledger-input-buffer-height 20)) + +;; (use-package! kubernetes +;; :defer t +;; :commands (kubernetes-overview) +;; :init (setq kubernetes-poll-frequency 3600 +;; kubernetes-redraw-frequency 3600)) + +;; (use-package! kubernetes-evil +;; :after kubernetes-overview) + +;; (use-package! kubernetes-tramp +;; :defer t) diff --git a/modules/common/emacs/doom/init.el b/modules/common/emacs/doom/init.el new file mode 100644 index 0000000..cdab069 --- /dev/null +++ b/modules/common/emacs/doom/init.el @@ -0,0 +1,119 @@ +(doom! :input + ;; japanese + + :completion + company + vertico + + :ui + ;; deft + doom + ;; doom-dashboard + ;; doom-quit + ;; emoji + hl-todo + indent-guides + ;; ligatures + ;; modeline + ;; nav-flash + ophints + (popup +defaults) + ;; tabs + ;; unicode + (vc-gutter +diff-hl +pretty) + window-select + workspaces + + :editor + (evil +everywhere) + file-templates + fold + format + ;; lispy + ;; multiple-cursors + parinfer + ;; rotate-text + snippets + word-wrap + + :emacs + dired + ;; electric + ibuffer + undo + vc + + :term + eshell + vterm + + :checkers + syntax + (spell +enchant + +everywhere + +flyspell) + grammar + + :tools + ansible + (debugger +lsp) + direnv + (docker +lsp) + editorconfig + (eval +overlay) + gist + (lookup +dictionary +offline) + (lsp +peek) + (magit +forge) + make + (pass +auth) + ;; pdf + terraform + tree-sitter + upload + + :os + (:if IS-MAC macos) + ;; (tty +osc) + + :lang + (cc +lsp +tree-sitter) + (common-lisp +lsp +tree-sitter) + (csharp +lsp +tree-sitter) + data + (dhall +lsp +tree-sitter) + (emacs-lisp +lsp +tree-sitter) + (go +lsp +tree-sitter) + ;; graphql + (:if IS-LINUX (haskell +lsp +tree-sitter)) + (java +lsp +tree-sitter) + (javascript +lsp +tree-sitter) + (json +lsp +tree-sitter) + (kotlin +lsp +tree-sitter) + (latex +lsp +tree-sittter) + (markdown +lsp +tree-sitter) + (nix +lsp) + (org +pandoc +roam2) + plantuml + (python +lsp +tree-sitter) + (:if IS-LINUX (racket +lsp +tree-sitter)) + ;; rst + (rust +lsp +tree-sitter) + (:if IS-LINUX (scheme +lsp +tree-sitter +racket)) + (sh +lsp +tree-sitter) + web + (yaml +lsp +tree-sitter) + (zig +lsp +tree-sitter) + + :email + mu4e + + :app + calendar + ;; emms + ;; everywhere + irc + (rss +org) + + :config + (default +bindings +smartparens)) diff --git a/modules/common/emacs/doom/packages.el b/modules/common/emacs/doom/packages.el new file mode 100644 index 0000000..298a203 --- /dev/null +++ b/modules/common/emacs/doom/packages.el @@ -0,0 +1,17 @@ +(disable-packages! writegood-mode) + +(unpin! org-roam) +(package! org-roam + :recipe (:host github + :repo "org-roam/org-roam" + :branch "main")) +(package! org-roam-ui + :recipe (:host github + :repo "org-roam/org-roam-ui" + :branch "main")) + +;; (package! hledger-mode) + +;; (package! kubernetes) +;; (package! kubernetes-evil) +;; (package! kubernetes-tramp) |