first commit
This commit is contained in:
49
profiles/desktop/.emacs.d/modules/common.el
Normal file
49
profiles/desktop/.emacs.d/modules/common.el
Normal file
@@ -0,0 +1,49 @@
|
||||
;;; common.el --- common stuff -*- lexical-binding: t -*-
|
||||
;;; Commentary:
|
||||
|
||||
;; add directory containing own stuff and helper utilities to load path
|
||||
(add-to-list 'load-path "~/.emacs.d/lisp")
|
||||
|
||||
;; keep ~/.emacs.d clean
|
||||
(setq no-littering-etc-directory "~/.emacs.d/")
|
||||
(let ((var "~/.cache/emacs/")
|
||||
(etc "~/.emacs.d/"))
|
||||
(make-directory var t)
|
||||
(setq no-littering-var-directory var)
|
||||
(setq lock-file-name-transforms `((".*" ,(concat var "lock-files/") t)))
|
||||
(setq custom-file (concat etc "lisp/custom-settings.el")))
|
||||
(require 'no-littering)
|
||||
(no-littering-theme-backups)
|
||||
|
||||
;; load settings set by customize
|
||||
(require 'custom-settings)
|
||||
|
||||
;; enable integration with pass
|
||||
(auth-source-pass-enable)
|
||||
;; copied from https://systemcrafters.net/emacs-tips/using-encrypted-passwords/
|
||||
(defun pt/lookup-password (&rest keys)
|
||||
(let ((result (apply #'auth-source-search keys)))
|
||||
(if result
|
||||
(funcall (plist-get (car result) :secret))
|
||||
nil)))
|
||||
|
||||
;; useful stuff
|
||||
(defmacro fmt (str)
|
||||
"Elisp string interpolation.
|
||||
Example:
|
||||
(fmt \"My name is #{user-full-name}, I am running Emacs #{(if (display-graphic-p) \\\"with a GUI\\\" \\\"in a terminal\\\".)}\""
|
||||
(let ((exprs nil))
|
||||
(with-temp-buffer
|
||||
(insert str)
|
||||
(goto-char 1)
|
||||
(while (re-search-forward "#{" nil t 1)
|
||||
(let ((here (point))
|
||||
(emptyp (eql (char-after) ?})))
|
||||
(unless emptyp (push (read (buffer-substring (point) (progn (forward-sexp 1) (point)))) exprs))
|
||||
(delete-region (- here 2) (progn (search-forward "}") (point)))
|
||||
(unless emptyp (insert "%s"))
|
||||
(ignore-errors (forward-char 1))))
|
||||
(append (list 'format (buffer-string)) (reverse exprs)))))
|
||||
|
||||
(provide 'common)
|
||||
;;; common.el ends here
|
||||
58
profiles/desktop/.emacs.d/modules/editing.el
Normal file
58
profiles/desktop/.emacs.d/modules/editing.el
Normal file
@@ -0,0 +1,58 @@
|
||||
;;; editing.el --- core editor config -*- lexical-binding: t -*-
|
||||
;;; Commentary:
|
||||
|
||||
;; follow symlinks
|
||||
(setq vc-follow-symlinks t)
|
||||
|
||||
;; complete brackets automatically
|
||||
(electric-pair-mode 1)
|
||||
(setq electric-pair-preserve-balance nil)
|
||||
|
||||
;; make C-k kill entire line when I'm at the start of line
|
||||
(setq kill-whole-line t)
|
||||
|
||||
;; key binding for copying lines
|
||||
(defun copy-line (arg)
|
||||
"Copy lines (as many as prefix argument) in the kill ring.
|
||||
Ease of use features:
|
||||
- Move to start of next line.
|
||||
- Appends the copy on sequential calls.
|
||||
- Use newline as last char even on the last line of the buffer.
|
||||
- If region is active, copy its lines."
|
||||
(interactive "p")
|
||||
(let ((beg (line-beginning-position))
|
||||
(end (line-end-position arg)))
|
||||
(when mark-active
|
||||
(if (> (point) (mark))
|
||||
(setq beg (save-excursion (goto-char (mark)) (line-beginning-position)))
|
||||
(setq end (save-excursion (goto-char (mark)) (line-end-position)))))
|
||||
(if (eq last-command 'copy-line)
|
||||
(kill-append (buffer-substring beg end) (< end beg))
|
||||
(kill-ring-save beg end)))
|
||||
(kill-append "\n" nil)
|
||||
(beginning-of-line (or (and arg (1+ arg)) 2))
|
||||
(if (and arg (not (= 1 arg))) (message "%d lines copied" arg)))
|
||||
(global-set-key "\C-cc" #'copy-line)
|
||||
|
||||
;; key binding for duplicating lines
|
||||
(defun duplicate-current-line (&optional n)
|
||||
"Duplicate current line, make more than 1 copy given a numeric argument."
|
||||
(interactive "p")
|
||||
(save-excursion
|
||||
(let ((nb (or n 1))
|
||||
(current-line (thing-at-point 'point)))
|
||||
;; when on last line, insert a newline first
|
||||
(when (or (= 1 (forward-line 1)) (eq (point) (point-max)))
|
||||
(insert "\n"))
|
||||
;; now insert as many time as requested
|
||||
(while (> n 0)
|
||||
(insert current-line)
|
||||
(cl-decf n)))))
|
||||
(global-set-key (kbd "\C-cd") #'duplicate-current-line)
|
||||
|
||||
;; persistent undo history
|
||||
(use-package undo-tree
|
||||
:hook (after-init . global-undo-tree-mode))
|
||||
|
||||
(provide 'editing)
|
||||
;;; editing.el ends here
|
||||
46
profiles/desktop/.emacs.d/modules/erc.el
Normal file
46
profiles/desktop/.emacs.d/modules/erc.el
Normal file
@@ -0,0 +1,46 @@
|
||||
;;; erc.el --- erc config -*- lexical-binding: t -*-
|
||||
;;; Commentary:
|
||||
|
||||
(defun pt/erc-connect-network (network)
|
||||
"Connect to Libera IRC network."
|
||||
(erc-tls :server "paraboletancza.org"
|
||||
:port 6697
|
||||
:user (fmt "whiteman808/#{network}")
|
||||
:password (pt/lookup-password :host "znc.paraboletancza.org" :user "whiteman808")
|
||||
:full-name "whiteman808"))
|
||||
|
||||
(use-package erc
|
||||
:custom
|
||||
;; user data
|
||||
(erc-nick "whiteman808")
|
||||
(erc-user-full-name "whiteman808")
|
||||
;; protect me from accidentally sending excess lines
|
||||
(erc-inhibit-multiline-input t)
|
||||
(erc-send-whitespace-lines t)
|
||||
(erc-ask-about-multiline-input t)
|
||||
;; scroll all windows to prompt when submitting input
|
||||
(erc-scrolltobottom-all t)
|
||||
;; reconnect automatically using a fancy strategy
|
||||
(erc-server-reconnect-function #'erc-server-delayed-check-reconnect)
|
||||
(erc-server-reconnect-timeout 30)
|
||||
;; show new buffers in the current window instead of a split
|
||||
(erc-interactive-display 'buffer)
|
||||
;; highlight references to me
|
||||
(erc-keywords '("whiteman808" "whiteman809"))
|
||||
:hook
|
||||
;; automatically connect to irc
|
||||
;; (after-init . (lambda nil
|
||||
;; (pt/erc-connect-network "Libera")
|
||||
;; (pt/erc-connect-network "PIRC")))
|
||||
;; enable matching keywords
|
||||
(erc-mode . erc-match-mode)
|
||||
;; insert a newline when I hit <RET> at the prompt, and prefer
|
||||
;; something more deliberate for actually sending messages
|
||||
;; :bind (:map erc-mode-map
|
||||
;; ("RET" . nil)
|
||||
;; ("C-c C-c" . #'erc-send-current-line))
|
||||
;; emphasize buttonized text in notices
|
||||
:custom-face (erc-notice-face ((t (:slant italic :weight unspecified)))))
|
||||
|
||||
(provide 'erc)
|
||||
;;; erc.el ends here
|
||||
11
profiles/desktop/.emacs.d/modules/misc.el
Normal file
11
profiles/desktop/.emacs.d/modules/misc.el
Normal file
@@ -0,0 +1,11 @@
|
||||
;;; misc.el --- various useful stuff -*- lexical-binding: t -*-
|
||||
;;; Commentary:
|
||||
|
||||
;; stuff related to window manager
|
||||
(use-package i3wm-config-mode
|
||||
:config
|
||||
(add-to-list 'auto-mode-alist '("/sway/.*config.*/" . i3wm-config-mode))
|
||||
(add-to-list 'auto-mode-alist '("/sway/config\\'" . i3wm-config-mode)))
|
||||
|
||||
(provide 'misc)
|
||||
;;; misc.el ends here
|
||||
30
profiles/desktop/.emacs.d/modules/org-mode.el
Normal file
30
profiles/desktop/.emacs.d/modules/org-mode.el
Normal file
@@ -0,0 +1,30 @@
|
||||
;;; org-mode.el --- org mode config -*- lexical-binding: t -*-
|
||||
;;; Commentary:
|
||||
|
||||
;; essential stuff
|
||||
(use-package org
|
||||
:hook
|
||||
(org-mode . (lambda nil
|
||||
(when (display-graphic-p)
|
||||
(org-indent-mode 1))))
|
||||
;; (org-mode . (lambda nil
|
||||
;; (push '("[ ]" . "") prettify-symbols-alist)
|
||||
;; (push '("[X]" . "" ) prettify-symbols-alist)
|
||||
;; (push '("[-]" . "" ) prettify-symbols-alist)
|
||||
;; (prettify-symbols-mode)))
|
||||
:custom
|
||||
(org-hide-leading-stars t)
|
||||
(org-hide-emphasis-markers t))
|
||||
|
||||
;; org-modern
|
||||
(use-package org-modern
|
||||
:custom
|
||||
(org-modern-list
|
||||
'((?- . "•")
|
||||
(?+ . "‣")))
|
||||
:hook
|
||||
(org-mode . org-modern-mode)
|
||||
(org-agenda-finalize . org-modern-agenda))
|
||||
|
||||
(provide 'org-mode)
|
||||
;;; org-mode.el ends here
|
||||
26
profiles/desktop/.emacs.d/modules/package-manager.el
Normal file
26
profiles/desktop/.emacs.d/modules/package-manager.el
Normal file
@@ -0,0 +1,26 @@
|
||||
;;; package-manager.el --- bootstrap straight.el -*- lexical-binding: t -*-
|
||||
;;; Commentary:
|
||||
|
||||
;; bootstrap straight.el
|
||||
(defvar bootstrap-version)
|
||||
(let ((bootstrap-file
|
||||
(expand-file-name
|
||||
"straight/repos/straight.el/bootstrap.el"
|
||||
(or (bound-and-true-p straight-base-dir)
|
||||
user-emacs-directory)))
|
||||
(bootstrap-version 7))
|
||||
(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)))
|
||||
(load bootstrap-file nil 'nomessage))
|
||||
|
||||
;; configure package manager
|
||||
(straight-use-package 'use-package)
|
||||
(setq straight-use-package-by-default t)
|
||||
|
||||
(provide 'package-manager)
|
||||
;;; package-manager.el ends here
|
||||
171
profiles/desktop/.emacs.d/modules/programming.el
Normal file
171
profiles/desktop/.emacs.d/modules/programming.el
Normal file
@@ -0,0 +1,171 @@
|
||||
;;; programming.el --- core programming settings -*- lexical-binding: t -*-
|
||||
;;; Commentary:
|
||||
|
||||
;; default indentation settings
|
||||
(setq-default indent-tabs-mode nil)
|
||||
(setq-default tab-width 4)
|
||||
|
||||
;; code diagnostics
|
||||
(use-package flycheck
|
||||
:custom
|
||||
(flycheck-display-error-delay 1.0)
|
||||
:hook
|
||||
(prog-mode . (lambda nil
|
||||
(when (not (derived-mode-p 'emacs-lisp-mode))
|
||||
(flycheck-mode))))
|
||||
(yaml-mode . flycheck-mode))
|
||||
|
||||
;; lsp support
|
||||
(use-package lsp-mode
|
||||
:custom
|
||||
(lsp-keymap-prefix "C-c l")
|
||||
(lsp-auto-guess-root t)
|
||||
:hook
|
||||
(prog-mode . (lambda nil
|
||||
(when (not (derived-mode-p 'emacs-lisp-mode))
|
||||
(lsp-deferred))))
|
||||
(TeX-mode . lsp-deferred)
|
||||
(lsp-mode . lsp-enable-which-key-integration))
|
||||
|
||||
(use-package lsp-ui
|
||||
:custom
|
||||
(lsp-ui-sideline-show-diagnostics t)
|
||||
(lsp-ui-sideline-show-hover nil)
|
||||
(lsp-ui-sideline-show-code-actions nil)
|
||||
(lsp-ui-sideline-update-mode 'line)
|
||||
(lsp-ui-peek-enable t)
|
||||
(lsp-ui-peek-show-directory t)
|
||||
(lsp-ui-doc-enable t)
|
||||
(lsp-ui-doc-position 'top)
|
||||
(lsp-ui-doc-side 'right)
|
||||
(lsp-ui-doc-show-with-cursor nil)
|
||||
(lsp-ui-doc-show-with-mouse nil)
|
||||
:bind
|
||||
(:map lsp-ui-mode-map
|
||||
([remap xref-find-definitions] . #'lsp-ui-peek-find-definitions)
|
||||
([remap xref-find-references] . #'lsp-ui-peek-find-references)
|
||||
("C-c l d" . #'lsp-ui-doc-toggle)))
|
||||
|
||||
;; autocompletion
|
||||
(defun pt/company-complete-func nil
|
||||
"Insert the common part of all candidates, or insert <TAB>."
|
||||
(interactive)
|
||||
(when (company-manual-begin)
|
||||
(let ((tick (buffer-chars-modified-tick)))
|
||||
(call-interactively #'company-complete-common)
|
||||
(when (eq tick (buffer-chars-modified-tick))
|
||||
(call-interactively #'company-abort)
|
||||
(call-interactively (key-binding "\t"))))))
|
||||
(use-package company
|
||||
:config
|
||||
(define-key company-active-map (kbd "<tab>") #'pt/company-complete-func)
|
||||
(define-key company-active-map (kbd "<TAB>") #'pt/company-complete-func)
|
||||
(define-key company-active-map (kbd "<backtab>") nil)
|
||||
(define-key company-active-map (kbd "C-p") #'company-cycle-backward)
|
||||
(define-key company-active-map (kbd "C-n") (lambda (&optional arg)
|
||||
(interactive "p")
|
||||
(let ((company-selection-wrap-around t))
|
||||
(call-interactively #'company-select-next))))
|
||||
:custom
|
||||
(company-minimum-prefix-length 1)
|
||||
(company-idle-delay (lambda () (if (company-in-string-or-comment) nil 0.3)))
|
||||
:hook
|
||||
(prog-mode . company-mode)
|
||||
(yaml-mode . company-mode)
|
||||
(TeX-mode . company-mode)
|
||||
(text-mode . company-mode)
|
||||
(conf-mode . company-mode))
|
||||
|
||||
;; project management
|
||||
(use-package projectile
|
||||
:commands projectile-mode
|
||||
:hook (after-init . projectile-mode)
|
||||
:bind
|
||||
(:map projectile-mode-map
|
||||
("C-c p" . #'projectile-command-map)))
|
||||
|
||||
;; web development
|
||||
(use-package web-mode
|
||||
:custom
|
||||
(web-mode-enable-auto-closing t)
|
||||
(web-mode-enable-auto-pairing t)
|
||||
(web-mode-enable-css-colorization t)
|
||||
(web-mode-markup-indent-offset 2)
|
||||
(web-mode-css-indent-offset 2)
|
||||
(web-mode-code-indent-offset 2)
|
||||
(web-mode-style-padding 0)
|
||||
(web-mode-script-padding 0)
|
||||
:mode
|
||||
(("\\.html?\\'" . web-mode)
|
||||
("\\.phtml\\'" . web-mode)
|
||||
("\\.php\\'" . web-mode)
|
||||
("\\.tpl\\'" . web-mode)
|
||||
("\\.[agj]sp\\'" . web-mode)
|
||||
("\\.as[cp]x\\'" . web-mode)
|
||||
("\\.erb\\'" . web-mode)
|
||||
("\\.mustache\\'" . web-mode)
|
||||
("\\.djhtml\\'" . web-mode)))
|
||||
|
||||
;; formatting code
|
||||
(use-package format-all
|
||||
:commands format-all-mode
|
||||
:hook (prog-mode . format-all-mode)
|
||||
:bind ("C-c f" . format-all-buffer)
|
||||
:config
|
||||
(define-format-all-formatter autopep8
|
||||
(:executable "autopep8")
|
||||
(:install "pip install autopep8")
|
||||
(:languages "Python")
|
||||
(:features)
|
||||
(:format (format-all--buffer-easy executable "-")))
|
||||
(define-format-all-formatter dockerfmt
|
||||
(:executable "dockerfmt")
|
||||
(:install "go install github.com/reteps/dockerfmt@latest")
|
||||
(:languages "Dockerfile")
|
||||
(:features)
|
||||
(:format (format-all--buffer-easy executable)))
|
||||
(setq-default format-all-formatters
|
||||
'(("C" (clang-format))
|
||||
("C++" (clang-format))
|
||||
("Shell" (beautysh))
|
||||
("HTML" (prettier))
|
||||
("XHTML" (prettier))
|
||||
("XML" (prettier))
|
||||
("CSS" (prettier))
|
||||
("Less" (prettier))
|
||||
("SCSS" (prettier))
|
||||
("JavaScript" (prettier))
|
||||
("JSON" (prettier))
|
||||
("JSX" (prettier))
|
||||
("TypeScript" (prettier))
|
||||
("TSX" (prettier))
|
||||
("YAML" (prettier))
|
||||
("TOML" (prettier))
|
||||
("LaTeX" (latexindent))
|
||||
("Lua" (stylua))
|
||||
("PHP" (prettier))
|
||||
("Python" (autopep8) (isort))
|
||||
("Perl" (perltidy))
|
||||
("Markdown" (prettier))
|
||||
("Dockerfile" (dockerfmt))
|
||||
("SQL" (pgformatter))
|
||||
("Nginx" (nginxfmt)))))
|
||||
|
||||
;; highlight words like todo
|
||||
(use-package hl-todo
|
||||
:custom
|
||||
(hl-todo-keyword-faces
|
||||
'(("FIXME" error bold)
|
||||
("TODO" org-todo)
|
||||
("DONE" org-done)
|
||||
("NOTE" bold)))
|
||||
:hook (prog-mode . hl-todo-mode))
|
||||
|
||||
;; various useful modes
|
||||
(use-package dockerfile-mode :commands dockerfile-mode)
|
||||
(use-package systemd :commands systemd-mode)
|
||||
(use-package nginx-mode :commands nginx-mode)
|
||||
(use-package yaml-mode :commands yaml-mode)
|
||||
|
||||
(provide 'programming)
|
||||
;;; programming.el ends here
|
||||
22
profiles/desktop/.emacs.d/modules/sysadm.el
Normal file
22
profiles/desktop/.emacs.d/modules/sysadm.el
Normal file
@@ -0,0 +1,22 @@
|
||||
;;; sysadm.el --- system administration stuff -*- lexical-binding: t -*-
|
||||
;;; Commentary:
|
||||
|
||||
;; terminal
|
||||
(use-package eat
|
||||
:straight (eat :type git
|
||||
:host codeberg
|
||||
:repo "akib/emacs-eat"
|
||||
:files ("*.el" ("term" "term/*.el") "*.texi"
|
||||
"*.ti" ("terminfo/e" "terminfo/e/*")
|
||||
("terminfo/65" "terminfo/65/*")
|
||||
("integration" "integration/*")
|
||||
(:exclude ".dir-locals.el" "*-tests.el"))))
|
||||
;; (use-package vterm)
|
||||
|
||||
;; developing pkgbuilds for arch linux
|
||||
(use-package pkgbuild-mode
|
||||
:commands pkgbuild-mode
|
||||
:mode "/PKGBUILD$")
|
||||
|
||||
(provide 'sysadm)
|
||||
;;; sysadm.el ends here
|
||||
89
profiles/desktop/.emacs.d/modules/user-interface.el
Normal file
89
profiles/desktop/.emacs.d/modules/user-interface.el
Normal file
@@ -0,0 +1,89 @@
|
||||
;;; user-interface.el --- user interface config -*- lexical-binding: t -*-
|
||||
;;; Commentary:
|
||||
|
||||
;; don't show startup message
|
||||
(setq inhibit-startup-screen t)
|
||||
|
||||
;; improve user interface
|
||||
(menu-bar-mode -1)
|
||||
(tool-bar-mode -1)
|
||||
(scroll-bar-mode -1)
|
||||
(defalias 'yes-or-no-p 'y-or-n-p) ; for portability
|
||||
(setopt use-short-answers t)
|
||||
|
||||
;; enable copy-pasting outside of emacs
|
||||
(setq x-select-enable-clipboard t)
|
||||
|
||||
;; disable ring bell sound
|
||||
(setq ring-bell-function 'ignore)
|
||||
|
||||
;; prefer vertical splits
|
||||
(setq split-width-threshold nil)
|
||||
|
||||
;; automatically wrap lines
|
||||
(global-visual-line-mode 1)
|
||||
|
||||
;; set default font
|
||||
(set-face-attribute 'default nil
|
||||
:family "Hack"
|
||||
:height 140
|
||||
:weight 'normal
|
||||
:width 'normal)
|
||||
(set-fontset-font t 'unicode (font-spec :family "Hack Nerd Font Mono" :height 200) nil)
|
||||
(set-fontset-font t 'symbol (font-spec :family "Font Awesome 7 Free" :height 200) nil)
|
||||
|
||||
;; color scheme
|
||||
(use-package catppuccin-theme
|
||||
:custom (catppuccin-flavor 'mocha)
|
||||
:config
|
||||
(set-frame-parameter nil 'alpha-background 80)
|
||||
(add-to-list 'default-frame-alist '(alpha-background . 80))
|
||||
(if (daemonp)
|
||||
(add-hook 'after-make-frame-functions (lambda (frame)
|
||||
(select-frame frame)
|
||||
(catppuccin-set-color 'base "unspecified-bg" 'mocha)
|
||||
(load-theme 'catppuccin t)))
|
||||
(progn (catppuccin-set-color 'base "#000000" 'mocha)
|
||||
(load-theme 'catppuccin :no-confirm))))
|
||||
|
||||
;; set transparency when running emacs in terminal
|
||||
(defun on-after-init ()
|
||||
(unless (display-graphic-p (selected-frame))
|
||||
(set-face-background 'default "unspecified-bg" (selected-frame))))
|
||||
(add-hook 'window-setup-hook 'on-after-init)
|
||||
|
||||
;; mode line
|
||||
(use-package doom-modeline
|
||||
:hook (after-init . doom-modeline-mode))
|
||||
|
||||
;; set cursor type and disable cursor blinking
|
||||
(blink-cursor-mode -1)
|
||||
(setq-default cursor-type '(hbar . 1))
|
||||
|
||||
;; display line numbers
|
||||
(setq display-line-numbers-width-start t)
|
||||
(dolist (mode '(prog-mode-hook
|
||||
yaml-mode-hook
|
||||
TeX-mode-hook
|
||||
markdown-mode-hook
|
||||
org-mode-hook
|
||||
conf-mode-hook))
|
||||
(add-hook mode #'display-line-numbers-mode))
|
||||
|
||||
;; enable commands hinting when pressing keys
|
||||
(which-key-mode 1)
|
||||
|
||||
;; better help
|
||||
(use-package helpful
|
||||
:bind
|
||||
(("C-h f" . helpful-callable)
|
||||
("C-h v" . helpful-variable)
|
||||
("C-h k" . helpful-key)
|
||||
("C-h x" . helpful-command)))
|
||||
|
||||
;; better switching between windows
|
||||
(use-package ace-window
|
||||
:bind ("M-o" . ace-window))
|
||||
|
||||
(provide 'user-interface)
|
||||
;;; user-interface.el ends here
|
||||
Reference in New Issue
Block a user