From 3ebc12ddc94ce00587de5eba7e6ea40a197fb83f Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Tue, 11 Feb 2025 21:41:51 -0800 Subject: [PATCH] Modify eglot stuff --- init.el | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/init.el b/init.el index d413965..9fcc564 100644 --- a/init.el +++ b/init.el @@ -1318,25 +1318,29 @@ With PROJECT, give diagnostics for all buffers in the current project." ;; (trusted-files-eglot-ensure-if-safe))) (defvar my/-eglot-documentation-buffer nil "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 () "Show documentation for a symbol at point." (interactive) (if-let (server (eglot-current-server)) (progn - (if-let* (((not (buffer-live-p my/-eglot-documentation-buffer))) - (name (generate-new-buffer-name "*eglot documentation*"))) - (setq my/-eglot-documentation-buffer (generate-new-buffer name))) + (unless (buffer-live-p my/-eglot-documentation-buffer) + (setq my/-eglot-documentation-buffer + (get-buffer-create "*eglot documentation*"))) (eglot-hover-eldoc-function (lambda (info _ _) (if-let (((not (seq-empty-p info))) (buff (current-buffer))) (with-current-buffer my/-eglot-documentation-buffer - (read-only-mode -1) - (erase-buffer) - (insert info) - (goto-char (point-min)) - (special-mode) - (read-only-mode 1) + (let ((inhibit-read-only t)) + (unless (derived-mode-p 'my/eglot-documentation-mode) + (my/eglot-documentation-mode)) + (erase-buffer) + (insert info) + (goto-char (point-min))) (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 buff t))))))))) @@ -1962,8 +1966,7 @@ line in the block and manually deal with indentation." t)) (save-excursion ;; if we are on a blank line, move forward a line - (when (zerop (length (buffer-substring-no-properties - (pos-bol) (pos-eol)))) + (when (= (pos-bol) (pos-eol)) (beginning-of-line 2)) (<= (count-lines (match-beginning 0) (pos-eol)) (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) (let ((browse-url-browser-function #'eww-browse-url)) (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 "The fontification buffer for the current sly buffer.")