I have the below setting in my config as recommended by many scrolling packages like ultra-scroll-mac
.
(setq scroll-conservatively 101)
The issue is, when using this config with lsp-mode
, xref-go-back
will not recenter the point to the middle of the window, but instead it recenter the point to the bottom of the window.
For example, before xref-find-definitions
after xref-find-definitions
after xref-go-back
I tested in a emacs -q
settings with the config below, I am not sure if it's a lsp-mode
issue so I have not reported it there. Also the issue is gone if scroll-conservatively
is 0
or not using lsp-mode
(e.g. using xref-go-back
in plain emacs-lisp-mode
).
I tried something like
(defun xref-go-back-fixes (orig-func &rest args)
(let ((scroll-conservatively 0))
(apply orig-func args)))
(advice-add 'xref-go-back :around #'xref-go-back-fixes)
But it does not work. Unless I eval (setq scroll-conservatively 0)
in the minibuffer, the issue is still there.
Any help or suggestion will be greatly appreciated!
;; -*- lexical-binding: t; -*-
(defvar elpaca-installer-version 0.6)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
:ref nil
:files (:defaults "elpaca-test.el" (:exclude "extensions"))
:build (:not elpaca--activate-package)))
(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory))
(build (expand-file-name "elpaca/" elpaca-builds-directory))
(order (cdr elpaca-order))
(default-directory repo))
(add-to-list 'load-path (if (file-exists-p build) build repo))
(unless (file-exists-p repo)
(make-directory repo t)
(when (< emacs-major-version 28) (require 'subr-x))
(condition-case-unless-debug err
(if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
((zerop (call-process "git" nil buffer t "clone"
(plist-get order :repo) repo)))
((zerop (call-process "git" nil buffer t "checkout"
(or (plist-get order :ref) "--"))))
(emacs (concat invocation-directory invocation-name))
((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
"--eval" "(byte-recompile-directory \".\" 0 'force)")))
((require 'elpaca))
((elpaca-generate-autoloads "elpaca" repo)))
(progn (message "%s" (buffer-string)) (kill-buffer buffer))
(error "%s" (with-current-buffer buffer (buffer-string))))
((error) (warn "%s" err) (delete-directory repo 'recursive))))
(unless (require 'elpaca-autoloads nil t)
(require 'elpaca)
(elpaca-generate-autoloads "elpaca" repo)
(load "./elpaca-autoloads")))
(add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order))
(elpaca elpaca-use-package
(elpaca-use-package-mode)
(setq elpaca-use-package-by-default t))
(elpaca-wait)
(setq use-package-verbose nil
use-package-enable-imenu-support t
use-package-always-defer t)
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-ts-mode))
(use-package lsp-mode
:defer 3
:diminish (lsp-mode)
:hook ((rust-ts-mode)
. (lambda () (run-with-idle-timer 0.2 nil #'lsp-deferred))))
(use-package lsp-rust
:elpaca nil
:demand t
:after (:all lsp-mode rust-ts-mode)
:init (setq lsp-rust-clippy-preference "on"
lsp-rust-analyzer-cargo-watch-command "clippy"))
(elpaca-wait)
eglot
.