Modify eglot stuff

This commit is contained in:
Alexander Rosenberg 2025-02-11 21:41:51 -08:00
parent 173178313e
commit 3ebc12ddc9
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

23
init.el
View File

@ -1318,25 +1318,29 @@ With PROJECT, give diagnostics for all buffers in the current project."
;; (trusted-files-eglot-ensure-if-safe))) ;; (trusted-files-eglot-ensure-if-safe)))
(defvar my/-eglot-documentation-buffer nil (defvar my/-eglot-documentation-buffer nil
"Buffer for showing documentation for `my/eglot-documentation-at-point'.") "Buffer for showing documentation for `my/eglot-documentation-at-point'.")
(define-derived-mode my/eglot-documentation-mode special-mode "Eglot-Doc"
"Major mode for eglot documentation buffers."
:interactive nil
(face-remap-add-relative 'nobreak-space 'default))
(defun my/eglot-documentation-at-point () (defun my/eglot-documentation-at-point ()
"Show documentation for a symbol at point." "Show documentation for a symbol at point."
(interactive) (interactive)
(if-let (server (eglot-current-server)) (if-let (server (eglot-current-server))
(progn (progn
(if-let* (((not (buffer-live-p my/-eglot-documentation-buffer))) (unless (buffer-live-p my/-eglot-documentation-buffer)
(name (generate-new-buffer-name "*eglot documentation*"))) (setq my/-eglot-documentation-buffer
(setq my/-eglot-documentation-buffer (generate-new-buffer name))) (get-buffer-create "*eglot documentation*")))
(eglot-hover-eldoc-function (eglot-hover-eldoc-function
(lambda (info _ _) (lambda (info _ _)
(if-let (((not (seq-empty-p info))) (if-let (((not (seq-empty-p info)))
(buff (current-buffer))) (buff (current-buffer)))
(with-current-buffer my/-eglot-documentation-buffer (with-current-buffer my/-eglot-documentation-buffer
(read-only-mode -1) (let ((inhibit-read-only t))
(unless (derived-mode-p 'my/eglot-documentation-mode)
(my/eglot-documentation-mode))
(erase-buffer) (erase-buffer)
(insert info) (insert info)
(goto-char (point-min)) (goto-char (point-min)))
(special-mode)
(read-only-mode 1)
(when (not (get-buffer-window my/-eglot-documentation-buffer nil)) (when (not (get-buffer-window my/-eglot-documentation-buffer nil))
(switch-to-buffer-other-window my/-eglot-documentation-buffer t) (switch-to-buffer-other-window my/-eglot-documentation-buffer t)
(switch-to-buffer-other-window buff t))))))))) (switch-to-buffer-other-window buff t)))))))))
@ -1962,8 +1966,7 @@ line in the block and manually deal with indentation."
t)) t))
(save-excursion (save-excursion
;; if we are on a blank line, move forward a line ;; if we are on a blank line, move forward a line
(when (zerop (length (buffer-substring-no-properties (when (= (pos-bol) (pos-eol))
(pos-bol) (pos-eol))))
(beginning-of-line 2)) (beginning-of-line 2))
(<= (count-lines (match-beginning 0) (pos-eol)) (<= (count-lines (match-beginning 0) (pos-eol))
(if-let ((match (match-string 1))) (if-let ((match (match-string 1)))
@ -2004,7 +2007,7 @@ line in the block and manually deal with indentation."
(defun my/-hyperspec-loopup-in-eww (oldfun &rest r) (defun my/-hyperspec-loopup-in-eww (oldfun &rest r)
(let ((browse-url-browser-function #'eww-browse-url)) (let ((browse-url-browser-function #'eww-browse-url))
(apply oldfun r))) (apply oldfun r)))
(advice-add 'hyperspec-lookup :around #'my/-hyperspec-loopup-in-eww) (advice-add 'common-lisp-hyperspec :around #'my/-hyperspec-loopup-in-eww)
(defvar-local my/-sly-fontification-buffer nil (defvar-local my/-sly-fontification-buffer nil
"The fontification buffer for the current sly buffer.") "The fontification buffer for the current sly buffer.")