initial commit

This commit is contained in:
MitchMarq42 2022-06-19 14:13:36 -08:00
commit 0602465dd1
10 changed files with 1282 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*

240
README.org Normal file
View File

@ -0,0 +1,240 @@
#+TITLE: Emacs Configuration
#+PROPERTY: header-args:elisp :mkdirp yes
* Emacs Configuration
Oh boy.
I don't even know what to say about this. I want to believe in the vim cult, but
emacs just has me under its thrall. It's precisely what I've been looking for
this whole time.
** early-init.el
#+PROPERTY: header-args:elisp :mkdirp yes :tangle early-init.el
*** A pointless header
#+begin_src elisp :tangle early-init.el
;;; Early-init --- do all these things early in the init process
;;; Commentary:
;; do the first initial beginning things
;;; Code:
#+end_src
*** Redefine the startup message
#+begin_src elisp :tangle early-init.el
(defun display-startup-echo-area-message ()
"A re-definition of the function.
Tell the Emacs startup time and number of garbage-collections
instead of the banal
\"For information about GNU Emacs and the GNU system, type \\[about-emacs].\""
(message
(concat (emacs-init-time) ", gc ran " (number-to-string gcs-done) " times"
)))
#+end_src
*** Redefine the Scratch blurb
#+begin_src elisp :tangle early-init.el
(setq initial-scratch-message (purecopy "\
;; Write some lisp in this buffer and it can be executed, either with
;; \\[eval-last-sexp] locally or \\[eval-buffer] globally.
"))
#+end_src
*** Un-hinge the garbage collector
#+begin_src elisp :tangle early-init.el
;; Crash the computer by overloading memory
(setq gc-cons-threshold (* 50 1000 1000))
#+end_src
*** Vanilla is not plain. Pour on the bleach.
#+begin_src elisp :tangle early-init.el
;; Disable package.el so we can use straight
(setq package-enable-at-startup nil)
#+end_src
*** just give me my file buffer, please
#+begin_src elisp :tangle early-init.el
;; Hide default dashboard
(defvar inhibit-startup-messages t)
(setq inhibit-startup-screen t)
#+end_src
*** Compilers are verbose, but we need not listen
#+begin_src elisp :tangle early-init.el
;; Don't pop up error window on native-comp emacs
(defvar native-comp-async-report-warnings-errors 'silent)
#+end_src
*** BROKEN: frame hooks. Present later in init.
#+begin_src elisp :tangle early-init.el
;; Run stuff after opening a new frame
;; (setq server-after-make-frame-hook (mitch/graphical-setup))
;; (setq before-make-frame-hook (mitch/graphical-setup))
;;; early-init.el ends here
#+end_src
** init.el
#+PROPERTY: header-args:elisp :mkdirp yes :tangle init.el
*** Cool figlet text
This file used to get checked by flycheck so that's perhaps worthy of note...
#+begin_src elisp :tangle init.el
;;; init.el --- basic initial declarations
;;; Commentary:
;; _ _ _ _
;; (_) _ __ (_)| |_ ___ | |
;; | || '_ \ | || __| / _ \| |
;; | || | | || || |_ _| __/| |
;; |_||_| |_||_| \__|(_)\___||_|
;;
;; '((above text graphic generated with command `figlet -k "init.el"'))
#+end_src
*** Wrap it all in a Let
This is said to speed up loading files because it doesn't search on network
locations, which have always been broken for me.
#+begin_src elisp :tangle init.el
;;; Code:
;; Speed up loading/finding files
(let
((file-name-handler-alist nil))
#+end_src
TODO make it indent correctly
*** BROKEN: explicit shell name
#+begin_src elisp :tangle init.el
;; Don't set this, fix the actual issue and use a POSIX-ish shell (or CMD):
;; (setq shell-file-name "/bin/sh")
#+end_src
*** Add my personal files to the load-path
#+begin_src elisp :tangle init.el
;; Load the files that I put my settings in...
(defvar mitch-directory
(directory-file-name
(concat user-emacs-directory
(convert-standard-filename "lisp/"))))
(setq load-path
(cons mitch-directory load-path))
(setq custom-theme-directory mitch-directory)
#+end_src
*** ... and load them
#+begin_src elisp :tangle init.el
(require 'mitch-defuns)
;; (require 'webkit) ; see https://github.com/akirakyle/emacs-webkit
(require 'man-plus)
#+end_src
*** Minify yes/no prompts
#+begin_src elisp :tangle init.el
;; minify yes/no prompts
;; (if (>= (string-to-number emacs-version) 28)
;; (defvar use-short-answers t))
(defalias 'yes-or-no-p 'y-or-n-p)
#+end_src
*** When GUI, do GUI things
#+begin_src elisp :tangle init.el
;; do the things
(add-hook 'server-after-make-frame-hook #'mitch/graphical-setup)
(if (display-graphic-p) (mitch/graphical-setup))
#+end_src
*** Hide backup, swap, and lock files
#+begin_src elisp :tangle init.el
;; Control backups/swapfiles
(defvar backup-directory
(expand-file-name "emacs-backups"
(or (getenv "XDG_CACHE_HOME")
(expand-file-name
".cache" "~"))))
(if (not (file-exists-p backup-directory))
(make-directory backup-directory t))
(setq backup-directory-alist `(("." . ,backup-directory)))
;; auto-save-mode doesn't create the path automatically!
(defvar auto-save-directory
(expand-file-name "tmp/auto-saves/" backup-directory))
(make-directory auto-save-directory t)
(setq auto-save-list-file-prefix
(expand-file-name "sessions/" auto-save-directory)
auto-save-file-name-transforms
`((".*" ,auto-save-directory t)))
(setq create-lockfiles nil)
#+end_src
*** Put Custom declarations in their own (ignored) file
#+begin_src elisp :tangle init.el
;; remove auto-generated bits
(setq custom-file (expand-file-name "custom.el" backup-directory))
(if (not (file-exists-p custom-file))
(make-empty-file custom-file t))
(load custom-file)
#+end_src
*** Invoke/load straight.el, the gud git package manager
#+begin_src elisp :tangle init.el
;; straight.el: the better package manager?
;; minified bootstrap (split lines if you want) (or not)
(defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 5)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) (straight-use-package 'use-package) (setq straight-use-package-by-default t)
#+end_src
*** And load my packages
#+begin_src elisp :tangle init.el
(require 'mitch-packages)
#+end_src
*** Line numbers
#+begin_src elisp :tangle init.el
;; Absolute line numbers. Relative ones are an annoyance to set up, sadly.
(global-display-line-numbers-mode)
(defvar display-line-numbers-width-start t)
#+end_src
*** Scrolling up and down is weird
#+begin_src elisp :tangle init.el
;; scroll step stuff
(setq scroll-margin 2
scroll-conservatively 100
scroll-up-aggressively 0.01
scroll-down-aggressively 0.01)
(global-visual-line-mode t)
#+end_src
*** BROKEN: run launcher for linux apps
#+begin_src emacs-lisp
;; run launcher exists. Copy it from
;; https://www.reddit.com/r/unixporn/comments/s7p7pr/so_which_run_launcher_do_you_use_rofi_or_dmenu/
;; I don't have it here because I don't use it right now.
#+end_src
*** UTF-8 is love, UTF-8 is life
#+begin_src elisp :tangle init.el
;; UTF-8 supremacy (Snippet from https://github.com/doomemacs/doomemacs/blob/master/early-init.el)
(set-language-environment "UTF-8")
#+end_src
*** BROKEN: Japanese input
you can still use it: ~C-u C-\ japanese RET~
#+begin_src elisp :tangle init.el
;; Toggle Japanese with `qq'
;; Sample text: 進撃 の 巨人
;; (shingeki no kyojin (attack on titan))
;; (setq default-input-method 'japanese)
;; (setq-default current-input-method 'japanese-ascii)
;; DISABLED because something broke and I didn't bother figuring out what...
#+end_src
*** Inspect Element popup, but 40 years old
#+begin_src elisp :tangle init.el
;; barf out emacs errors as they are encountered
(setq debug-on-error t)
#+end_src
*** Pointless scrolling hack
TODO should go in [[Scrolling up and down is weird]]
#+begin_src elisp :tangle init.el
;; Speed up scrolling down (why is this even a thing?)
(setq auto-window-vscroll nil)
#+end_src
*** Save our place in files, to jump right back into it
#+begin_src elisp :tangle init.el
;; save place in all files
(save-place-mode t)
(defvar save-place-file
(expand-file-name "file-position-save" backup-directory))
#+end_src
*** an excuse to write lambda as λ
#+begin_src elisp :tangle init.el
;; load eshell stuff when we start eshell
(add-hook 'eshell-mode-hook #'(lambda () (require 'eshell-settings)))
;; Display "labmda" as λ
(global-prettify-symbols-mode 1)
#+end_src
*** Close the 'Let'
#+begin_src elisp :tangle init.el
)
#+end_src
*** Re-hinge the garbage collector
see early-init.el
#+begin_src elisp :tangle init.el
;; lower gc threshold again
(setq gc-cons-threshold (* 2 1000 1000))
;;; init.el ends here
#+end_src

27
lisp/ansi-term-plus.el Normal file
View File

@ -0,0 +1,27 @@
;; Fix ansi-term not closing when it closes (broken?)
(defadvice term-sentinel
(around my-advice-term-sentinel (proc msg))
(if (memq (process-status proc) '(signal exit))
(let ((buffer (process-buffer proc)))
ad-do-it
(kill-buffer buffer))
ad-do-it))
(ad-activate 'term-sentinel)
;; Ansi-term always use zsh?
(defvar my-term-shell (getenv "ZSH"))
(defadvice ansi-term (before force-zsh)
(interactive (list my-term-shell)))
(ad-activate 'ansi-term)
;; ansi-term utf-8 everything better
(defun my-term-use-utf8 ()
(set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))
(add-hook 'term-exec-hook 'my-term-use-utf8)
(defun my-term-setup ()
"custom function of things to run when launching
a new terminal."
(display-line-numbers-mode -1))
;; Term cleanup things
(add-hook 'term-mode-hook 'my-term-setup)
(setq evil-collection-term-sync-state-and-mode-p nil)
(provide 'ansi-term-plus)

30
lisp/eshell-settings.el Normal file
View File

@ -0,0 +1,30 @@
;;; eshell-settings --- settings for eshell.
;;; Commentary:
;; the elisp linter wants me to put some text here so I guess I will
;;; Code:
(defun eshell/emacs (&rest args)
"Basically you can edit ARGS and it will open in a new buffer.
When your shell is Emacs, your Emacs is but an oyster...
This is taken from a website that I can't remember at the moment."
(if (null args)
(bury-buffer)
(mapc
#'find-file
(mapcar
#'expand-file-name (eshell-flatten-list (reverse args))))))
(defun eshell/clear ()
"Clear the scrollback buffer, like `clear' in a real shell..."
(eshell/clear-scrollback))
(defun eshell/faketty (&rest args)
"USAGE: `faketty ARGS` where ARGS is anything that spews colors.
Credit: https://stackoverflow.com/questions/1401002/how-to-trick-an-application-into-thinking-its-stdout-is-a-terminal-not-a-pipe"
(let
((shell-command-dont-erase-buffer t))
(shell-command
(concat "script -qfc '" args "' /dev/null")
(current-buffer))
))
(provide 'eshell-settings)
;;; eshell-settings.el ends here

27
lisp/man-plus.el Normal file
View File

@ -0,0 +1,27 @@
;; man-plus.el
;; Loosely based on neovim's `man.vim' functionality.
;;
;; Feature goals:
;; - MANWIDTH based on size of new window
;; - Lots of different colors for headings, options,
;; sh snippets, etc
(setq man-plus-highlights
'(
("^[A-Z]\([1-9]\)\s*.*$" . 'transient-heading)
("^[a-z]\([1-9]\)\s*.*$" . 'transient-heading)
("^\s*[A-Z]*$" . 'font-lock-keyword-face)
(".*\([1-9]\)" . 'font-lock-string-face)
("^\s*-[a-z]*" . 'font-lock-string-face)
)
)
(defun man-plus-setall ()
"Do all of the things that Man wants. To be
run as `Man-mode-hook'."
(setq font-lock-defaults '(man-plus-highlights)))
(setq Man-mode-hook
'man-plus-setall)
(provide 'man-plus)

114
lisp/mitch-defuns.el Normal file
View File

@ -0,0 +1,114 @@
;;; mitch-defuns.el --- custom-defined functions
;;; Commentary:
;; _ _ _
;; _ __ ___ (_)| |_ ___ | |__
;; | '_ ` _ \ | || __|/ __|| '_ \ _____
;; | | | | | || || |_| (__ | | | ||_____|
;; |_| |_| |_||_| \__|\___||_| |_|
;; _ __ _
;; __| | ___ / _| _ _ _ __ ___ ___ | |
;; / _` | / _ \| |_ | | | || '_ \ / __| / _ \| |
;; | (_| || __/| _|| |_| || | | |\__ \ _ | __/| |
;; \__,_| \___||_| \__,_||_| |_||___/(_) \___||_|
;;
;; Some functions to run when loading packages...
;;; Code:
;; (defun mitch/evil-init ()
;; "A batch of commands to run as the :init of evil's `use-package'.
;; Made solely to reduce lines in the init-file."
;; (setq evil-want-integration t
;; evil-want-keybinding nil
;; evil-want-C-u-scroll nil
;; evil-want-C-i-jump nil
;; evil-vsplit-window-right t
;; evil-split-window-below t
;; evil-undo-system
;; (if (>= (string-to-number emacs-version) 29)
;; (quote undo-redo)
;; (quote undo-fu))))
(defun mitch/evil-config ()
"A batch of commands to run as the :config of evil's `use-package'.
Made solely to reduce lines in the init-file."
(evil-mode t)
(evil-set-initial-state 'messages-buffer-mode 'normal)
(global-visual-line-mode t)
(diminish 'visual-line-mode)
;; Make evil-join combine lines. Taken from https://github.com/hlissner/doom-emacs/commit/40cf6139ed53b635fec37ce623c4b1093c78a11e
;; (evil-define-operator +evil-join-a (beg end)
;; "Join the selected lines.
;; This advice improves on `evil-join' by removing comment delimiters when joining
;; commented lines, by using `fill-region-as-paragraph'.
;; From https://github.com/emacs-evil/evil/issues/606"
;; :motion evil-line
;; (let* ((count (count-lines beg end))
;; (count (if (> count 1) (1- count) count))
;; (fixup-mark (make-marker)))
;; (dotimes (var count)
;; (if (and (bolp) (eolp))
;; (join-line 1)
;; (let* ((end (line-beginning-position 3))
;; (fill-column (1+ (- end beg))))
;; (set-marker fixup-mark (line-end-position))
;; (fill-region-as-paragraph beg end nil t)
;; (goto-char fixup-mark)
;; (fixup-whitespace))))
;; (set-marker fixup-mark nil)))
;; (advice-add #'evil-join :override #'+evil-join-a)
)
(defun mitch/graphical-setup ()
"A batch of commands to run at the beginning of
the init file when we're on a graphical display.
This prevents errors in termux and speeds up init
when editing from the console."
;; hide gui scrollbars and menubar etc
(scroll-bar-mode t)
(setq scroll-bar-adjust-thumb-portion nil)
(tool-bar-mode 0)
(menu-bar-mode 0)
(set-fringe-mode 8)
;; diable stupid file open box thingy
(setq use-file-dialog nil)
(setq use-dialog-box nil)
;; Pixel scrolling. Only in emacs 29+...
(if (>= (string-to-number emacs-version) 29)
(pixel-scroll-precision-mode t)))
(defun toggle-ja-input ()
"Switch between english and japanese. Broken."
(interactive)
(if (eq current-input-method 'japanese)
(setq current-input-method 'japanese-ascii)
(setq current-input-method 'japanese)))
(defun mitch/general-config ()
"A batch of commands to run immediately after loading the `general' package.
Made solely to reduce lines in the init file."
(require 'mitch-keybinds))
(defun turn-off-line-numbers ()
"A tiny wrapper around `display-line-numbers-mode'.
For use in hooks."
(interactive)
(display-line-numbers-mode -1))
(defun mitch/terminal-setup ()
"A batch of commands to run when opening anything that looks like a terminal.
For instance:
- Shell
- (ansi-)term
- eshell
- vterm
- Maybe SLIME too."
(turn-off-line-numbers))
;; for vterm
(defun update-pwd (path)
"Sync Emacs' working PATH with the shell's.
For use with `vterm'."
(setq default-directory path))
;; This one line cost me over an hour of frustration...
(provide 'mitch-defuns)
;;; mitch-defuns.el ends here

50
lisp/mitch-keybinds.el Normal file
View File

@ -0,0 +1,50 @@
;;; mitch-keybinds.el --- do keybinding things, mostly with General...
;;; Commentary:
;; -----------------------------------------------------------------------------
;; There are a lot of things we do with the keyboard. Perhaps all of the
;; things, in fact. Thus, we use the `general' package for transparently
;; defining keybindings in various states. See
;; `https://github.com/noctuid/general.el' for more.
;; -----------------------------------------------------------------------------
;;; Code:
(general-define-key
"<escape>" 'keyboard-escape-quit
"C--" 'text-scale-decrease
"C-=" 'text-scale-increase)
(general-define-key
:states 'motion
"j" 'evil-next-visual-line
"k" 'evil-previous-visual-line)
(general-define-key
:states 'normal
:map 'org-mode-map
"RET" 'org-open-at-point)
(general-define-key
:states '(normal visual)
:prefix "SPC"
:non-normal-prefix "SPC"
"w" 'evil-window-map
"h" 'help-command
"b" 'switch-to-buffer
"SPC" 'evil-buffer)
(general-define-key
:states '(normal visual)
:prefix-command 'eval-map-prefix
:prefix-map 'eval-map
:prefix "SPC e"
"l" 'eval-last-sexp
"b" 'eval-buffer
"r" 'eval-region
":" 'eval-expression
"s" 'eshell)
;; broken
(general-define-key
:prefix-map 'minibuffer-mode-map
"DEL" 'backward-kill-word)
;; fixed?
(provide 'mitch-keybinds)
;;; mitch-keybinds.el ends here

543
lisp/mitch-packages.el Normal file
View File

@ -0,0 +1,543 @@
;;; mitch-packages --- Declare and configure use-package statements
;;; Commentary:
;; -----------------------------------------------------------------------------
;; This is a file in which I put declarations for packages and things.
;; -----------------------------------------------------------------------------
;;; Code:
;; diminish
(use-package diminish)
(use-package eldoc
:custom
(eldoc-echo-area-use-multiline-p nil)
:defer 1
:diminish)
;; Keybinding manager
(use-package general
:config (mitch/general-config))
;; load evil
(use-package evil
:general
(general-define-key
:states 'normal
"<escape>" 'evil-beginning-of-line
"C-p" 'scroll-down-line
"C-n" 'scroll-up-line)
(general-define-key
:states 'insert
"C-w" 'evil-window-map
"C-V" (general-key-dispatch
'evil-quoted-insert
"u" 'insert-char))
:diminish visual-line-mode
:custom
(evil-want-integration t)
(evil-want-keybinding nil)
(evil-want-C-u-scroll nil)
(evil-want-C-i-jump nil)
(evil-vsplit-window-right t)
(evil-split-window-below t)
(evil-undo-system
(if (>= (string-to-number emacs-version) 28)
(quote undo-redo)
(quote undo-fu)))
:init
(evil-mode t))
(use-package evil-collection
:after evil
:diminish evil-collection-unimpaired-mode
:config (evil-collection-init))
(use-package evil-commentary
:diminish 'evil-commentary-mode
:config (evil-commentary-mode)
:after evil)
(use-package evil-surround
:diminish 'global-evil-surround-mode
:after evil
:config (global-evil-surround-mode 1))
(use-package evil-terminal-cursor-changer
:after evil
:diminish
:if (not (display-graphic-p))
:config
(evil-terminal-cursor-changer-activate)
(xterm-mouse-mode))
(use-package undo-fu
:after evil
:if (< (string-to-number emacs-version) 29)
:diminish)
;; Completion framework...
;; (use-package vertico
;; :custom (vertico-resize t)
;; :config (vertico-mode))
;; (use-package consult
;; :after vertico)
;; Minibuffer generic stuff
(use-package savehist
:straight (:type built-in)
;; :after vertico
:init (savehist-mode))
(use-package marginalia
;; :after (vertico consult)
:init (marginalia-mode))
(use-package orderless
;; :after vertico
;; :config
;; (setq completion-category-defaults nil
;; completion-category-overrides nil)
:commands 'execute-extended-command
:custom
(completion-styles '(orderless partial-completion basic))
(completion-category-defaults nil)
;; (completion-category-overrides '((file (styles basic partial-completion))))
(completion-category-overrides nil)
)
;; broken terminal that doesn't compile but at least it's fast when it does
(use-package vterm
:custom
(vterm-always-compile-module t)
(vterm-module-cmake-args "-DUSE_SYSTEM_LIBVTERM=no")
(vterm-clear-scrollback-when-clearing t)
:config
(evil-collection-define-key 'insert 'vterm-mode-map
(kbd "C-w") 'evil-window-map)
(add-to-list 'vterm-keymap-exceptions
"C-w")
(setq mitch/vterm-eval-cmds-strings
'("update-pwd"
"restart-emacs"
"find-file-other-window"
"find-file-other-frame"))
(dolist (emacs-function mitch/vterm-eval-cmds-strings)
(add-to-list 'vterm-eval-cmds
(list emacs-function (intern emacs-function))))
:hook
(vterm-mode . mitch/terminal-setup)
(vterm-exit-functions . save-buffers-kill-terminal))
(use-package multi-vterm
:commands (multi-vterm multi-vterm-other-window)
:config
(defun multi-vterm-other-window ()
"Run a new-ish vterm in the other window"
(interactive)
(other-window 1) (multi-vterm))
:general
(general-define-key
:states '(normal visual)
:prefix "SPC"
:non-normal-prefix "SPC"
"v" 'multi-vterm)
(general-define-key
:states 'normal
:prefix-map 'ctl-x-4-map
:prefix "SPC 4"
"v" 'multi-vterm-other-window))
;; Better modeline?
(use-package powerline
:init
:custom
(powerline-default-separator 'utf-8)
(powerline-utf-8-separator-left 57532)
(powerline-utf-8-separator-right 57534)
(powerline-display-hud nil)
(powerline-gui-use-vcs-glyph t))
(use-package airline-themes
:custom
(airline-cursor-colors nil)
(airline-display-directory t)
(airline-eshell-colors nil)
(airline-shortened-directory-length 20)
:after powerline
:config
(load-theme 'airline-ravenpower t))
;; Custom Theme.
;; Not to be confused with a color theme, or a color scheme, or a custom scheme.
(use-package autothemer
:custom
(window-divider-default-places t)
(right-divider-width 5)
(ring-bell-function 'ignore)
:config
(tooltip-mode -1)
(menu-bar-mode -1)
(load-theme 'mitch t)
)
;; (use-package doom-themes
;; :init (load-theme 'doom-one t))
;; (use-package yascroll
;; :diminish
;; :defer 1
;; :if (not (display-graphic-p))
;; :custom (yascroll:delay-to-hide nil)
;; :custom-face
;; (yascroll:thumb-text-area ((t (:background "ForestGreen"))))
;; (yascroll:thumb-fringe
;; ((t (:background "ForestGreen" :foreground "ForestGreen"))))
;; :config (global-yascroll-bar-mode 1))
;; parentheses settingses
(use-package paredit
:defer 0.1
:general (general-define-key
:states 'normal
"M-j" 'paredit-forward-slurp-sexp
"M-k" 'paredit-forward-barf-sexp
"M-h" 'paredit-backward-barf-sexp
"M-l" 'paredit-backward-slurp-sexp)
:config
(show-paren-mode 1)
(electric-pair-mode 1)
:custom
(show-paren-delay 0)
(show-paren-style 'parenthesis))
;; org mode and messy things
(use-package org
:straight (:type built-in)
:mode (("\\.org$" . org-mode))
:custom
(org-ellipsis "")
(org-hide-leading-stars t)
(org-startup-indented t)
:config
(org-indent-mode)
(add-hook 'org-mode-hook
#'(lambda ()
(add-hook 'after-save-hook
#'(lambda ()
(org-babel-tangle)))))
(with-eval-after-load 'org
;; This is needed as of Org 9.2
(require 'org-tempo)
(add-to-list 'org-structure-template-alist '("sh" . "src shell"))
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
(add-to-list 'org-structure-template-alist '("ps1" . "src powershell")))
:hook (org-mode . turn-off-line-numbers))
(use-package org-variable-pitch
:diminish
:config
(set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-delimiter-face fixed-pitch))
:hook (org-mode . org-variable-pitch-minor-mode))
(use-package org-contrib
:after org
:config
(org-babel-do-load-languages
'org-babel-load-languages
'((powershell . t)
(shell . t)
)))
;; (use-package org-appear
;; :hook (org-mode . org-appear-mode)
;; :after org
;; :custom
;; (org-appear-autolinks t))
(use-package ob-powershell
:after (org powershell)
:custom
(ob-powershell-powershell-command "pwsh"))
;; (use-package visual-fill-column
;; :config
;; (setq-default visual-fill-column-center-text t)
;; (setq-default fill-column 140)
;; :hook (org-mode . visual-fill-column-mode))
(use-package company-org-block
:after (org company))
(use-package org-modern
:hook (org-mode . org-modern-mode))
;; cheaty key popups
(use-package which-key
:diminish
:defer 5
:init (which-key-mode t))
;; parentheses are boring
(use-package rainbow-delimiters
:diminish
:defer 1
:hook (prog-mode . rainbow-delimiters-mode))
;; Hex colors
(use-package rainbow-mode
:diminish
:defer 10
:hook (prog-mode . rainbow-mode))
;; Nobody loves a good language
(use-package powershell
:mode ("\\.ps1\\'" . powershell-mode))
(use-package cider
:defer 1)
;; or a bad language
(use-package haskell-mode
:mode "\\.hs\\'"
;; :init
;; (add-hook 'haskell-mode-hook 'haskell-decl-scan-mode)
;; (add-hook 'haskell-mode-hook #'lsp)
:bind (
:map haskell-mode-map
("C-c h" . hoogle)
("C-c s" . haskell-mode-stylish-buffer))
:config (message "Loaded haskell-mode")
(setq haskell-mode-stylish-haskell-path "brittany")
(setq haskell-hoogle-url "https://www.stackage.org/lts/hoogle?q=%s"))
;; c sharp; taken from https://www.reddit.com/r/emacs/comments/k8tnzg/help_setting_up_c_lsp_omnisharproslyn/
(use-package csharp-mode
;; :ensure t
:mode (("\\.cs\\'" . csharp-mode))
:config
(add-to-list 'compilation-error-regexp-alist-alist
'(my-csharp
"^\\(.+\\)(\\([1-9][0-9]+\\),\\([0-9]+\\)): \\(?:\\(warning\\)\\|error\\)?"
1 2 3 (4)))
(add-to-list 'compilation-error-regexp-alist 'my-csharp)
(defun my-csharp-repl ()
"Switch to the CSharpRepl buffer, creating it if necessary."
(interactive)
(if-let ((buf (get-buffer "*CSharpRepl*")))
(pop-to-buffer buf)
(when-let ((b (make-comint "CSharpRepl" "csharp")))
(switch-to-buffer-other-window b))))
(define-key csharp-mode-map (kbd "C-c C-z") 'my-csharp-repl)
;; (define-key csharp-mode-map (kbd "C-c C-c") #'projectile-compile-project)
)
(use-package omnisharp
;; :ensure t
:after csharp-mode
:config
(eval-after-load 'company '(add-to-list 'company-backends 'company-omnisharp))
;; (setq omnisharp-completing-read-function #'ivy-completing-read)
(put 'my-omnisharp-solution-path 'safe-local-variable #'stringp)
:hook (csharp-mode . omnisharp-mode))
(use-package lsp-mode
:hook ((powershell-mode . lsp)
(csharp-mode . lsp)
(lsp-mode . lsp-enable-which-key-integration)
(lsp-completion-mode . my/lsp-mode-setup-completion))
:commands lsp
:init
(defun my/lsp-mode-setup-completion ()
(setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
'(flex))) ;; Configure flex
:custom
(lsp-completion-provider :none))
;; optionally
(use-package lsp-ui
:after lsp
:commands lsp-ui-mode)
(use-package lsp-treemacs
:after lsp
:commands lsp-treemacs-errors-list)
;; optionally if you want to use debugger
;; (use-package dap-mode)
;; (use-package dap-powershell)
;; (use-package dap-LANGUAGE) to load the dap adapter for your language
;; Better help-pages. Genuinely pretty great.
(use-package helpful
:general (general-define-key
[remap describe-key] 'helpful-key
[remap describe-variable] 'helpful-variable
[remap describe-function] 'helpful-callable)
(general-define-key
:keymaps 'help-map
"F" 'describe-face
"k" 'helpful-key)
(general-define-key
:keymaps 'emacs-lisp-mode-map
:states 'normal
"K" 'helpful-at-point))
;; Better lisp highlighting?
(use-package highlight-defined
:hook (emacs-lisp-mode . highlight-defined-mode))
;; Shell linting?
(use-package flycheck
:diminish
:hook (prog-mode . flycheck-mode)
;; :config (global-flycheck-mode t)
)
;; Emacs startup profiling
(use-package esup
:commands esup)
;; Blingy file tree view
(use-package treemacs
:general (general-define-key
:states 'normal
:prefix-command 'treemacs-map-prefix
:prefix-map 'treemacs-map
:prefix "SPC t"
"t" 'treemacs)
:config
(treemacs-project-follow-mode)
(treemacs-git-mode 'simple)
:hook
(treemacs-mode . turn-off-line-numbers))
(use-package treemacs-evil
:after treemacs)
(use-package treemacs-all-the-icons
:after treemacs)
;; Blingy laggy minimap on the right
(use-package minimap
:general (general-define-key
:states 'normal
:prefix-command 'mini-map-prefix
:prefix-map 'mini-map
:prefix "SPC m"
"m" 'minimap-mode
"k" 'minimap-kill)
:custom
(minimap-window-location 'right)
(minimap-update-delay 0)
:custom-face
(minimap-active-region-background
((t (:background "#303030" :extend t))))
(minimap-current-line-face
((t (:background "#afafaf" :extend t)))))
;; epic drop-down completion
;; (use-package company
;; :diminish
;; :custom (company-require-match nil)
;; (company-tooltip-align-annotations t)
;; :hook (prog-mode . company-mode))
;; (use-package company-lsp
;; :after (lsp company)
;; :config
;; (push 'company-lsp company-backends))
;; (use-package company-fuzzy
;; :hook (company-mode . company-fuzzy-mode)
;; ;; :init
;; :custom
;; ;; (company-fuzzy-sorting-backend 'flx)
;; (company-fuzzy-prefix-on-top nil)
;; (company-fuzzy-history-backends '(company-yasnippet))
;; (company-fuzzy-trigger-symbols '("." "->" "<" "\"" "'" "@"))
;; (company-fuzzy-passthrough-backends '(company-capf)))
(use-package corfu
:custom
(completion-cycle-threshold 3)
(tab-always-indent 'complete)
(corfu-auto t)
(corfu-quit-no-match t)
(corfu-count (- (window-total-height) 10))
;; (corfu-separator ";")
:init (global-corfu-mode)
(defun corfu-enable-always-in-minibuffer ()
"Enable Corfu in the minibuffer if Vertico/Mct are not active."
(unless (or (bound-and-true-p mct--active)
(bound-and-true-p vertico--input))
(setq-local corfu-auto nil) ;; Enable/disable auto completion
(corfu-mode 1)
(minibuffer-complete)))
(add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
;; (defun corfu-kill-in-minibuffer ()
;; "Kill corfu and minibuffer. To be bound to Esc."
;; (interactive)
;; (setq-local inhibit-debugger t)
;; (corfu-quit)
;; (exit-minibuffer)
;; )
(defun corfu-send-shell (&rest _)
"Send completion candidate when inside comint/eshell."
(cond
((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
(eshell-send-input))
((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
(comint-send-input))))
:general
(general-define-key
:prefix-map 'corfu-map
"C-n" 'corfu-next
"C-p" 'corfu-previous
"RET" 'corfu-insert
"ESC" 'corfu-kill-in-minibuffer
)
)
(use-package popon
:straight
(:type git
:repo "https://codeberg.org/akib/emacs-popon"))
(use-package corfu-terminal
:straight
(:type git
:repo "https://codeberg.org/akib/emacs-corfu-terminal")
:init (unless
(display-graphic-p)
(corfu-terminal-mode +1)))
;; Visualize whitespace. In a very chill and invisible way.
(use-package whitespace
:straight (:type built-in)
:defer 1
:diminish global-whitespace-mode
:custom
(whitespace-style '(face lines-tail))
(whitespace-line-column 80)
:config (global-whitespace-mode t))
;; (use-package lsp-dart
;; ;; :custom (lsp-dart-dap-flutter-hot-reload t)
;; :init
;; (add-hook 'dart-mode-hook 'lsp)
;; (add-hook 'dart-mode-hook
;; #'(lambda ()
;; (add-hook 'after-save-hook
;; #'(lambda ()
;; (lsp-dart-dap-flutter-hot-reload))))))
(use-package eshell
:straight (:type built-in)
:hook (eshell-mode . mitch/terminal-setup)
:config (require 'eshell-settings))
(use-package popper
:custom
(display-buffer-base-action '(display-buffer-pop-up-window))
(popper-reference-buffers
'(
helpful-mode
compilation-mode
ibuffer-mode
"*Warnings"))
;; (popper-display-function
;; #'display-buffer-pop-up-frame)
(popper-mode-line nil)
:init
(popper-mode +1)
(popper-echo-mode +1))
;; (use-package mini-frame
;; :init (mini-frame-mode))
(use-package xwidget ;-webkit
:straight (:type built-in)
:if (featurep 'xwidget-internal)
:config
(add-hook 'xwidget-webkit-mode-hook
#'(lambda ()
(turn-off-line-numbers)
(scroll-bar-mode -1)
))
)
(provide 'mitch-packages)
;;; mitch-packages.el ends here

149
lisp/mitch-theme.el Normal file
View File

@ -0,0 +1,149 @@
;;; mitch-theme.el --- set visual theme in the only unique way
;;; Commentary:
;; When I first started using `nvim', I copied my `nano' config
;; which was very cringe and basic. And so I scoured the internet
;; for themes. And discovered something truly disturbing:
;; Every single `nvim' and `emacs' theme looks exactly the same,
;; and they're all gray-on-gray cringe. I prefer my cringe to really
;; pop rather than ooze before my eyes, so I somehow found the `nvim'
;; theme that gradually became this.
;; We require 'autothemer because it makes the face declaration so much
;; simpler.
;;; Code:
(require 'autothemer)
;; set font...
;; Taken from https://web.archive.org/web/20210622224446/https://www.manueluberti.eu/emacs/2017/02/26/dynamicfonts/
;; insane font stuff. Might be what breaks something.
;; (defun mitch/setup-main-fonts (default-height variable-pitch-height)
;; "Set up default fonts.
;; Use DEFAULT-HEIGHT for default face and VARIABLE-PITCH-HEIGHT
;; for variable-pitch face."
;; (set-face-attribute 'default nil
;; :family "MesloLGS NF"
;; :height default-height)
;; (set-face-attribute 'variable-pitch nil
;; :height variable-pitch-height
;; :weight 'regular))
;; ;; Now I just have to call this function with the proper values for :height
;; ;; according to the screen size.
;; (when window-system
;; (if (> (x-display-pixel-width) 1800)
;; (mitch/setup-main-fonts 130 140)
;; (mitch/setup-main-fonts 110 120)))
;; sane font stuff
(set-face-attribute 'fixed-pitch nil
:family "MesloLGS NF"
:height 130)
(set-face-attribute 'default nil
:family "MesloLGS NF"
:height 130)
(set-face-attribute 'variable-pitch nil
:height 140
:weight 'regular)
(setq rainbow-delimiters-max-face-count 2)
;; (setq org-fontify-quote-and-verse-blocks t)
;; Set transparent background; might break older emacsen
(add-to-list 'initial-frame-alist '(alpha-background . 50))
(add-to-list 'default-frame-alist '(alpha-background . 50))
(add-to-list 'default-frame-alist '(cursor-color . "white"))
(add-to-list 'default-frame-alist '(fullscreen . maximized))
(autothemer-deftheme
mitch "Based on my nvim theme. Because everything else looks the same."
;; Specify the color classes used by the theme
((
((class color) (min-colors #xFFFFFF)) ;; truecolor
((class color) (min-colors #xFF )) ;; 256color
((class color) (min-colors 16 )) ;; 16color
((class color) (min-colors 8 )) ;; 8color
)
;; Specify the color palette for each of the classes above.
(mitch-black "black" )
(mitch-red "red" )
(mitch-green "ForestGreen")
(mitch-yellow "gold1" "white")
(mitch-blue "blue" )
(mitch-magenta "magenta")
(mitch-cyan "cyan")
(mitch-white "white")
(mitch-pink "pink2")
(mitch-light-black "grey19" "grey19" "gray")
(mitch-light-red "orange")
(mitch-light-green "green3")
(mitch-light-yellow "PaleGoldenrod")
(mitch-light-blue "RoyalBlue")
(mitch-light-magenta "DarkMagenta")
(mitch-light-cyan "turquoise3")
(mitch-light-white "grey69")
(mitch-visual-bg "DarkBlue")
(mitch-dark-gray "grey7")
(mitch-dark-yellow "DarkGoldenrod1")
(mitch-dark-red "DarkRed")
(mitch-mid-gray "grey33")
(mitch-mid-violet "BlueViolet")
)
;; specifications for Emacs faces.
(
;; (default (:background mitch-black :foreground mitch-light-yellow))
;; (fixed-pitch (:inherit 'default))
(default (:background mitch-black :foreground mitch-white))
(cursor (:inherit 'default))
(highlight (:background mitch-visual-bg))
(region (:inherit 'highlight))
(link (:foreground mitch-light-blue :underline 't))
(link-visited (:foreground mitch-mid-violet :underline 't))
(whitespace-line (:background mitch-dark-red))
(line-number (:inherit 'fixed-pitch :foreground mitch-light-black :weight 'normal))
(line-number-current-line (:inherit 'line-number :foreground mitch-yellow :weight 'bold))
(linum (:inherit 'line-number))
(linum-relative-current-face (:inherit 'line-number-current-line))
;; font-lock faces. The defaults that are important to get right.
(font-lock-comment-face (:foreground mitch-green :slant 'oblique))
(font-lock-comment-delimiter-face (:foreground mitch-light-black))
(font-lock-constant-face (:foreground mitch-light-white :weight 'normal))
(font-lock-string-face (:foreground mitch-light-blue :slant 'italic))
(font-lock-builtin-face (:foreground mitch-light-white :weight 'bold))
(font-lock-keyword-face (:foreground mitch-red :weight 'bold))
(font-lock-type-face (:foreground mitch-light-red :weight 'bold))
(font-lock-function-name-face (:foreground mitch-red :weight 'normal))
(font-lock-variable-name-face (:foreground mitch-light-cyan :weight 'normal))
(font-lock-negation-char-face (:foreground mitch-visual-bg :weight 'bold))
;; other things
(transient-heading (:inherit 'default :foreground mitch-magenta :weight 'bold))
(rainbow-delimiters-depth-1-face (:foreground mitch-light-magenta))
(rainbow-delimiters-depth-2-face (:foreground mitch-magenta :weight 'normal))
(vertical-border (:foreground mitch-light-magenta :weight 'bold))
(fringe (:inherit 'default))
(whitespace-space (:foreground mitch-black))
(whitespace-tab (:foreground mitch-black))
(whitespace-newline (:foreground mitch-black))
(org-meta-line (:inherit 'font-lock-comment-delimiter-face))
(isearch (:foreground mitch-dark-yellow :background mitch-light-magenta :weight 'bold))
(lazy-highlight (:inherit 'isearch))
(completions-highlight (:background mitch-mid-violet))
(corfu-default (:background mitch-mid-gray))
(corfu-current (:inherit 'completions-highlight))
(vterm-color-red (:foreground mitch-red :background mitch-light-red))
(vterm-color-blue (:foreground mitch-blue :background mitch-light-blue))
(vterm-color-cyan (:foreground mitch-cyan :background mitch-light-cyan))
(vterm-color-black (:foreground mitch-black :background mitch-light-black))
(vterm-color-green (:foreground mitch-green :background mitch-light-green))
(vterm-color-white (:foreground mitch-white :background mitch-light-white))
(vterm-color-yellow (:foreground mitch-yellow :background mitch-light-yellow))
(vterm-color-magenta (:foreground mitch-magenta :background mitch-light-magenta))
)
)
(provide-theme 'mitch)
;;; mitch-theme.el ends here

101
lisp/webkit.el Normal file
View File

@ -0,0 +1,101 @@
;; webkit.el
;;
;; This file is barely a thing.
;; It was taken from
;; https://raw.githubusercontent.com/emacksnotes/emacsnotes.wordpress.com/master/my-xwidget-menu.el
;; as a simple and painless way to embed webkit into an emacs window,
;; ideally for use in something...
(require 'xwidget)
(when
(featurep 'xwidget-internal)
(easy-menu-define my-xwidget-tools-menu nil "Menu for Xwidget Webkit."
`("Xwidget Webkit" :visible
(featurep 'xwidget-internal)
["Browse Url ..." xwidget-webkit-browse-url
:help "Ask xwidget-webkit to browse URL"]
["End Edit Textarea" xwidget-webkit-end-edit-textarea
:help "End editing of a webkit text area"]))
(easy-menu-add-item menu-bar-tools-menu nil
my-xwidget-tools-menu 'separator-net)
(easy-menu-define my-xwidget-menu
xwidget-webkit-mode-map "Menu for Xwidget Webkit."
'("Xwidget Webkit"
["Browse Url" xwidget-webkit-browse-url
:help "Ask xwidget-webkit to browse URL"]
["Reload" xwidget-webkit-reload
:help "Reload current url"]
["Back" xwidget-webkit-back
:help "Go back in history"]
"--"
["Insert String" xwidget-webkit-insert-string
:help "current webkit widget"]
["End Edit Textarea" xwidget-webkit-end-edit-textarea
:help "End editing of a webkit text area"]
"--"
["Scroll Forward" xwidget-webkit-scroll-forward
:help "Scroll webkit forwards"]
["Scroll Backward" xwidget-webkit-scroll-backward
:help "Scroll webkit backwards"]
"--"
["Scroll Up" xwidget-webkit-scroll-up
:help "Scroll webkit up"]
["Scroll Down" xwidget-webkit-scroll-down
:help "Scroll webkit down"]
"--"
["Scroll Top" xwidget-webkit-scroll-top
:help "Scroll webkit to the very top"]
["Scroll Bottom" xwidget-webkit-scroll-bottom
:help "Scroll webkit to the very bottom"]
"--"
["Zoom In" xwidget-webkit-zoom-in
:help "Increase webkit view zoom factor"]
["Zoom Out" xwidget-webkit-zoom-out
:help "Decrease webkit view zoom factor"]
"--"
["Fit Width" xwidget-webkit-fit-width
:help "Adjust width of webkit to window width"]
["Adjust Size" xwidget-webkit-adjust-size
:help "Manually set webkit size to width W, height H"]
["Adjust Size Dispatch" xwidget-webkit-adjust-size-dispatch
:help "Adjust size according to mode"]
["Adjust Size To Content" xwidget-webkit-adjust-size-to-content
:help "Adjust webkit to content size"]
"--"
["Copy Selection As Kill" xwidget-webkit-copy-selection-as-kill
:help "Get the webkit selection and put it on the kill-ring"]
["Current Url" xwidget-webkit-current-url
:help "Get the webkit url and place it on the kill-ring"]
"--"
["Show Element" xwidget-webkit-show-element
:help "Make webkit xwidget XW show a named element ELEMENT-SELECTOR"]
["Show Id Element" xwidget-webkit-show-id-element
:help "Make webkit xwidget XW show an id-element ELEMENT-ID"]
["Show Id Or Named Element" xwidget-webkit-show-id-or-named-element
:help "Make webkit xwidget XW show a name or element id ELEMENT-ID"]
["Show Named Element" xwidget-webkit-show-named-element
:help "Make webkit xwidget XW show a named element ELEMENT-NAME"]
"--"
["Cleanup" xwidget-cleanup
:help "Delete zombie xwidgets"]
["Event Handler" xwidget-event-handler
:help "Receive xwidget event"]
"--"
["Xwidget Webkit Mode" xwidget-webkit-mode :style toggle
:selected xwidget-webkit-mode
:help "Xwidget webkit view mode"])))
(add-hook 'xwidget-webkit-mode-hook
#'(lambda ()
(turn-off-line-numbers)
(scroll-bar-mode -1)
))
;; (setq browse-url-browser-function 'xwidget-webkit-browse-url)
;; (defun browse-url-default-browser (url &rest args)
;; "Override `browse-url-default-browser' to use `xwidget-webkit' URL ARGS."
;; (xwidget-webkit-browse-url url args))
(provide 'webkit)