commit 3862587180e1a41df853a70f92710ad917bcefac
parent 344e9deaa50fc22a981f7940aa79c9f17e635ce1
Author: dwrz <dwrz@dwrz.net>
Date: Sun, 17 Nov 2024 16:05:39 +0000
Update Emacs init
Diffstat:
M | emacs/init.el | | | 101 | ++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------- |
1 file changed, 64 insertions(+), 37 deletions(-)
diff --git a/emacs/init.el b/emacs/init.el
@@ -73,19 +73,6 @@
(interactive)
(org-capture 0))
-(defun dwrz-shell-in-current-directory ()
- "Create or switch to a shell buffer for the current directory."
- (interactive)
- (let* ((default-directory (if (buffer-file-name)
- (file-name-directory (buffer-file-name))
- default-directory))
- (dir-path (expand-file-name default-directory))
- (shell-buffer-name (concat "*shell:" dir-path "*"))
- (existing-shell-buffer (get-buffer shell-buffer-name)))
- (if existing-shell-buffer
- (switch-to-buffer existing-shell-buffer)
- (shell (generate-new-buffer-name shell-buffer-name)))))
-
(defun dwrz-vterm-in-current-directory ()
"Create or switch to a vterm buffer for the current directory."
(interactive)
@@ -156,8 +143,6 @@
(add-to-list 'completion-at-point-functions #'cape-file)
(add-to-list 'completion-at-point-functions #'cape-keyword)
(add-to-list 'completion-at-point-functions #'cape-history)
- (add-to-list 'completion-at-point-functions #'cape-sgml)
- (add-to-list 'completion-at-point-functions #'cape-rfc1345)
:ensure t)
(use-package cc-vars
@@ -312,15 +297,10 @@
(embark-collect-mode . consult-preview-at-point-mode))
(use-package faces
- :config (set-face-attribute
- 'default t
- :family "DejaVu Sans Mono"
- :foundry "PfEd"
- :slant 'normal
- :weight 'normal
- :height 190
- :width 'normal)
- (setq default-frame-alist '((font . "DejaVu Sans Mono-16")))
+ :config
+ (let ((font "DejaVu Sans Mono-16"))
+ (set-face-attribute 'default nil :font font)
+ (add-to-list 'default-frame-alist `(font . ,font)))
:custom (face-font-family-alternatives
'(("hans" "adobe-source-han-sans-cn-font"))))
@@ -337,11 +317,17 @@
(use-package flyspell
:bind (:map flyspell-mode-map ("C-;" . nil))
+ :defer t
+ :hook ((text-mode . flyspell-mode)
+ (prog-mode . flyspell-prog-mode))
:ensure nil)
(use-package frame :config (window-divider-mode -1) :ensure nil)
-(use-package gnutls :config (setq gnutls-verify-error t) :ensure nil)
+(use-package gnutls
+ :config (setq gnutls-verify-error t)
+ :defer t
+ :ensure nil)
(use-package go-mode
:bind (:map go-mode-map
@@ -351,22 +337,50 @@
:defer t
:ensure t
:hook ((go-mode . lsp)
- (go-mode . (lambda () (set (make-local-variable 'before-save-hook)
- '(lsp-organize-imports lsp-format-buffer))))))
+ (go-mode . (lambda ()
+ (add-hook 'before-save-hook #'lsp-organize-imports nil t)
+ (add-hook 'before-save-hook #'lsp-format-buffer nil t))))
+ :mode "\\.go\\'")
(use-package go-playground
:config (setq go-playground-ask-file-name nil
go-playground-basedir "~/.local/share/go/src/playground/"
- go-playground-go-command "GO111MODULE=auto go"
go-playground-init-command "go mod init")
:defer t
:ensure t)
(use-package go-tag
+ :after go-mode
:config (setq go-tag-args (list "-transform" "camelcase"))
:defer t
:ensure t)
+(use-package gptel
+ :commands (gptel gtpel-send gptel-send-region gptel-send-buffer)
+ :config
+ (setq gptel-api-key (password-store-get "open-ai/emacs")
+ gptel-default-mode 'org-mode)
+ (gptel-make-ollama "Ollama"
+ :host "localhost:11434"
+ :stream t
+ :models '(llama3.2:latest codeqwen:latest))
+ (gptel-make-openai "OpenRouter"
+ :host "openrouter.ai"
+ :endpoint "/api/v1/chat/completions"
+ :stream t
+ :key (password-store-get "openrouter.ai/keys/emacs")
+ :models '(openai/gpt-4o-2024-08-06
+ meta-llama/llama-3.1-70b-instruct:free
+ meta-llama/llama-3.1-70b-instruct
+ meta-llama/llama-3.1-70b-instruct:nitro
+ meta-llama/llama-3.1-405b-instruct
+ meta-llama/llama-3.1-405b-instruct:free
+ meta-llama/llama-3.1-405b-instruct:nitro
+ anthropic/claude-3.5-sonnet
+ anthropic/claude-3-5-haiku))
+ :defer t
+ :ensure t)
+
(use-package hl-line
:config (global-hl-line-mode t)
:ensure nil)
@@ -577,9 +591,9 @@
(defun dwrz-switch-org-ctx (ctx)
"Switch org agenda context."
(cond ((string= ctx "") (setq org-agenda-files (append
- chimerical-agenda-files
- dwrz-agenda-files
- eti-agenda-files)))
+ chimerical-agenda-files
+ dwrz-agenda-files
+ eti-agenda-files)))
((string= ctx "chimerical") (setq org-agenda-files
chimerical-agenda-files))
((string= ctx "dwrz") (setq org-agenda-files
@@ -663,7 +677,13 @@
(use-package password-store :defer t :ensure t)
-(use-package pdf-tools :ensure t)
+(use-package pdf-tools
+ :config (setq pdf-view-display-size 'fit-page)
+ :ensure t
+ :hook (pdf-view-mode . (lambda ()
+ (unless (featurep 'pdf-tools)
+ (pdf-tools-install))))
+ :mode ("\\.pdf\\'" . pdf-view-mode))
(use-package plantuml-mode
:config (setq org-plantuml-jar-path (expand-file-name
@@ -720,6 +740,7 @@
(set-register ?h '(file . "~/projects/home/"))
(set-register ?i '(file . "~/.config/emacs/init.el"))
(set-register ?j '(file . "~/journal/2024/2024.org"))
+ (set-register ?k '(file . "~/projects/chimerical/"))
(set-register ?n '(file . "~/projects/net/"))
(set-register ?o '(file . "~/org/"))
(set-register ?p '(file . "~/projects/")))
@@ -800,7 +821,10 @@
(use-package tool-bar :config (tool-bar-mode -1) :ensure nil)
-(use-package tramp :config (setq tramp-default-method "rsync") :ensure nil)
+(use-package tramp
+ :config (setq tramp-default-method "rsync")
+ :defer t
+ :ensure nil)
(use-package vertico
:config
@@ -1032,7 +1056,6 @@
:doc "Prefix keymap for terminal."
:name "Terminal"
"c" #'vterm-copy-mode
- "s" #'dwrz-shell-in-current-directory
"t" #'term
"v" #'dwrz-vterm-in-current-directory)
@@ -1086,7 +1109,9 @@
:name "dwrz prefix"
:repeat (:exit (ignore))
"#" #'display-line-numbers-mode
+ "&" #'async-shell-command
"-" #'negative-argument
+ ":" #'eval-expression
";" (cons "terminal" dwrz-terminal-map)
"<" #'undo
"<down>" #'windmove-down
@@ -1096,6 +1121,7 @@
">" #'undo-redo
"?" (cons "help" help-map)
"@" (cons "time" dwrz-time-map)
+ "A" #'gptel-menu
"E" #'hippie-expand
"F" #'consult-find
"H" (cons "highlight" dwrz-highlight-map)
@@ -1113,7 +1139,7 @@
"h" #'hippie-expand
"i" (cons "insert" dwrz-insert-map)
"j" (cons "jump" #'jump-to-register)
- "l" (cons "line" #'avy-goto-line)
+ "l" (cons "line" #'consult-goto-line)
"m" (cons "move" dwrz-movement-map)
"n" (cons "narrow" narrow-map)
"o" (cons "org" dwrz-org-map)
@@ -1125,9 +1151,10 @@
"u" #'universal-argument
"v" #'vundo
"w" (cons "window" dwrz-windows-map)
- "z" (cons "zoom" dwrz-zoom-map))
+ "y" #'yasnippet-capf
+ "z" (cons "zoom" dwrz-zoom-map)
+ "|" #'shell-command-on-region)
;; KEYBINDINGS
(global-set-key (kbd "C-z") dwrz-prefix-map)
(global-set-key (kbd "C-;") dwrz-prefix-map)
-(global-set-key (kbd "C-,") dwrz-prefix-map)