Simplified emacs setup and made it default
This commit is contained in:
56
hosts/config/emacs/emacs.el
Normal file
56
hosts/config/emacs/emacs.el
Normal file
@@ -0,0 +1,56 @@
|
||||
(eval-when-compile
|
||||
(require 'use-package))
|
||||
|
||||
;; load some packages
|
||||
|
||||
(use-package company
|
||||
:bind ("<C-tab>" . company-complete)
|
||||
:diminish company-mode
|
||||
:commands (company-mode global-company-mode)
|
||||
:defer 1
|
||||
:config
|
||||
(global-company-mode))
|
||||
|
||||
(use-package counsel
|
||||
:commands (counsel-descbinds)
|
||||
:bind (([remap execute-extended-command] . counsel-M-x)
|
||||
("C-x C-f" . counsel-find-file)
|
||||
("C-c g" . counsel-git)
|
||||
("C-c j" . counsel-git-grep)
|
||||
("C-c k" . counsel-ag)
|
||||
("C-x l" . counsel-locate)
|
||||
("M-y" . counsel-yank-pop)))
|
||||
|
||||
(use-package flycheck
|
||||
:defer 2
|
||||
:config (global-flycheck-mode))
|
||||
|
||||
(use-package ivy
|
||||
:defer 1
|
||||
:bind (("C-c C-r" . ivy-resume)
|
||||
("C-x C-b" . ivy-switch-buffer)
|
||||
:map ivy-minibuffer-map
|
||||
("C-j" . ivy-call))
|
||||
:diminish ivy-mode
|
||||
:commands ivy-mode
|
||||
:config
|
||||
(ivy-mode 1))
|
||||
|
||||
(use-package magit
|
||||
:defer
|
||||
:if (executable-find "git")
|
||||
:bind (("C-x g" . magit-status)
|
||||
("C-x G" . magit-dispatch-popup))
|
||||
:init
|
||||
(setq magit-completing-read-function 'ivy-completing-read))
|
||||
|
||||
(use-package projectile
|
||||
:commands projectile-mode
|
||||
:bind-keymap ("C-c p" . projectile-command-map)
|
||||
:defer 5
|
||||
:config
|
||||
(projectile-global-mode))
|
||||
|
||||
|
||||
|
||||
(global-set-key (kbd "C-.") 'set-mark-command)
|
||||
@@ -75,7 +75,19 @@ in
|
||||
environment.systemPackages =
|
||||
with pkgs;
|
||||
[
|
||||
emacs-unstable
|
||||
# Emacs with automatic package management from overlay
|
||||
(emacsWithPackagesFromUsePackage {
|
||||
config = ../config/emacs/emacs.el;
|
||||
defaultInitFile = true;
|
||||
package = emacs-unstable;
|
||||
alwaysEnsure = true;
|
||||
extraEmacsPackages = epkgs: with epkgs; [
|
||||
magit
|
||||
company
|
||||
nix-mode
|
||||
use-package
|
||||
];
|
||||
})
|
||||
]
|
||||
++ (import ../../modules/shared/packages.nix { inherit pkgs; })
|
||||
|
||||
|
||||
@@ -334,6 +334,20 @@ in
|
||||
];
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
# Emacs with automatic package management from overlay
|
||||
(emacsWithPackagesFromUsePackage {
|
||||
config = ../config/emacs/emacs.el;
|
||||
defaultInitFile = true;
|
||||
package = emacs-unstable;
|
||||
alwaysEnsure = true;
|
||||
extraEmacsPackages =
|
||||
epkgs: with epkgs; [
|
||||
magit
|
||||
company
|
||||
nix-mode
|
||||
use-package
|
||||
];
|
||||
})
|
||||
gitAndTools.gitFull
|
||||
inetutils
|
||||
];
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,142 +0,0 @@
|
||||
;; -------------------------
|
||||
;; Variable Declarations
|
||||
;; -------------------------
|
||||
(defvar org-config-file "~/.local/share/src/nixos-config/modules/shared/config/emacs/config.org")
|
||||
(defvar default-config-file "~/.emacs.d/default-config.org")
|
||||
(defvar default-config-url "https://git.kolkman.org/olaf/nixos-config_to_rule_them_all/raw/branch/main/modules/shared/config/emacs/config.org")
|
||||
|
||||
;; -------------------------
|
||||
;; Package Manager Setup
|
||||
;; -------------------------
|
||||
(require 'package)
|
||||
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
|
||||
("gnu" . "http://elpa.gnu.org/packages/")))
|
||||
|
||||
(unless (assoc-default "melpa" package-archives)
|
||||
(message "Warning: MELPA source not found. Adding MELPA to package-archives.")
|
||||
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t))
|
||||
(unless (assoc-default "org" package-archives)
|
||||
(message "Warning: Org source not found. Adding Org to package-archives.")
|
||||
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t))
|
||||
|
||||
(setq package-enable-at-startup nil)
|
||||
|
||||
;; -------------------------
|
||||
;; Use-Package Setup
|
||||
;; -------------------------
|
||||
(unless (package-installed-p 'use-package)
|
||||
(package-initialize)
|
||||
(if (package-install 'use-package)
|
||||
(message "use-package installed successfully.")
|
||||
(error "Error: Failed to install use-package."))
|
||||
(setq use-package-verbose t)
|
||||
(setq use-package-always-ensure t)
|
||||
(require 'use-package))
|
||||
|
||||
;; -------------------------
|
||||
;; Environment Variables Setup
|
||||
;; -------------------------
|
||||
(use-package exec-path-from-shell
|
||||
:if (memq window-system '(mac ns x))
|
||||
:config
|
||||
(setq exec-path-from-shell-variables '("PATH" "GOPATH" "PNPM_HOME"))
|
||||
(if (exec-path-from-shell-initialize)
|
||||
(message "Environment variables initialized successfully.")
|
||||
(error "Error: Failed to initialize environment variables.")))
|
||||
|
||||
(when (daemonp)
|
||||
(exec-path-from-shell-initialize))
|
||||
|
||||
;; -------------------------
|
||||
;; Straight.el Setup
|
||||
;; -------------------------
|
||||
(setq straight-repository-branch "develop")
|
||||
(defvar bootstrap-version)
|
||||
(let ((bootstrap-file
|
||||
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
|
||||
(bootstrap-version 6))
|
||||
(unless (file-exists-p bootstrap-file)
|
||||
(with-current-buffer
|
||||
(url-retrieve-synchronously
|
||||
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
|
||||
'silent 'inhibit-cookies)
|
||||
(goto-char (point-max))
|
||||
(eval-print-last-sexp)))
|
||||
(if (load bootstrap-file nil 'nomessage)
|
||||
(message "Straight.el loaded successfully.")
|
||||
(error "Error: Failed to load Straight.el.")))
|
||||
|
||||
(setq straight-use-package-by-default t)
|
||||
(package-initialize)
|
||||
|
||||
;; -------------------------
|
||||
;; Window and UI Setup
|
||||
;; -------------------------
|
||||
(defun dl/window-setup ()
|
||||
(condition-case nil
|
||||
(progn
|
||||
(column-number-mode)
|
||||
(scroll-bar-mode 0)
|
||||
(menu-bar-mode -1)
|
||||
(tool-bar-mode 0)
|
||||
(winner-mode 1)
|
||||
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
|
||||
(add-to-list 'default-frame-alist '(ns-appearance . dark))
|
||||
(setq ns-use-proxy-icon nil)
|
||||
(setq frame-title-format nil)
|
||||
(message "Window and UI setup completed successfully."))
|
||||
(error (message "Error occurred in Window and UI setup."))))
|
||||
(dl/window-setup)
|
||||
|
||||
;; -------------------------
|
||||
;; Org Mode Setup
|
||||
;; -------------------------
|
||||
(defun dl/org-mode-setup ()
|
||||
(condition-case nil
|
||||
(progn
|
||||
(org-indent-mode)
|
||||
(variable-pitch-mode 1)
|
||||
(auto-fill-mode 0)
|
||||
(visual-line-mode 1)
|
||||
(setq evil-auto-indent nil)
|
||||
(message "Org mode setup completed successfully."))
|
||||
(error (message "Error occurred in Org mode setup."))))
|
||||
|
||||
(use-package org
|
||||
:defer t
|
||||
:hook (org-mode . dl/org-mode-setup)
|
||||
:config
|
||||
(setq org-edit-src-content-indentation 2
|
||||
org-ellipsis " ▾"
|
||||
org-hide-emphasis-markers t
|
||||
org-hide-block-startup nil)
|
||||
:bind (("C-c a" . org-agenda)))
|
||||
|
||||
;; -------------------------
|
||||
;; Default Config Download
|
||||
;; -------------------------
|
||||
(defun dl/download-default-config ()
|
||||
(condition-case nil
|
||||
(progn
|
||||
(unless (file-exists-p default-config-file)
|
||||
(url-retrieve default-config-url
|
||||
(lambda (_status)
|
||||
;; delete-region removes the HTTP headers from the downloaded content.
|
||||
(delete-region (point-min) (1+ url-http-end-of-headers))
|
||||
;; save the contents of the buffer to the file.
|
||||
(write-file default-config-file)))
|
||||
(message "Default configuration downloaded successfully.")))
|
||||
(error (message "Error occurred while downloading the default configuration."))))
|
||||
|
||||
;; -------------------------
|
||||
;; Load Org Config or Default
|
||||
;; -------------------------
|
||||
(condition-case nil
|
||||
(progn
|
||||
(unless (file-exists-p org-config-file)
|
||||
(dl/download-default-config))
|
||||
(if (file-exists-p org-config-file)
|
||||
(org-babel-load-file org-config-file)
|
||||
(org-babel-load-file default-config-file))
|
||||
(message "Configuration loaded successfully."))
|
||||
(error (message "Error occurred while loading the configuration.")))
|
||||
@@ -9,8 +9,4 @@
|
||||
# text = githubPublicKey;
|
||||
# };
|
||||
|
||||
# Initializes Emacs with org-mode so we can tangle the main config
|
||||
".emacs.d/init.el" = {
|
||||
text = builtins.readFile ../shared/config/emacs/init.el;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user