From 2b65287a624c140a69e13dd0f0ba78b2bd6a618d Mon Sep 17 00:00:00 2001 From: Vladislav Slobodenyuk Date: Wed, 21 Jan 2026 17:37:44 +0900 Subject: [PATCH] Fix embark, add tempel --- .config.d/10-completion.el | 13 +++++----- .config.d/15-lsp.el | 52 +++++++++++++++++++++++++++++--------- .gitignore | 1 + templates | 3 +++ 4 files changed, 51 insertions(+), 18 deletions(-) create mode 100644 templates diff --git a/.config.d/10-completion.el b/.config.d/10-completion.el index ec38ef9..8aefc72 100644 --- a/.config.d/10-completion.el +++ b/.config.d/10-completion.el @@ -53,7 +53,7 @@ ;; completion-at-point-functions (Capfs). (use-package cape :ensure t - :defer t + :defer nil :commands (cape-dabbrev cape-file cape-elisp-block) :bind ("C-c p" . cape-prefix-map) :init @@ -127,16 +127,17 @@ :init (setq prefix-help-command #'embark-prefix-help-command) - (push 'embark--allow-edit - (alist-get 'eglot-code-actions embark-target-injection-hooks)) - (push 'embark--ignore-target - (alist-get 'eglot-code-actions embark-target-injection-hooks)) + :config ;; Hide the mode line of the Embark live/completions buffers (add-to-list 'display-buffer-alist '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" nil - (window-parameters (mode-line-format . none))))) + (window-parameters (mode-line-format . none)))) + (push 'embark--allow-edit + (alist-get 'eglot-code-actions embark-target-injection-hooks)) + (push 'embark--ignore-target + (alist-get 'eglot-code-actions embark-target-injection-hooks))) ;; This package provides some integrations between the emabrk and ;; consult packages. diff --git a/.config.d/15-lsp.el b/.config.d/15-lsp.el index 8bf2fca..6121b88 100644 --- a/.config.d/15-lsp.el +++ b/.config.d/15-lsp.el @@ -168,17 +168,45 @@ control codes are not supported." (indent-bars-treesit-wrap '((rust arguments parameters))) :hook ((python-base-mode yaml-mode rust-mode) . indent-bars-mode)) -;; Ellama allows using LLMs from emacs. -(use-package ellama - :ensure nil - :defer t - :bind ("C-c e" . ellama) - :init (setopt ellama-auto-scroll t) - :commands (ellama) - :config - ;; show ellama context in header line in all buffers - (ellama-context-header-line-global-mode +1) - ;; show ellama session id in header line in all buffers - (ellama-session-header-line-global-mode +1)) +;; Configure Tempel +(use-package tempel + :bind (("M-+" . tempel-complete) ;; Alternative tempel-expand + ("M-*" . tempel-insert)) + + :init + + ;; Setup completion at point + (defun tempel-setup-capf () + ;; Add the Tempel Capf to `completion-at-point-functions'. `tempel-expand' + ;; only triggers on exact matches. We add `tempel-expand' *before* the main + ;; programming mode Capf, such that it will be tried first. + (setq-local completion-at-point-functions + (cons #'tempel-expand completion-at-point-functions)) + + ;; Alternatively use `tempel-complete' if you want to see all matches. Use + ;; a trigger prefix character in order to prevent Tempel from triggering + ;; unexpectly. + ;; (setq-local corfu-auto-trigger "/" + ;; completion-at-point-functions + ;; (cons (cape-capf-trigger #'tempel-complete ?/) + ;; completion-at-point-functions)) + ) + + (add-hook 'conf-mode-hook 'tempel-setup-capf) + (add-hook 'prog-mode-hook 'tempel-setup-capf) + (add-hook 'text-mode-hook 'tempel-setup-capf) + + (setq tempel-path (concat minimal-emacs-user-directory "templates")) + + ;; Optionally make the Tempel templates available to Abbrev, + ;; either locally or globally. `expand-abbrev' is bound to C-x '. + ;; (add-hook 'prog-mode-hook #'tempel-abbrev-mode) + ;; (global-tempel-abbrev-mode) + ) + +;; Optional: Add tempel-collection if you want ready-made templates. Yes sir, I +;; do. +(use-package tempel-collection) + ;;; 15-lsp.el end here diff --git a/.gitignore b/.gitignore index 57212fa..0202525 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ !post-init.el !.config.d/ !.config.d/* +!templates diff --git a/templates b/templates new file mode 100644 index 0000000..6a09549 --- /dev/null +++ b/templates @@ -0,0 +1,3 @@ +emacs-lisp-mode + +(up "(use-package " p n> ":ensure t" n> ":defer t" n ")")