2019-11-11 18:41:30 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
2019-10-23 03:44:17 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
gitpkgs = import /nixpkgs {};
|
2020-03-27 13:25:54 +01:00
|
|
|
fn = import (toString ../fn.nix) { inherit lib; };
|
2019-11-17 23:13:50 +01:00
|
|
|
modefiles = fn.lst { p = (toString ./emacs); b = true; };
|
2019-11-11 18:41:30 +01:00
|
|
|
in rec {
|
2019-11-17 23:13:50 +01:00
|
|
|
# nixpkgs.overlays = [
|
|
|
|
# (import (builtins.fetchTarball {
|
|
|
|
# url = https://github.com/nix-community/emacs-overlay/archive/master.tar.gz;
|
|
|
|
# }))
|
|
|
|
# ];
|
2019-11-11 18:41:30 +01:00
|
|
|
imports = [
|
2020-03-27 13:25:54 +01:00
|
|
|
../options/emacs-init.nix
|
2019-11-17 23:13:50 +01:00
|
|
|
] ++ modefiles;
|
2019-11-11 18:41:30 +01:00
|
|
|
|
|
|
|
programs.emacs.init = {
|
2019-11-20 11:21:43 +01:00
|
|
|
enable = (elem "emacs" config.machine.pkgs);
|
2019-11-11 18:41:30 +01:00
|
|
|
recommendedGcSettings = true;
|
2019-11-17 23:13:50 +01:00
|
|
|
|
2019-11-11 18:41:30 +01:00
|
|
|
prelude = ''
|
|
|
|
;; Disable UI Clutter
|
|
|
|
(menu-bar-mode -1)
|
|
|
|
(tool-bar-mode -1)
|
|
|
|
(scroll-bar-mode -1)
|
|
|
|
(tooltip-mode -1)
|
|
|
|
(blink-cursor-mode -1)
|
|
|
|
(setq ring-bell-function 'ignore)
|
|
|
|
(setq inhibit-startup-buffer-menu t)
|
|
|
|
(setq use-dialog-box nil)
|
|
|
|
(setq inhibit-startup-message t)
|
|
|
|
(setq inhibit-splash-screen t)
|
|
|
|
(setq initial-scratch-message nil)
|
|
|
|
(fset 'yes-or-no-p 'y-or-n-p)
|
|
|
|
(setq-default show-trailing-whitespace t)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Save and Backup behaviour
|
|
|
|
(add-hook 'before-save-hook 'delete-trailing-whitespace)
|
|
|
|
(setq create-lockfiles nil)
|
|
|
|
(setq backup-directory-alist `(("." . "~/.emacs_saves")))
|
|
|
|
(setq backup-by-copying t)
|
|
|
|
(setq delete-old-versions t
|
|
|
|
kept-new-versions 6
|
|
|
|
kept-old-versions 2
|
|
|
|
version-control t)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Tabs vs Spaces... I like Spaces
|
|
|
|
(setq-default indent-tabs-mode nil
|
|
|
|
tab-width 4
|
|
|
|
c-basic-offset 4)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; General Functions I want
|
|
|
|
(put 'narrow-to-region 'disabled nil)
|
|
|
|
(put 'upcase-region 'disabled nil)
|
|
|
|
(put 'downcase-region 'disabled nil)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Global UI related Modes
|
|
|
|
(global-display-line-numbers-mode)
|
|
|
|
(setq display-line-numbers-width-start t)
|
|
|
|
(setq display-line-numbers-grow-only t)
|
|
|
|
(column-number-mode t)
|
|
|
|
(global-hl-line-mode t)
|
|
|
|
(size-indication-mode t)
|
|
|
|
(show-paren-mode t)
|
2019-11-17 23:13:50 +01:00
|
|
|
(setq split-height-threshold 200)
|
|
|
|
(setq split-width-threshold nil)
|
2019-11-11 18:41:30 +01:00
|
|
|
|
|
|
|
|
2020-01-26 17:35:22 +01:00
|
|
|
|
|
|
|
;; Text Scaling
|
|
|
|
(global-set-key (kbd "C-+") 'text-scale-increase)
|
|
|
|
(global-set-key (kbd "C--") 'text-scale-decrease)
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-11-11 18:41:30 +01:00
|
|
|
;; Font Config
|
|
|
|
(defun set-fonts (frame)
|
|
|
|
(interactive)
|
|
|
|
"Adjust the font settings of FRAME so Emacs can display emoji and chinese properly."
|
|
|
|
(set-fontset-font t 'ascii (font-spec :family "DejaVu Sans Mono") frame 'preprend)
|
|
|
|
(set-fontset-font t 'big5 (font-spec :family "AR PL UMing TW") frame)
|
|
|
|
(set-fontset-font t 'chinese-gbk (font-spec :family "AR PL UMing CN") frame)
|
|
|
|
(set-fontset-font t 'symbol (font-spec :family "Symbola") frame 'prepend))
|
|
|
|
|
|
|
|
;; For when Emacs is started in GUI mode:
|
|
|
|
(set-fonts nil)
|
|
|
|
;; Hook for when a frame is created with emacsclient
|
|
|
|
;; see https://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Frames.html
|
|
|
|
(add-hook 'after-make-frame-functions 'set-fonts)
|
2019-12-18 09:08:23 +01:00
|
|
|
|
|
|
|
;; Fix keyboard input of 'dead-keys'
|
|
|
|
(require 'iso-transl)
|
2020-06-01 02:28:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Some small helper functions
|
|
|
|
;; These are based on the already existing 'kill' versions of the function
|
|
|
|
;; It's literally just a M-x r-str kill delete (and getting rid of tabs)
|
|
|
|
(defun delete-word (arg)
|
|
|
|
"Delete characters forward until encountering the end of a word.
|
|
|
|
With argument ARG, do this that many times."
|
|
|
|
(interactive "p")
|
|
|
|
(delete-region (point) (progn (forward-word arg) (point))))
|
|
|
|
(define-key global-map [remap kill-word] 'delete-word)
|
|
|
|
;; (define-key global-map (kbd <>) 'kill-word)
|
|
|
|
|
|
|
|
(defun backward-delete-word (arg)
|
|
|
|
"Delete characters backward until encountering the beginning of a word.
|
|
|
|
With argument ARG, do this that many times."
|
|
|
|
(interactive "p")
|
|
|
|
(delete-word (- arg)))
|
|
|
|
(define-key global-map [remap backward-kill-word] 'backward-delete-word)
|
|
|
|
|
|
|
|
(defun delete-whole-line (&optional arg)
|
|
|
|
"Delete current line.
|
|
|
|
With prefix ARG, delete that many lines starting from the current line.
|
|
|
|
If ARG is negative, delete backward. Also delete the preceding newline.
|
|
|
|
\(This is meant to make \\[repeat] work well with negative arguments.)
|
|
|
|
If ARG is zero, delete current line but exclude the trailing newline."
|
|
|
|
(interactive "p")
|
|
|
|
(or arg (setq arg 1))
|
|
|
|
(if (and (> arg 0) (eobp) (save-excursion (forward-visible-line 0) (eobp)))
|
|
|
|
(signal 'end-of-buffer nil))
|
|
|
|
(if (and (< arg 0) (bobp) (save-excursion (end-of-visible-line) (bobp)))
|
|
|
|
(signal 'beginning-of-buffer nil))
|
|
|
|
(unless (eq last-command 'delete-region)
|
|
|
|
(delete-new "")
|
|
|
|
(setq last-command 'delete-region))
|
|
|
|
(cond ((zerop arg)
|
|
|
|
;; We need to delete in two steps, because the previous command
|
|
|
|
;; could have been a delete command, in which case the text
|
|
|
|
;; before point needs to be prepended to the current delete
|
|
|
|
;; ring entry and the text after point appended. Also, we
|
|
|
|
;; need to use save-excursion to avoid copying the same text
|
|
|
|
;; twice to the delete ring in read-only buffers.
|
|
|
|
(save-excursion
|
|
|
|
(delete-region (point) (progn (forward-visible-line 0) (point))))
|
|
|
|
(delete-region (point) (progn (end-of-visible-line) (point))))
|
|
|
|
((< arg 0)
|
|
|
|
(save-excursion
|
|
|
|
(delete-region (point) (progn (end-of-visible-line) (point))))
|
|
|
|
(delete-region (point)
|
|
|
|
(progn (forward-visible-line (1+ arg))
|
|
|
|
(unless (bobp) (backward-char))
|
|
|
|
(point))))
|
|
|
|
(t
|
|
|
|
(save-excursion
|
|
|
|
(delete-region (point) (progn (forward-visible-line 0) (point))))
|
|
|
|
(delete-region (point)
|
|
|
|
(progn (forward-visible-line arg) (point))))))
|
|
|
|
(define-key global-map [remap kill-whole-line] 'delete-whole-line)
|
2019-11-11 18:41:30 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-11-17 23:13:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### OLD STUFF
|
2019-11-11 18:41:30 +01:00
|
|
|
# machine.pkgsets.emacs.pkgwrap = [(gitpkgs.pkgs.emacsWithPackages (ps: with ps; config.machine.pkgsets.emacs.pkgs))];
|
|
|
|
#[
|
|
|
|
# (pkgs.emacsWithPackagesFromUsePackage {
|
|
|
|
# # config = (concatStringsSep "\n" machine.pkgsets.emacs.config);
|
|
|
|
# config = ''
|
|
|
|
# # (package-initialize)
|
|
|
|
# # (org-babel-load-file "~/.emacs.d/configuration.org")
|
|
|
|
# '';
|
|
|
|
# package = pkgs.emacsGit;
|
|
|
|
# extraEmacsPackages = (ep: with ep; config.machine.pkgsets.emacs.pkgs);
|
|
|
|
# })
|
|
|
|
# ];
|
|
|
|
# machine.pkgsets.emacs.pkgs = with pkgs; with pkgs.emacsPackages; [
|
|
|
|
# /* Theming */
|
|
|
|
# solarized-theme color-theme-sanityinc-tomorrow moe-theme powerline moody minions
|
|
|
|
# /*General Stuff */
|
|
|
|
# rainbow-delimiters # color parenthesis by indentation
|
|
|
|
# color-identifiers-mode
|
|
|
|
# /* Python */
|
|
|
|
# company-jedi pylint elpy flycheck-mypy
|
|
|
|
# /* Git support */
|
|
|
|
# magit
|
|
|
|
# emms # multimedia support
|
|
|
|
# wsd-mode
|
|
|
|
# plantuml-mode
|
|
|
|
# /* Other Stuff, not yet sorted */
|
|
|
|
# mu4e-alert
|
|
|
|
# google-translate
|
|
|
|
# tramp
|
|
|
|
# transmission
|
|
|
|
# org-plus-contrib orgit ox-gfm ox-rst
|
|
|
|
# easy-jekyll markdown-mode impatient-mode simple-httpd htmlize
|
|
|
|
# eclim
|
|
|
|
# auto-complete
|
|
|
|
# pkgs.aspell pkgs.aspellDicts.en pkgs.aspellDicts.de
|
|
|
|
# use-package diminish bind-key
|
|
|
|
# smartparens
|
|
|
|
# evil-surround evil-indent-textobject evil-cleverparens avy undo-tree
|
|
|
|
# cdlatex # for math expressions
|
|
|
|
# helm
|
|
|
|
# /* LaTeX */ auctex helm-bibtex cdlatex
|
|
|
|
# markdown-mode
|
|
|
|
# flycheck
|
|
|
|
# pkgs.ledger
|
|
|
|
# yaml-mode
|
|
|
|
# company
|
|
|
|
# # Irony is currently broken.
|
|
|
|
# /* C/C++ */ irony company-irony company-irony-c-headers flycheck-irony clang-format pkgs.clang-tools
|
|
|
|
# /* Haskell */ haskell-mode flycheck-haskell
|
|
|
|
# /* Org */ org org-ref pdf-tools org-bullets org-caldav
|
|
|
|
# /* Rust */ rust-mode flycheck-rust racer
|
|
|
|
# /* mail */ messages-are-flowing
|
|
|
|
# /* Nix */ nix-buffer nix-mode nixos-options company-nixos-options nix-sandbox
|
|
|
|
# paganini-theme
|
|
|
|
# json-navigator
|
|
|
|
# spaceline # modeline beautification
|
|
|
|
# winum eyebrowse # window management
|
|
|
|
# auto-compile
|
|
|
|
# /* Maxima */ pkgs.maxima
|
|
|
|
# visual-fill-column
|
|
|
|
# web-mode
|
|
|
|
# melpaStablePackages.idris-mode helm-idris
|
|
|
|
# /* Java */
|
|
|
|
# # projectile yasnippet lsp-mode hydra company-lsp lsp-ui lsp-java dap-mode
|
|
|
|
# cl-lib meghanada autodisass-java-bytecode google-c-style realgud
|
|
|
|
# weechat
|
|
|
|
# ];
|
2019-10-23 03:44:17 +02:00
|
|
|
}
|