Skip to content
Snippets Groups Projects
.emacs 12.2 KiB
Newer Older
James Vasile's avatar
James Vasile committed
;;; package --- Summary
;;;
;;; Emacs config file
;;;
;; Commentary:
;;;
;;; These first few override some of Emacs's most frustrating defaults.
;;; We put it early in the file because if anything in .emacs is
;;; broken, we at least want to turn off the goddam beeping.  Having my
;;; laptop beep at me when I'm hitting the wrong keys because .emacs
;;; isn't loading my custom keys is extremely frustrating.

;;; Code:
(message "STARTING .EMACS")

;; Set this here, but unset it at the end of init
(setq debug-on-error t)

;; OMG, who wants beeps in this day and age?
(setq ring-bell-function 'ignore)

;; Don't ask about following symlinks into git dirs
(setq vc-follow-symlinks nil)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Save Desktop
;;
;;  We don't actually want to save most things.  If emacs is doing
;;  restoration of themes, it interferes with us setting themes
;;  because emacs doesn't respect our theme-per-frame as well as we
;;  do.
;;
;;  We do this high up in the .emacs because it is convenient to have
;;  this already set in case we need to abort starting emacs, fix
;;  .emacs, and try again.
(setq desktop-restore-frames nil)
(setq frameset-filter-alist
      `((tabs . :never)
	(background-color . :never)
	(buffer-list . :never)
	(buffer-predicate . :never)
	(buried-buffer-list . :never)
	(client . :never)
	(delete-before . :never)
	(font . :never)
	(font-backend . :never)
	(foreground-color . :never)
	(frameset--text-pixel-height . :never)
	(frameset--text-pixel-width . :never)
	(fullscreen . :never)
	(GUI:font . :never)
	(GUI:fullscreen . :never)
	(GUI:height . :never)
	(GUI:width . :never)
	(height . :never)
	(outer-window-id . :never)
	(parent-frame . :never)
	(parent-id . :never)
	(mouse-wheel-frame . :never)
	(tty . frameset-filter-tty-to-GUI)
	(tty-type . frameset-filter-tty-to-GUI)
	(width . :never)
	(window-id . :never)
	(window-system . :never)
	(name . :never)
	(left . :never)
	(minibuffer . :never)
	(top . :never)
	))
(desktop-save-mode 1)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages
   '(ivy icicles auto-package-update dyalog-mode org-babel-eval-in-repl apl jedi ruff-format elpy evil-collecion xclip zoom-window yasnippet-snippets yaml-mode windata vterm typescript-mode tree-mode toml-mode tidal sly sass-mode rustic python-mode pkg-info pass origami org-roam neotree magit lua-mode lsp-ui load-theme-buffer-local kivy-mode gotest go-gen-test go-dlv fountain-mode evil-escape evil-commentary evil-collection elfeed edit-server dart-mode color-theme-modern coffee-mode auctex ansible-doc all-the-icons adoc-mode)))
James Vasile's avatar
James Vasile committed
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

;; Keep track of recent files
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(setq recentf-max-saved-items 25)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)

;; Completion
(setq completion-cycle-threshold 5
      fido-mode 0)
(use-package ivy
   :ensure t
   :config (progn
	(setq ivy-use-virtual-buffers t
	    ivy-count-format "(%d/%d) "
	    ivy-mode 1)
   ))

James Vasile's avatar
James Vasile committed
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Looks
;;

;; Dark theme
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
(load-theme 'dracula t)

;; Remove visual clutter
;; disable the menu bar, scrollbar, toolbar
(menu-bar-mode -1)
(scroll-bar-mode -1)
(tool-bar-mode -1) 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Packages
;;
;; Set up package handling
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(require 'use-package)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Evil Mode
;;

;; evil-collection admonished me to set this before loading evil
(setq evil-want-keybinding nil)

;; load evil
(use-package evil
  :ensure t ;; install the evil package if not installed
  :init ;; tweak evil's configuration before loading it
  (setq evil-search-module 'evil-search)
  (setq evil-ex-complete-emacs-commands nil)
  (setq evil-vsplit-window-right t)
  (setq evil-split-window-below t)
  (setq evil-shift-round nil)
  (setq evil-want-C-u-scroll t)
  :config ;; tweak evil after loading it
  (evil-mode)
  (evil-commentary-mode)
  )

;; Bring evil keybindings to more modes
(use-package evil-collection :ensure t :init)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Languge Server Protocol
;;
(use-package lsp-mode :ensure t :init)

	    
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; APL
;;

;; I grabbed apl.el from https://www.metalevel.at/unicapl/ and it
;; doesn't appear to be in any elisp package archives.
;;
;; To use this, do M-x set-input-method (C-u C-\) then specify
;; apl-ascii.  Toggle back and forth between regular and apl-ascii
;; with C-\.  When apl-asii is active (you'll see "apl" in the
;; modeline while in evil insert mode), put an ascii string in curly
;; braces and apl.el will replace it with the appropriate apl symbol
;; when you hit the closing brace.  The replacement is triggered by
;; typing the closing brace and if your editing doesn't trigger
;; (e.g. because you didn't type it straight through, do M-x
;; apl-ascii-to-unicode to convert any ones in the buffer.
;;
;; A table of apl symbols and their ascii triggers is at
;; https://www.metalevel.at/unicapl/asciiapl.pdf and I put a copy in
;; ~/.emacs.d/3p/apl too.
;;
;; That table is also reproduced here:
;; " ¨
;; #% ⌹
;; #O ⌼
;; % ÷
;; & ⋄
;; - −
;; -> →
;; -| ⊣
;; /= ≠
;; /=_ ≢
;; /\ ∆
;; /\| ⍋
;; /match ≢
;; <- ←
;; <= ≤
;; =_ ≡
;; >= ≥
;; @ ⍝
;; I ⌶
;; I-beam ⌶
;; O ○
;; O" ⍥
;; O* ⍟
;; O- ⊖
;; O\ ⍉
;; T ⊤
;; \/~ ⍫
;; abs ∣
;; alpha ⍺
;; and ∧
;; assign ←
;; backslash-bar ⍀
;; base ⊥
;; box ⎕
;; branch →
;; caret ∧
;; catenate ,
;; ceiling ⌈
;; circle ○
;; circle-backslash ⍉
;; circle-dash ⊖
;; circle-diaeresis ⍥
;; circle-star ⍟
;; circle-stile ⌽
;; comment ⍝
;; compress /
;; compress1 ⌿
;; deal ?
;; decode ⊥
;; del ∇
;; del-stile ⍒
;; del-tilde ⍫
;; delta ∆
;; delta-stile ⍋
;; depth ≡
;; dex ⊣
;; diaeresis ¨
;; diamond ⋄
;; disclose ⊃
;; divide ÷
;; domino ⌹
;; down-arrow ↓
;; down-caret ∨
;; down-shoe ∪
;; down-tack ⊤
;; downcaret-tilde ⍱
;; downtack-jot ⍕
;; drop ↓
;; each ¨
;; enclose ⊂
;; encode ⊤
;; enlist ∈
;; epsilon ∈
;; epsilon-underbar ⍷
;; epsilon_ ⍷
;; execute ⍎
;; exp ⋆
;; expand \
;; expand1 ⍀
;; find ⍷
;; first ↑
;; floor ⌊
;; format ⍕
;; gets ←
;; goto →
;; grade-down ⍒
;; grade-up ⍋
;; greater-of ⌈
;; greater-than-equal ≥
;; holler ⍥
;; hoot ⍤
;; index ⌷
;; index-of ⍳
;; intersect ∩
;; intersection ∩
;; inverted-caret ∨
;; iota ⍳
;; iota-underbar ⍸
;; iota_ ⍸
;; is ←
;; jot ∘
;; jot-diaeresis ⍤
;; laminate ,
;; lamp ⍝
;; left-arrow ←
;; left-shoe ⊂
;; left-tack ⊣
;; leftbrace {
;; less-than-equal ≤
;; lesser-of ⌊
;; lev ⊢
;; ln ⍟
;; log ⍟
;; mat-divide ⌹
;; mat-inverse ⌹
;; match ≡
;; max ⌈
;; member ∈
;; member-of ∈
;; min ⌊
;; minus −
;; nabla ∇
;; nand ⍲
;; nazg ∘
;; negative −
;; nor ⍱
;; not ∼
;; not-equal ≠
;; not-match ≢
;; o ○
;; o" ⍥
;; omega ⍵
;; or ∨
;; partition ⊂
;; pi-times ○
;; pick ⊃
;; pow ⋆
;; quad ⎕
;; quad-backslash ⍂
;; quad-circle ⌼
;; quad-divide ⌹
;; quote-quad ⍞
;; rank ⍤
;; ravel ,
;; reciprocal ÷
;; reduce /
;; reduce1 ⌿
;; replicate /
;; replicate1 ⌿
;; represent ⊤
;; reshape ⍴
;; residue ∣
;; reverse ⌽
;; rho ⍴
;; right-arrow →
;; right-shoe ⊃
;; right-tack ⊢
;; rightbrace }
;; ring ∘
;; roll ?
;; rotate ⊖
;; rotate ⊖
;; scan \
;; scan1 ⍀
;; shape ⍴
;; signum ×
;; slash-bar ⌿
;; slope-bar ⍀
;; star ⋆
;; stile ∣
;; take ↑
;; tilde ∼
;; times ×
;; transpose ⍉
;; type ∈
;; union ∪
;; up-arrow ↑
;; up-caret ∧
;; up-shoe ∩
;; up-tack ⊥
;; upcaret-tilde ⍲
;; upshoe-jot ⍝
;; uptack-jot ⍎
;; w ⍵
;; x ×
;; |- ⊢
;; ~ ∼
;; ~^ ⍲
;; ~v ⍱
;(add-to-list 'load-path "~/.emacs.d/3p/apl")
;(require 'apl)

;; This gives us synax highlighting (and other things,
;; I'm not using those)
;(add-to-list 'load-path "~/.emacs.d/3p/gnu-apl")
;(require 'gnu-apl-mode)
;(add-to-list 'auto-mode-alist '("\\.apl\\'" . gnu-apl-mode))
(use-package dyalog-mode
  :ensure t
  :config
  (add-to-list 'auto-mode-alist '("\\.apl\\'" . dyalog-mode))
  (add-to-list 'auto-mode-alist '("\\.dyalog$" . dyalog-mode)) 
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; YAS Snippet

; I think org babel python wants this because I get an error related
; to symbol function definition is void
; yasnippet-snippet--fixed-indent
(use-package yasnippet :ensure t)
(use-package yasnippet-snippets :ensure t)
(yas-reload-all) 
(add-hook 'prog-mode-hook #'yas-minor-mode)
; Nope... that didn't fix it.
James Vasile's avatar
James Vasile committed
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Org Mode
(use-package org
  :ensure t)
(setq org-src-fontify-natively t)
(setq org-confirm-babel-evaluate nil)

(org-babel-do-load-languages
 'org-babel-load-languages
 '((python . t)
   (shell . t)
   (lisp . t)
   ))
(setq org-confirm-babel-evaluate nil)

(use-package org-roam
  :ensure t
  :custom
  (org-roam-directory (file-truename "~/Documents/org-roam/"))
  :bind (("C-c n l" . org-roam-buffer-toggle)
         ("C-c n f" . org-roam-node-find)
         ("C-c n g" . org-roam-graph)
         ("C-c n i" . org-roam-node-insert)
         ("C-c n c" . org-roam-capture)
         ;; Dailies
         ("C-c n j" . org-roam-dailies-capture-today))
  :config
  ;; If you're using a vertical completion framework, you might want a more informative completion interface
  (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag)))
  (org-roam-db-autosync-mode)
  ;; If using org-roam-protocol
  (require 'org-roam-protocol)
  (require 'org-roam-export) )
James Vasile's avatar
James Vasile committed
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Python
;;
(use-package jedi ; elpy wants this
  :ensure t
  :config
  ; We only need to do this once, not every time we start emacs
  ;(jedi:install-server)
  )

(use-package elpy
  ;; C-c C-p to launch REPL
  ;; C-c C-c to run the file in the REPL
  :ensure t
  :config

  ; enable elpy-goto-definition
  (add-hook 'python-mode-hook 'jedi-mode) 

  (elpy-enable)
  )

;; Connect to the python language server, enable completion.
(add-hook 'python-mode-hook #'lsp) ;; pip3 install python-lsp-server
(add-hook 'python-mode-hook #'yas-minor-mode) ;; completion needs this
(setq lsp-pylsp-plugins-rope-autoimport-enabled t)

;; enable ruff formatting linter
(use-package ruff-format
  :ensure t
  :config
  ;(add-hook 'python-mode-hook 'ruff-format-on-save-mode)
  )

;; We use ipython as our shell interpreter, mostly because it's good
;; for org-mode.
(setq python-shell-interpreter "ipython"
    python-shell-interpreter-args "-i --simple-prompt")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; YAML mode
;;
(add-to-list 'load-path "~/.emacs.d/3p/yaml-mode")
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
(add-hook 'yaml-mode-hook
	(lambda ()
	  (define-key yaml-mode-map "\C-m" 'newline-and-indent)))
James Vasile's avatar
James Vasile committed
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



;; Update packages
(use-package auto-package-update
   :ensure t
   :config
   (progn
       (setq auto-package-update-delete-old-versions t
	     auto-package-update-interval 7)
       (auto-package-update-maybe)
       t)
   )

James Vasile's avatar
James Vasile committed
;; Start emacsclient listener
James Vasile's avatar
James Vasile committed
(server-start)

;; We set this for init, but don't want it during normal operations
(setq debug-on-error nil)