Skip to content

Instantly share code, notes, and snippets.

@the42
Created August 28, 2024 11:29
Show Gist options
  • Save the42/1edbc024b5a18cc950d4d51084d4bb89 to your computer and use it in GitHub Desktop.
Save the42/1edbc024b5a18cc950d4d51084d4bb89 to your computer and use it in GitHub Desktop.
Emacs config
;; Temporary to mitigate https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68668
;; (setopt native-comp-enable-subr-trampolines nil)
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
(set-default-coding-systems 'utf-8)
;; (add-to-list 'process-coding-system-alist '("grep" . (cp1252-dos)))
;; (add-to-list 'process-coding-system-alist '("find" . (cp1252-dos)))
;; (setq default-process-coding-system '(utf-8 . utf-8))
(setq default-process-coding-system '(utf-8-dos . cp1252-dos))
(global-set-key (kbd "C-c l") #'org-store-link)
(global-set-key (kbd "C-c a") #'org-agenda)
(global-set-key (kbd "C-c c") #'org-capture)
(global-set-key "\C-x\ \C-r" 'recentf-open)
(global-set-key "\C-x\ \C-n" 'dired-sidebar-toggle-sidebar)
;; use multiple dictionaries
;; https://www.reddit.com/r/emacs/comments/10336qd/ispellhunspell_doesnt_want_to_use_multiple/
(setq ispell-hunspell-dict-paths-alist
'(
("de_AT_frami" "C:\\Users\\HoechtlJ\\AppData\\Local\\Programs\\hunspell\\share\\hunspell\\de_AT_frami.aff")
("en_US" "C:\\Users\\HoechtlJ\\AppData\\Local\\Programs\\hunspell\\share\\hunspell\\en_US.aff"))
)
(use-package indent-bars
:load-path "~/.emacs.d/site-lisp/indent-bars/")
(use-package orderless
:ensure t
:init
;; Configure a custom style dispatcher (see the Consult wiki)
;; (setq orderless-style-dispatchers '(+orderless-dispatch)
;; orderless-component-separator #'orderless-escapable-split-on-space)
(setq completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides '((file (styles partial-completion)))
))
(use-package cape
;; Bind dedicated completion commands
;; Alternative prefix keys: C-c p, M-p, M-+, ...
:bind (
("C-c p p" . completion-at-point) ;; capf
("C-c p w" . cape-dict)
("C-c p f" . cape-file)
;; ("C-c p t" . complete-tag) ;; etags
;; ("C-c p d" . cape-dabbrev) ;; or dabbrev-completion
;; ("C-c p h" . cape-history)
;; ("C-c p k" . cape-keyword)
;; ("C-c p s" . cape-elisp-symbol)
;; ("C-c p e" . cape-elisp-block)
;; ("C-c p a" . cape-abbrev)
;; ("C-c p l" . cape-line)
;; ("C-c p \\" . cape-tex)
;; ("C-c p _" . cape-tex)
;; ("C-c p ^" . cape-tex)
;; ("C-c p &" . cape-sgml)
;; ("C-c p r" . cape-rfc1345)
)
:init
;; Add to the global default value of `completion-at-point-functions' which is
;; used by `completion-at-point'. The order of the functions matters, the
;; first function returning a result wins. Note that the list of buffer-local
;; completion functions takes precedence over the global list.
(add-to-list 'completion-at-point-functions #'cape-file)
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
;; (add-to-list 'completion-at-point-functions #'cape-elisp-block)
;;(add-to-list 'completion-at-point-functions #'cape-history)
;;(add-to-list 'completion-at-point-functions #'cape-keyword)
;;(add-to-list 'completion-at-point-functions #'cape-tex)
;;(add-to-list 'completion-at-point-functions #'cape-sgml)
;;(add-to-list 'completion-at-point-functions #'cape-rfc1345)
;;(add-to-list 'completion-at-point-functions #'cape-abbrev)
;;(add-to-list 'completion-at-point-functions #'cape-dict)
;;(add-to-list 'completion-at-point-functions #'cape-elisp-symbol)
;;(add-to-list 'completion-at-point-functions #'cape-line)
(setq completion-ignore-case t)
)
(defun my-insert-date-prompt ()
"Insert a date at point using `org-read-date' with its optional argument
of TO-TIME so that the user can customize the date format more easily.
Also, copy the time-string to the `kill-ring'."
(interactive)
(require 'org)
(let* ((time (org-read-date nil 'to-time nil "Date: "))
(time-string (format-time-string "%Y-%m-%d" time)))
(kill-new time-string)
(insert time-string)
))
;; https://www.reddit.com/r/emacs/comments/1447fy2/looking_for_help_in_improving_typescript_eglot/
(fset #'jsonrpc--log-event #'ignore)
(add-hook 'prog-mode-hook
(lambda ()
(ispell-change-dictionary "en_US")
(flyspell-prog-mode)
(hs-minor-mode)
(yas-minor-mode)
(corfu-mode)
(corfu-terminal-mode)
(display-fill-column-indicator-mode)
(display-line-numbers-mode)
))
(defun my-lsp-go-install-save-hooks ()
(add-hook 'before-save-hook #'eglot-format-buffer t t)
)
(add-hook 'go-mode-hook
(lambda ()
(my-lsp-go-install-save-hooks)
(eglot-ensure)
))
(add-hook 'markdown-mode-hook
(lambda()
(ispell-change-dictionary "de_AT_frami")
(flyspell-mode)
;; activate it to physically break lines.
;; (refill-mode)
;; if refill-mode is activated, should then deactivate the
;; following block
(word-wrap-whitespace-mode)
;; visual-line-mode disables fringe indicators, yet they
;; are helpful, so still use them
(setq visual-line-fringe-indicators '(left-curly-arrow right-curly-arrow))
(visual-line-mode)
(adaptive-wrap-prefix-mode)
;; (visual-fill-column-mode) ;; activate it to visually break long lines at fill column
(set-fringe-bitmap-face 'left-curly-arrow 'window-divider-last-pixel)
(set-fringe-bitmap-face 'right-curly-arrow 'window-divider-last-pixel)
(corfu-mode)
(corfu-terminal-mode)
(setq-default indent-tabs-mode nil)
))
;; setting this through customize doesn't prevent winner-mode from
;; grabbing key bindings, therefore setting it here
(setq winner-dont-bind-my-keys 't)
(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.
'(calendar-week-start-day 1)
'(column-number-mode t)
'(completion-auto-help 'always)
'(completion-auto-select 'second-tab)
'(connection-local-criteria-alist
'(((:application eshell) eshell-connection-default-profile)))
'(connection-local-profile-alist
'((eshell-connection-default-profile (eshell-path-env-list))))
'(corfu-auto t)
'(corfu-auto-prefix 2)
'(corfu-cycle t)
'(corfu-on-exact-match 'quit)
'(corfu-quit-at-boundary 'separator)
'(csv-separators '(";" "," "\11"))
'(custom-enabled-themes '(tango-dark))
'(custom-safe-themes
'("9fb561389e5ac5b9ead13a24fb4c2a3544910f67f12cfcfe77b75f36248017d0"
default))
'(delete-auto-save-files t)
'(delete-selection-mode t)
'(desktop-lazy-verbose nil)
'(desktop-path '("~/.emacs.d/" "~" "."))
'(desktop-restore-eager t)
'(desktop-save 'if-exists)
'(desktop-save-mode t)
'(dired-auto-revert-buffer t)
'(dired-kill-when-opening-new-dired-buffer t)
'(ediff-keep-variants nil)
'(ediff-split-window-function 'split-window-horizontally)
'(ediff-window-setup-function 'ediff-setup-windows-plain)
'(ffap-file-name-with-spaces t)
'(ffap-require-prefix nil)
'(fido-mode t)
'(global-auto-revert-mode t)
'(impatient-showdown-markdown-background-color "#f2f2f2")
'(indent-bars-color '(highlight :face-bg t :blend 0.2))
'(indent-bars-prefer-character t)
'(inhibit-startup-screen t)
'(initial-major-mode 'text-mode)
'(initial-scratch-message nil)
'(ispell-local-dictionary-alist
'(("de_AT_frami" "[[:alpha:]ÄÖÜéäöüß]" "[^[:alpha:]ÄÖÜéäöüß]" "[']"
nil
("-d" "de_AT_frami" "-p"
"C:\\Users\\HoechtlJ\\AppData\\Local\\Programs\\hunspell\\share\\hunspell\\personal.de")
nil utf-8)
("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US")
nil undecided)))
'(kill-buffer-delete-auto-save-files t)
'(make-backup-files nil)
'(marginalia-mode t)
'(markdown-asymmetric-header t)
'(markdown-disable-tooltip-prompt t)
'(markdown-fontify-code-blocks-natively t)
'(markdown-gfm-uppercase-checkbox t)
'(markdown-header-scaling t)
'(markdown-header-scaling-values '(1.2 1.15 1.1 1.0 1.0 1.0))
'(markdown-unordered-list-item-prefix " - ")
'(mouse-buffer-menu-mode-mult 1)
'(next-error-message-highlight 'keep)
'(outline-minor-mode-use-buttons t)
'(package-selected-packages
'(adaptive-wrap cape corfu corfu-terminal csv-mode d2-mode dape
dired-sidebar edit-indirect eglot
gnu-elpa-keyring-update go-mode hideshowvis
impatient-showdown magit marginalia markdown-mode
olivetti orderless visual-fill-column vundo
yasnippet))
'(pixel-scroll-precision-mode t)
'(recentf-max-menu-items 30)
'(recentf-max-saved-items 50)
'(recentf-mode t)
'(ring-bell-function 'ignore)
'(save-place-mode t)
'(savehist-additional-variables '(search-ring regexp-search-ring global-mark-ring))
'(savehist-mode t)
'(show-paren-context-when-offscreen t)
'(speedbar-show-unknown-files t)
'(speedbar-supported-extension-expressions
'(".[ch]\\(\\+\\+\\|pp\\|c\\|h\\|xx\\)?" ".tex\\(i\\(nfo\\)?\\)?"
".el" ".emacs" ".l" ".lsp" ".p" ".java" ".js"
".f\\(90\\|77\\|or\\)?" ".ad[abs]" ".p[lm]" ".tcl" ".m" ".scm"
".pm" ".py" ".g" ".lua" ".s?html" ".ma?k"
"[Mm]akefile\\(\\.in\\)?" ".md"))
'(sql-ms-options '("-w" "300"))
'(sql-ms-program "sqlcmd")
'(tab-always-indent 'complete)
'(tab-bar-close-last-tab-choice nil)
'(tab-bar-mode t)
'(tab-bar-new-tab-to 'rightmost)
'(tab-bar-position t)
'(tab-width 4)
'(text-mode-ispell-word-completion nil)
'(undo-limit 1000000)
'(visible-bell t)
'(windmove-default-keybindings '([ignore] meta control))
'(windmove-mode t)
'(winner-mode t)
'(yas-reload-all nil))
(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.
'(default ((t (:family "Consolas" :foundry "outline" :slant normal :weight regular :height 120 :width normal))))
'(eglot-mode-line ((t (:inherit nil :weight bold))))
'(markdown-code-face ((t (:inherit font-lock-doc-face)))))
(put 'narrow-to-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment