Skip to content

Commit

Permalink
tweak(eglot): add a helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jun 11, 2023
1 parent 811b74b commit 56f430d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
12 changes: 12 additions & 0 deletions modules/me-prog.el
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@
(add-hook hook #'eglot-ensure)
(remove-hook hook #'lsp-deferred))))
:config
;; Modified from Crafted Emacs, pass `eglot-server-programs' to this function
;; to fill `+eglot-auto-enable-modes' with all supported modes.
(defun +eglot-use-on-all-supported-modes (mode-list)
(dolist (mode-def mode-list)
(let ((mode (if (listp mode-def) (car mode-def) mode-def)))
(cond
((listp mode) (+eglot-use-on-all-supported-modes mode))
(t
(when (and (not (eq 'clojure-mode mode)) ; prefer cider
(not (eq 'lisp-mode mode)) ; prefer sly
(not (eq 'scheme-mode mode))) ; prefer geiser
(add-to-list '+eglot-auto-enable-modes mode)))))))
(+map! :keymaps 'eglot-mode-map
:infix "c"
"fF" #'eglot-format-buffer
Expand Down
18 changes: 14 additions & 4 deletions skel/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,20 @@
:variable-pitch-font-size 16))

(+deferred!
;; Auto enable Eglot in supported modes using `+eglot-auto-enable' (from the
;; `me-prog' module). You can use `+lsp-auto-enable' instead to automatically
;; enable LSP mode in supported modes (from the `me-lsp' module).
(+eglot-auto-enable))
;; Auto enable Eglot in modes `+eglot-auto-enable-modes' using
;; `+eglot-auto-enable' (from the `me-prog' module). You can use
;; `+lsp-auto-enable' instead to automatically enable LSP mode in supported
;; modes (from the `me-lsp' module).
(+eglot-auto-enable)

;; Add `ocaml-mode' to `eglot' auto-enable modes
(add-to-list '+eglot-auto-enable-modes 'ocaml-mode)

(with-eval-after-load 'eglot
;; You can use this to fill `+eglot-auto-enable-modes' with all supported
;; modes from `eglot-server-programs'
(+eglot-use-on-all-supported-modes eglot-server-programs)))


;; If you installed Emacs from source, you can add the source code
;; directory to enable jumping to symbols defined in Emacs' C code.
Expand Down

0 comments on commit 56f430d

Please sign in to comment.