aboutsummaryrefslogtreecommitdiff
path: root/nix/users
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--nix/users/fcuny/configs/emacs/early-init.el21
-rw-r--r--nix/users/fcuny/configs/emacs/init.el471
-rw-r--r--nix/users/fcuny/dev.nix6
-rw-r--r--nix/users/fcuny/emacs.nix69
-rw-r--r--nix/users/fcuny/home-manager.nix1
-rw-r--r--nix/users/fcuny/shell.nix2
6 files changed, 562 insertions, 8 deletions
diff --git a/nix/users/fcuny/configs/emacs/early-init.el b/nix/users/fcuny/configs/emacs/early-init.el
new file mode 100644
index 0000000..55c8728
--- /dev/null
+++ b/nix/users/fcuny/configs/emacs/early-init.el
@@ -0,0 +1,21 @@
+;; Startup speed, annoyance suppression
+(setq gc-cons-threshold 10000000)
+(setq byte-compile-warnings '(not obsolete))
+(setq warning-suppress-log-types '((comp) (bytecomp)))
+(setq native-comp-async-report-warnings-errors 'silent)
+
+;; Silence startup message
+(setq inhibit-startup-echo-area-message (user-login-name))
+
+;; Default frame configuration: full screen, good-looking title bar on macOS
+(setq frame-resize-pixelwise t)
+
+(tool-bar-mode -1)
+
+(setq default-frame-alist '((fullscreen . maximized)
+ ;; Setting the face in here prevents flashes of
+ ;; color as the theme gets activated
+ (ns-appearance . light)
+ (ns-transparent-titlebar . t)))
+
+(set-face-attribute 'default nil :family "Source Code Pro" :height 150)
diff --git a/nix/users/fcuny/configs/emacs/init.el b/nix/users/fcuny/configs/emacs/init.el
new file mode 100644
index 0000000..914fd82
--- /dev/null
+++ b/nix/users/fcuny/configs/emacs/init.el
@@ -0,0 +1,471 @@
+(defconst emacs-start-time (current-time))
+
+(defun report-time-since-load ()
+ "Report how long it takes to load my Emacs configuration."
+ (message "[after-init ]Loading init...done (%.3fs)"
+ (float-time (time-subtract (current-time) emacs-start-time))))
+
+(add-hook 'after-init-hook #'(lambda () (report-time-since-load)) t)
+
+(setq sentence-end-double-space nil ;; it matters for filling
+ create-lockfiles nil ;; don't use a lock file
+ initial-major-mode 'fundamental-mode ;; default mode for the scratch buffer
+ initial-scratch-message "" ;; makes the scratch buffer empty
+ confirm-kill-emacs #'yes-or-no-p ;; ask before killing emacs
+ use-short-answers t ;; use y-or-n
+ ring-bell-function 'ignore ;; really no bell
+ visible-bell nil ;; no bell
+ delete-by-moving-to-trash t ;; delete files by moving them to the trash
+ history-delete-duplicates t ;; delete duplicate from history
+ require-final-newline t ;; ensure a new line is present at the bottom of files
+ auto-save-default nil ;; no auto save
+ backup-inhibited t ;; no backups
+ )
+
+;; Use UTF-8 everywhere
+(set-default-coding-systems 'utf-8)
+
+(use-package recentf
+ :custom
+ (recentf-max-saved-items 2000)
+ (recentf-max-menu-items 200)
+ (recentf-exclude
+ '("~\\'" "\\`out\\'" "\\.log\\'" "^/[^/]*:" "\\.el\\.gz\\'" "\\.gz\\'"))
+ :config
+ (recentf-mode t))
+
+(use-package savehist
+ :hook (after-init . savehist-mode)
+ :config
+ (setq history-length 100)
+ (setq history-delete-duplicates t)
+ (setq savehist-save-minibuffer-history t)
+ (savehist-mode t))
+
+(use-package saveplace
+ :config
+ (save-place-mode t))
+
+(use-package autorevert
+ :custom
+ (auto-revert-use-notify nil)
+ :config
+ (global-auto-revert-mode t))
+
+(global-set-key (kbd "M-j") 'join-line)
+
+(use-package which-key
+ :diminish
+ :hook (after-init . which-key-mode))
+
+(use-package imenu
+ :config
+ (setq imenu-auto-rescan t))
+
+(use-package exec-path-from-shell
+ :config
+ (exec-path-from-shell-initialize)
+ :custom
+ (exec-path-from-shell-variables '("ASPELL_CONF")))
+
+(use-package ibuffer
+ :bind ("C-x C-b" . ibuffer)
+ :custom
+ (ibuffer-expert t)
+ (ibuffer-show-empty-filter-groups nil)
+ (ibuffer-jump-offer-only-visible-buffers t)
+ (ibuffer-maybe-show-predicates '("^\\*.*\\*$"))
+ (ibuffer-never-show-predicates '("^ "))
+ (ibuffer-use-other-window t))
+
+(use-package midnight
+ :custom
+ ;; every 6 hours
+ (midnight-period (* 3600 6)))
+
+(use-package dired
+ :hook (dired-mode . dired-omit-mode)
+ :bind (:map dired-mode-map
+ ( "." . dired-omit-mode))
+ :custom
+ (dired-omit-files (rx (seq bol ".")))
+ (dired-use-ls-dired t)
+ (insert-directory-program "/etc/profiles/per-user/fcuny/bin/ls")
+ (dired-clean-up-buffers-too nil)
+ (dired-dwim-target t)
+ (dired-hide-details-hide-information-lines nil)
+ (dired-hide-details-hide-symlink-targets nil)
+ (dired-recursive-copies 'always)
+ (dired-recursive-deletes 'always)
+ (dired-no-confirm
+ '(byte-compile chgrp chmod chown copy hardlink symlink touch)))
+
+(defun my/rename-this-buffer-and-file ()
+ "Renames current buffer and file it is visiting."
+ (interactive)
+ (let ((name (buffer-name))
+ (filename (buffer-file-name))
+ (read-file-name-function 'read-file-name-default))
+ (if (not (and filename (file-exists-p filename)))
+ (error "Buffer '%s' is not visiting a file!" name)
+ (let ((new-name (read-file-name "New name: " filename)))
+ (cond ((get-buffer new-name)
+ (error "A buffer named '%s' already exists!" new-name))
+ (t
+ (rename-file filename new-name 1)
+ (rename-buffer new-name)
+ (set-visited-file-name new-name)
+ (set-buffer-modified-p nil)
+ (message "File '%s' successfully renamed to '%s'" name (file-name-nondirectory new-name))))))))
+
+;; Don't say anything on mode-line mouseover.
+(setq mode-line-default-help-echo nil)
+
+;; Keep cursors and highlights in current window only.
+(setq cursor-in-non-selected-windows nil)
+
+;; Don't highlight inactive windows.
+(setq highlight-nonselected-windows nil)
+
+(use-package fringe
+ :config
+ ;; no fringe on the right side
+ (fringe-mode '(8 . 0)))
+
+;; Disable bidirectional text support for slight performance bonus.
+(setq bidi-display-reordering nil)
+
+;; show column number in the mode line
+(setq column-number-mode t)
+
+(require 'time)
+
+(setq display-time-24hr-format t
+ display-time-interval 60
+ display-time-mode t
+ display-time-format "%H:%M %d.%m"
+ display-time-day-and-date t
+ display-time-default-load-average nil)
+
+(setq world-clock-list t
+ world-clock-timer-enable t
+ world-clock-timer-second 60
+ world-clock-time-format "%R %z %A %d %B")
+
+;; UTC => 02:42 +0000 Wednesday 20 April
+;; Berkeley => 19:42 -0700 Tuesday 19 April
+(setq zoneinfo-style-world-list '(("UTC" "UTC")
+ ("America/Los_Angeles" "Berkeley")
+ ("America/Denver" "Mountain Time")
+ ("America/Chicago" "Central Time")
+ ("America/New_York" "New York")
+ ("Europe/London" "London")
+ ("Europe/Paris" "Paris")))
+
+(use-package ef-themes
+ :custom
+ (ef-themes-region '(intense no-extend neutral))
+ (ef-themes-disable-other-themes t)
+ (ef-themes-to-toggle '(ef-melissa-light ef-maris-light))
+ :init
+ (ef-themes-select 'ef-maris-light))
+
+(use-package magit
+ :bind ("C-x g" . magit-status)
+ :custom
+ (magit-diff-refine-hunk t)
+ (magit-repository-directories
+ '(("~/workspace" . 1)))
+ (magit-repolist-column-flag-alist
+ '((magit-untracked-files . "N")
+ (magit-unstaged-files . "U")
+ (magit-staged-files . "S")))
+ (magit-repolist-columns
+ '(("Name" 25 magit-repolist-column-ident nil)
+ ("" 3 magit-repolist-column-flag)
+ ("Version" 25 magit-repolist-column-version
+ ((:sort magit-repolist-version<)))
+ ("B<U" 3 magit-repolist-column-unpulled-from-upstream
+ ((:right-align t)
+ (:sort <)))
+ ("B>U" 3 magit-repolist-column-unpushed-to-upstream
+ ((:right-align t)
+ (:sort <)))
+ ("Path" 99 magit-repolist-column-path nil)))
+ (magit-clone-default-directory "~/workspace/")
+ :config
+ ;; show ANSI colors in the process buffer, so it's easier to read what's going on
+ ;; for some reasons if it's in the `:custom' section it does not get set
+ (setq magit-process-finish-apply-ansi-colors t))
+
+(use-package git-link
+ :defines git-link-remote-alist
+ :bind ("C-c Y" . git-link)
+ :commands (git-link git-link-commit git-link-homepage)
+ :custom
+ (git-link-open-in-browser t)
+ :config
+ ;; sets up roblox git enterprise as a git-link handler
+ (add-to-list 'git-link-remote-alist '("github\\.rblx\\.com" git-link-github))
+ (add-to-list 'git-link-commit-remote-alist '("github\\.rblx\\.com" git-link-commit-github)))
+
+(use-package rg
+ :custom
+ (rg-group-result t)
+ (rg-show-columns t)
+ (rg-align-line-number-field-length 3)
+ (rg-align-column-number-field-length 3)
+ (rg-align-line-column-separator "#")
+ (rg-align-position-content-separator "|")
+ (rg-hide-command nil)
+ (rg-align-position-numbers t)
+ (rg-command-line-flags '("--follow")))
+
+(use-package project
+ :config
+ (setq project-mode-line t
+ project-switch-commands
+ '((project-find-file "Find file" f)
+ (project-dired "Dired" d)
+ (project-eshell "Eshell" e)
+ (magit-project-status "Magit" ?m))))
+
+;; `elec-pair' is a built-in minor-mode that enables auto-pairing of parens (or
+;; similar delimiters).
+(use-package elec-pair
+ :hook (prog-mode . electric-pair-mode))
+
+(use-package compile
+ :hook (compilation-filter . ansi-color-compilation-filter)
+ :custom
+ (compilation-always-kill t)
+ (compilation-context-lines 10)
+ (compilation-disable-input t)
+ (compilation-scroll-output 'first-error)
+ (compilation-scroll-output t)
+ (compilation-skip-threshold 2)
+ ;; Save all buffers on M-x `compile'
+ (compilation-ask-about-save nil))
+
+(use-package eldoc
+ :diminish
+ :hook ((emacs-lisp-mode) . eldoc-mode)
+ :custom
+ (eldoc-idle-delay 1)
+ (eldoc-documentation-strategy #'eldoc-documentation-default)
+ ;; Don't resize the echo area if the documentation is longer. This is very
+ ;; distracting when combined with Eglot's highlight functionality.
+ (eldoc-echo-area-use-multiline-p nil))
+
+(use-package tree-sitter
+ :config
+ (global-tree-sitter-mode))
+
+(use-package tree-sitter-langs
+ :after tree-sitter)
+
+(use-package direnv
+ :custom
+ (direnv-always-show-summary nil)
+ :config
+ (direnv-mode))
+
+(use-package emacs-lisp-mode
+ :bind (:map emacs-lisp-mode-map
+ ("C-c C-r" . eval-region)
+ ("C-c C-d" . eval-defun)
+ ("C-c C-b" . eval-buffer))
+ :hook ((emacs-lisp-mode . flymake-mode)))
+
+(use-package eglot
+ :after yasnippet
+ :bind (:map eglot-mode-map
+ ("C-c l a" . eglot-code-actions)
+ ("C-c l r" . eglot-rename)
+ ("C-c l f" . eglot-format-buffer))
+ :hook ((go-mode . eglot-ensure)
+ (python-mode . eglot-ensure)
+ (nix-mode . eglot-ensure))
+ :custom
+ (eglot-send-changes-idle-time 0.1)
+ :config
+ (setq eglot-autoshutdown t
+ ;; Disable logging of events.
+ eglot-events-buffer-size 0)
+ (setq-default eglot-workspace-configuration
+ '(:pylsp (:plugins (:ruff (:enabled t)))
+ :nil (:formatting (:command ["nixfmt"]))
+ :gopls (:usePlaceholders t
+ :staticcheck t
+ :completeUnimported t
+ :matcher "CaseSensitive")))
+
+ ;; uses https://github.com/nix-community/nixd for the LSP server instead of rnix
+ (add-to-list 'eglot-server-programs '(nix-mode . ("nil"))))
+
+(use-package dape
+ :hook
+ ((kill-emacs . dape-breakpoint-save) ; Save breakpoints on quit
+ (dape-compile . kill-buffer) ; Kill compile buffer on build success
+ (dape-display-source . pulse-momentary-highlight-one-line) ; Pulse source line (performance hit)
+ (dape-stopped . dape-info) ; To display info and/or repl buffers on stopped
+ (dape-stopped . dape-repl)
+ (dape-start . (lambda () (save-some-buffers t t)))) ; Save buffers on startup, useful for interpreted languages
+ :config
+ (dape-breakpoint-global-mode)
+ (setq dape-buffer-window-arrangement 'gud)
+ (setq dape-inlay-hints t))
+
+;;; go related configuration
+(use-package go-mode
+ :hook ((go-mode . tree-sitter-hl-mode)
+ (go-mode . (lambda () (setq tab-width 4)))
+ (go-mode . (lambda () (add-hook 'before-save-hook 'eglot-format-buffer nil t))))
+ :bind (:map go-mode-map
+ ("C-c C-c" . compile)))
+
+(use-package gotest
+ :after go-mode
+ :custom
+ (go-test-verbose t))
+
+;;; nix related configuration
+(use-package nix-mode
+ :hook ((nix-mode . (lambda () (add-hook 'before-save-hook 'eglot-format-buffer nil t))))
+ :custom
+ (nix-indent-function 'nix-indent-line))
+
+;;; python related configuration
+(use-package python-mode
+ :hook ((python-mode . tree-sitter-hl-mode)))
+
+(use-package ruby-mode)
+
+;;; flymake related configuration
+(use-package flymake
+ :bind (:prefix "C-c !"
+ :prefix-map flymake-prefix-map
+ ("l" . consult-flymake)
+ ("b" . flymake-show-project-diagnostics)
+ ("n" . flymake-goto-next-error)
+ ("p" . flymake-goto-prev-error))
+ :hook
+ (prog-mode . flymake-mode)
+ :custom
+ (flymake-start-on-save-buffer t)
+ (flymake-fringe-indicator-position 'left-fringe)
+ (flymake-suppress-zero-counters t)
+ (flymake-proc-compilation-prevents-syntax-check t)
+ (flymake-no-changes-timeout 9999)
+ (elisp-flymake-byte-compile-load-path load-path))
+
+;;; JSON related modules
+(use-package json-mode
+ :mode "\\.json\\'")
+
+(use-package json-reformat
+ :after json-mode)
+
+(use-package jq-mode
+ :mode "\\.jq\\'")
+
+;;; hashicorp related modules
+(use-package terraform-mode
+ :mode "\.tf\\'")
+
+(use-package hcl-mode
+ :mode "\.nomad\\'")
+
+;;; TOML related modules
+(use-package toml-mode)
+
+;;; YAML related modules
+(use-package yaml-mode)
+
+;;; docker related modules
+(use-package docker
+ :bind ("C-c d" . docker)
+ :diminish
+ :init
+ (use-package docker-image :commands docker-images)
+ (use-package docker-volume :commands docker-volumes)
+ (use-package docker-network :commands docker-containers)
+ (use-package docker-compose :commands docker-compose)
+
+ (use-package docker-container
+ :commands docker-containers
+ :custom
+ (docker-containers-shell-file-name "/bin/bash")
+ (docker-containers-show-all nil)))
+
+(use-package docker-compose-mode
+ :mode "docker-compose.*\.yml\\'")
+
+(use-package dockerfile-mode
+ :mode "Dockerfile[a-zA-Z.-]*\\'")
+
+(use-package protobuf-mode
+ :mode "\\.proto\\'")
+
+;;; css related configuration
+(use-package css-mode
+ :custom
+ (css-indent-offset 2)
+ (cssm-indent-level 1))
+
+(use-package consult
+ :commands (consult-ripgrep consult-buffer consult-imenu)
+ :bind (("C-c m" . consult-mode-command)
+ ("C-x b" . consult-buffer)
+ ("C-x r b" . consult-bookmark)
+ ("C-x p b" . consult-project-buffer)
+ ("C-c i" . consult-imenu)
+ ("M-g e" . consult-compile-error)
+ ("M-g M-g" . consult-goto-line)
+ ("M-g m" . consult-mark)
+ ("M-g k" . consult-global-mark)))
+
+(use-package corfu
+ :custom
+ (corfu-auto t)
+ :bind ("M-/" . completion-at-point)
+ :hook ((after-init . global-corfu-mode)
+ (global-corfu-mode . corfu-popupinfo-mode)))
+
+(use-package cape
+ :ensure t)
+
+(use-package marginalia
+ :ensure t
+ :hook (after-init . marginalia-mode))
+
+(use-package orderless
+ :demand t
+ :custom
+ (completion-styles '(orderless basic))
+ (completion-category-defaults nil))
+
+(use-package vertico
+ :hook ((after-init . vertico-mode)))
+
+(use-package eshell
+ :commands (eshell eshell-command)
+ :bind (("C-r" . consult-history))
+ :custom
+ (eshell-hist-ignoredups t)
+ (eshell-history-size 50000)
+ (eshell-ls-dired-initial-args '("-h"))
+ (eshell-ls-initial-args "-h")
+ (eshell-ls-exclude-regexp "~\\'")
+ (eshell-save-history-on-exit t)
+ (eshell-stringify-t nil)
+ (eshell-term-name "ansi"))
+
+(use-package yasnippet
+ :hook (after-init . yas-global-mode))
+
+;; Yasnippet Completion At Point Function
+(use-package yasnippet-capf
+ :init (add-to-list 'completion-at-point-functions #'yasnippet-capf))
+
+(report-time-since-load)
diff --git a/nix/users/fcuny/dev.nix b/nix/users/fcuny/dev.nix
index 0202747..f95c04d 100644
--- a/nix/users/fcuny/dev.nix
+++ b/nix/users/fcuny/dev.nix
@@ -29,12 +29,6 @@
rustup
];
- programs.emacs = {
- enable = true;
- # https://github.com/NixOS/nixpkgs/issues/395169
- package = pkgs.emacs.override { withNativeCompilation = false; };
- };
-
programs.go = {
enable = true;
goPath = ".local/share/pkg.go";
diff --git a/nix/users/fcuny/emacs.nix b/nix/users/fcuny/emacs.nix
new file mode 100644
index 0000000..9c3b73b
--- /dev/null
+++ b/nix/users/fcuny/emacs.nix
@@ -0,0 +1,69 @@
+{ pkgs, ... }:
+let
+ myEmacs = pkgs.emacsWithPackagesFromUsePackage {
+ # TODO: https://github.com/NixOS/nixpkgs/issues/395169
+ package = pkgs.emacs.override { withNativeCompilation = false; };
+ config = ./configs/emacs/init.el;
+ defaultInitFile = true;
+ extraEmacsPackages =
+ epkgs: with epkgs; [
+ # completion
+ cape
+ consult
+ corfu
+ marginalia
+ orderless
+ vertico
+
+ # development
+ dape
+ git-link
+ direnv
+ docker
+ docker-compose-mode
+ dockerfile-mode
+ go-mode
+ gotest
+ hcl-mode
+ jq-mode
+ json-mode
+ json-reformat
+ magit
+ nix-mode
+ protobuf-mode
+ terraform-mode
+ toml-mode
+ tree-sitter
+ tree-sitter-langs
+ treesit-grammars.with-all-grammars
+ yaml-mode
+
+ # misc
+ ef-themes
+ exec-path-from-shell
+ rg
+ yasnippet
+ yasnippet-capf
+ ];
+ };
+in
+{
+ home.file.".config/emacs/early-init.el".source = ./configs/emacs/early-init.el;
+ home.file.".config/emacs/init.el".source = ./configs/emacs/init.el;
+
+ programs.emacs = {
+ enable = true;
+ package = myEmacs;
+ };
+
+ home.packages = with pkgs; [
+ aspell
+ aspellDicts.en
+ aspellDicts.en-science
+ aspellDicts.en-computers
+ ];
+
+ home.sessionVariables = {
+ EDITOR = "emacsclient -t";
+ };
+}
diff --git a/nix/users/fcuny/home-manager.nix b/nix/users/fcuny/home-manager.nix
index 0a3f6fc..7750642 100644
--- a/nix/users/fcuny/home-manager.nix
+++ b/nix/users/fcuny/home-manager.nix
@@ -8,6 +8,7 @@
imports =
[
+ ./emacs.nix
./shell.nix
./ssh.nix
./git.nix
diff --git a/nix/users/fcuny/shell.nix b/nix/users/fcuny/shell.nix
index 57017e9..efcbae5 100644
--- a/nix/users/fcuny/shell.nix
+++ b/nix/users/fcuny/shell.nix
@@ -149,11 +149,9 @@ in
};
home.sessionVariables = {
- EDITOR = "code --wait";
LESS = "-FRSXM";
LESSCHARSET = "utf-8";
PAGER = "less";
SHELL = "${pkgs.fish}/bin/fish";
- VISUAL = "code --wait";
};
}