dotfiles/doom/.doom.d/config.el

153 lines
5.3 KiB
EmacsLisp
Raw Normal View History

2022-11-05 20:57:02 +01:00
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets. It is optional.
(setq user-full-name "Jeffrey Serio"
user-mail-address "hyperreal@fedoraproject.org")
;; See 'C-h v doom-font' for documentation and more examples of what they
;; accept. For example:
2023-05-18 17:04:51 +02:00
(setq doom-font (font-spec :family "JetBrains Mono Nerd Font Mono" :size 18)
doom-variable-pitch-font (font-spec :family "Rubik")
2023-05-18 17:04:51 +02:00
doom-unicode-font (font-spec :family "JetBrains Mono Nerd Font Mono" :size 18)
doom-big-font (font-spec :family "JetBrains Mono Nerd Font Mono" :size 18))
2022-11-05 20:57:02 +01:00
;; Use catppuccin-mocha theme
2023-05-18 17:04:51 +02:00
(setq doom-theme 'catppuccin)
(setq catppuccin-flavor 'mocha)
2022-11-05 20:57:02 +01:00
;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type 'relative)
;; If you use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/Nextcloud/org/")
;; Set bpython as Python shell interpreter
(add-hook! python-mode-hook
(setq python-shell-interpreter "bpython"))
;; Make vterm open in another window
(setq vterm-other-window 1)
;; Keybinding to kill-whole-line
(global-set-key (kbd "M-9") 'kill-whole-line)
;; Popup rule for yasnippet
(defun yas-popup-isearch-prompt (prompt choices &optional display-fn)
(when (featurep 'popup)
(popup-menu*
(mapcar
(lambda (choice)
(popup-make-item
(or (and display-fn (funcall display-fn choice))
choice)
:value choice))
choices)
:prompt prompt
;; start isearch mode immediately
:isearch t
)))
(setq yas-prompt-functions '(yas-popup-isearch-prompt yas-maybe-ido-prompt yas-completing-prompt yas-no-prompt))
;; Copy all or text selection
(defun xah-copy-all-or-region ()
"Put the whole buffer content to `kill-ring', or text selection if there's one.
Respects `narrow-to-region'.
URL `https://ergomacs.org/emacs/emacs_copy_cut_all_or_region.html'
Version 2015-08-22"
(interactive)
(if (use-region-p)
(progn
(kill-new (buffer-substring (region-beginning) (region-end)))
(message "Text selection copied."))
(progn
(kill-new (buffer-string))
(message "Buffer content copied."))))
;; Cut all or text selection
(defun xah-cut-all-or-region ()
"Cut the whole buffer content to `kill-ring', or text selection if there's one.
Respects `narrow-to-region'.
URL `https://ergomacs.org/emacs/emacs_copy_cut_all_or_region.html'
Version 2015-08-22"
(interactive)
(if (use-region-p)
(progn
(kill-new (buffer-substring (region-beginning) (region-end)))
(delete-region (region-beginning) (region-end)))
(progn
(kill-new (buffer-string))
(delete-region (point-min) (point-max)))))
2022-11-24 07:10:34 +01:00
;; open URL in Firefox
(defun browse-host-firefox (url &rest ignored)
2022-11-05 20:57:02 +01:00
"Browse URL with the host's Firefox using distrobox-exec."
(interactive "sURL: ")
(shell-command (concat "firefox " url)))
2022-11-05 20:57:02 +01:00
2022-11-24 07:10:34 +01:00
(setq browse-url-browser-function 'browse-host-firefox)
2022-11-05 20:57:02 +01:00
;; after copy Ctrl+c in Linux X11, you can paste by `yank' in emacs
(setq select-enable-clipboard t)
;; after mouse selection copy in X11, you can paste by `yank' in emacs
(setq select-enable-primary t)
;; set keybinding for paste
(global-set-key (kbd "C-S-V") #'clipboard-yank)
;; Smart home key
(defun smart-beginning-of-line ()
"Move point to first non-whitespace character or beginning-of-line.
Move point to the first non-whitespace character on this line.
If point was already at that position, move point to beginning of line."
(interactive "^")
(let ((oldpos (point)))
(back-to-indentation)
(and (= oldpos (point))
(beginning-of-line))))
(global-set-key (kbd "<home>") 'smart-beginning-of-line)
(global-set-key (kbd "<end>") 'end-of-line)
;; Autoformat on save
(setq +format-on-save-enabled-modes
'(emacs-lisp-mode
python-mode))
(setq-hook! 'python-mode-hook +format-with 'black)
;; org-mode, close items with timestamp
(setq org-log-done 'time)
;; open Emacs in a maxmimized window
2023-05-18 17:04:51 +02:00
;(add-to-list 'default-frame-alist '(fullscreen . maximized))
2022-11-05 20:57:02 +01:00
;; mastodon
2022-11-24 07:10:34 +01:00
(setq mastodon-instance-url "https://mastodon.hyperreal.coffee"
2022-11-05 20:57:02 +01:00
mastodon-active-user "hyperreal")
2022-11-24 07:10:34 +01:00
;; keybinds for evil-nerd-commenter
(global-set-key (kbd "M-;") 'evilnc-comment-or-uncomment-lines)
(global-set-key (kbd "C-c l") 'evilnc-quick-comment-or-uncomment-to-the-line)
(global-set-key (kbd "C-c c") 'evilnc-copy-and-comment-lines)
(global-set-key (kbd "C-c p") 'evilnc-comment-or-uncomment-paragraphs)
2023-05-18 17:04:51 +02:00
;; completion for GoLang
(add-hook 'completion-at-point-functions 'go-complete-at-point)
;; Go - lsp-mode
(defun lsp-go-install-save-hooks ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
(add-hook 'go-mode-hook #'lsp-go-install-save-hooks)
;; Start LSP Mode
(add-hook 'go-mode-hook #'lsp-deferred)
;; EPUB - nov.el and nov-xwidget
(setq nov-variable-pitch nil)