Closed SamuelBanya closed 2 years ago
I had the same problem in Linux (Emacs 28.1 with Cairo) for a long time. So I decided to dive into the lsp-ui source code and solved it (link) for my use case. I don't know if it is the right solution, but it's working like a charm.
I've created a snippet to test/show the behavior without extra dependencies:
;; This overlay overflows
(let* ((p (line-end-position))
(ov (make-overlay p p))
(msg (propertize "This overlay overflows to the next line. Bad, bad overlay..." 'face 'error))
(string (concat (propertize " " 'display `(space :align-to (- right-fringe ,(1+ (length msg))))) msg)))
(overlay-put ov 'after-string string))
;; This overlay doesn't overflow
(let* ((p (line-end-position))
(ov (make-overlay p p))
(msg (propertize "This overlay DOESN'T overflow to the next line. Woo-hoo!!!!!" 'face 'error))
(string (concat (propertize " " 'display `(space :align-to (- right-fringe (,(1+ (length msg)) . width)))) msg)))
(overlay-put ov 'after-string string))
Hey @gustavotcabral
Question regarding workflow for this particular patch:
Should I put this in a custom function within the ':config' section of my 'use-package' config for 'lsp-mode' in my config? : https://github.com/SamuelBanya/SamsEmacs/blob/main/configuration.org
Or do I have to use Straight.el to benefit from this fix?
Thanks,
Sam
On Fri, Jun 17, 2022, at 2:00 PM, gustavotcabral wrote:
I had the same problem in Linux (Emacs 28.1 with Cairo) for a long time. So I decided to dive into the lsp-ui source code and solved it (link https://github.com/emacs-lsp/lsp-ui/issues/184#issuecomment-1158057166) for my use case. I don't know if it is the right solution, but it's working like a charm.
I've created a snippet to test/show the behavior without extra dependencies:
;; This overlay overflows (let* ((p (line-end-position)) (ov (make-overlay p p)) (msg (propertize "This overlay overflows to the next line. Bad, bad overlay..." 'face 'error)) (string (concat (propertize " " 'display `(space :align-to (- right-fringe ,(1+ (length msg))))) msg))) (overlay-put ov 'after-string string))
;; This overlay doesn't overflow (let* ((p (line-end-position)) (ov (make-overlay p p)) (msg (propertize "This overlay DOESN'T overflow to the next line. Woo-hoo!!!!!" 'face 'error)) (string (concat (propertize " " 'display `(space :align-to (- right-fringe (,(1+ (length msg)) . width)))) msg))) (overlay-put ov 'after-string string)) overlays https://user-images.githubusercontent.com/15175513/174352744-3036661a-b3af-421b-b0eb-f45592da6fa4.png
— Reply to this email directly, view it on GitHub https://github.com/emacs-lsp/lsp-ui/issues/716#issuecomment-1159114632, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVU3GXOSMCADJ7NBIIKHGR3VPS4NXANCNFSM5X5NVJKQ. You are receiving this because you authored the thread.Message ID: @.***>
Hey @gustavotcabral Question regarding workflow for this particular patch: Should I put this in a custom function within the ':config' section of my 'use-package' config for 'lsp-mode' in my config? : https://github.com/SamuelBanya/SamsEmacs/blob/main/configuration.org Or do I have to use Straight.el to benefit from this fix? Thanks, Sam … On Fri, Jun 17, 2022, at 2:00 PM, gustavotcabral wrote: I had the same problem in Linux (Emacs 28.1 with Cairo) for a long time. So I decided to dive into the lsp-ui source code and solved it (link <#184 (comment)>) for my use case. I don't know if it is the right solution, but it's working like a charm. I've created a snippet to test/show the behavior without extra dependencies: ;; This overlay overflows (let ((p (line-end-position)) (ov (make-overlay p p)) (msg (propertize "This overlay overflows to the next line. Bad, bad overlay..." 'face 'error)) (string (concat (propertize " " 'display `(space :align-to (- right-fringe ,(1+ (length msg))))) msg))) (overlay-put ov 'after-string string)) ;; This overlay doesn't overflow (let ((p (line-end-position)) (ov (make-overlay p p)) (msg (propertize "This overlay DOESN'T overflow to the next line. Woo-hoo!!!!!" 'face 'error)) (string (concat (propertize " " 'display `(space :align-to (- right-fringe (,(1+ (length msg)) . width)))) msg))) (overlay-put ov 'after-string string)) overlays https://user-images.githubusercontent.com/15175513/174352744-3036661a-b3af-421b-b0eb-f45592da6fa4.png — Reply to this email directly, view it on GitHub <#716 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVU3GXOSMCADJ7NBIIKHGR3VPS4NXANCNFSM5X5NVJKQ. You are receiving this because you authored the thread.Message ID: @.***>
Hi, @SamuelBanya.
To test the fix, yank the new function in a lisp-interaction-mode
or emacs-lisp-mode
buffer (I use *scratch*
), put the point after the last )
and call eval-last-sexp
(or C-x C-e
). The first LSP sideline created after this eval will use the new behavior.
I use a mybugs.el
file:
(eval-after-load 'lsp-ui-sideline
(defun ... custom-code-here ...))
I've never used use-package
. Maybe it's a better alternative.
Is there a way I can make a hook function to call your separate custom function as soon as a LSP Mode buffer is enabled instead?
On Sat, Jun 18, 2022, at 3:35 PM, gustavotcabral wrote:
Hey @gustavotcabral https://github.com/gustavotcabral Question regarding workflow for this particular patch: Should I put this in a custom function within the ':config' section of my 'use-package' config for 'lsp-mode' in my config? : https://github.com/SamuelBanya/SamsEmacs/blob/main/configuration.org Or do I have to use Straight.el to benefit from this fix? Thanks, Sam … https://www.fastmail.com/mail/Inbox/compose?u=80f940c1# On Fri, Jun 17, 2022, at 2:00 PM, gustavotcabral wrote: I had the same problem in Linux (Emacs 28.1 with Cairo) for a long time. So I decided to dive into the lsp-ui source code and solved it (link <#184 (comment) https://github.com/emacs-lsp/lsp-ui/issues/184#issuecomment-1158057166>) for my use case. I don't know if it is the right solution, but it's working like a charm. I've created a snippet to test/show the behavior without extra dependencies: ;; This overlay overflows (let ((p (line-end-position)) (ov (make-overlay p p)) (msg (propertize "This overlay overflows to the next line. Bad, bad overlay..." 'face 'error)) (string (concat (propertize " " 'display `(space :align-to (- right-fringe ,(1+ (length msg))))) msg))) (overlay-put ov 'after-string string)) ;; This overlay doesn't overflow (let ((p (line-end-position)) (ov (make-overlay p p)) (msg (propertize "This overlay DOESN'T overflow to the next line. Woo-hoo!!!!!" 'face 'error)) (string (concat (propertize " " 'display `(space :align-to (- right-fringe (,(1+ (length msg)) . width)))) msg))) (overlay-put ov 'after-string string)) overlays https://user-images.githubusercontent.com/15175513/174352744-3036661a-b3af-421b-b0eb-f45592da6fa4.png — Reply to this email directly, view it on GitHub <#716 (comment) https://github.com/emacs-lsp/lsp-ui/issues/716#issuecomment-1159114632>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVU3GXOSMCADJ7NBIIKHGR3VPS4NXANCNFSM5X5NVJKQ. You are receiving this because you authored the thread.Message ID: @.***>
Hi, @SamuelBanya https://github.com/SamuelBanya.
To test the fix, yank the new function in a
lisp-interaction-mode
oremacs-lisp-mode
buffer (I use*scratch*
), put the point after the last)
and calleval-last-sexp
(orC-x C-e
). The first LSP sideline created after this eval will use the new behavior.I use a
mybugs.el
file:(eval-after-load 'lsp-ui-sideline (defun ... custom-code-here ...)) I've never used
use-package
. Maybe it's a better alternative.— Reply to this email directly, view it on GitHub https://github.com/emacs-lsp/lsp-ui/issues/716#issuecomment-1159545971, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVU3GXPLGNSSELLASK535SDVPYQITANCNFSM5X5NVJKQ. You are receiving this because you were mentioned.Message ID: @.***>
Is there a way I can make a hook function to call your separate custom function as soon as a LSP Mode buffer is enabled instead? … On Sat, Jun 18, 2022, at 3:35 PM, gustavotcabral wrote: > > Hey @gustavotcabral https://github.com/gustavotcabral Question regarding workflow for this particular patch: Should I put this in a custom function within the ':config' section of my 'use-package' config for 'lsp-mode' in my config? : https://github.com/SamuelBanya/SamsEmacs/blob/main/configuration.org Or do I have to use Straight.el to benefit from this fix? Thanks, Sam > … https://www.fastmail.com/mail/Inbox/compose?u=80f940c1# > On Fri, Jun 17, 2022, at 2:00 PM, gustavotcabral wrote: I had the same problem in Linux (Emacs 28.1 with Cairo) for a long time. So I decided to dive into the lsp-ui source code and solved it (link <#184 (comment) <#184 (comment)>>) for my use case. I don't know if it is the right solution, but it's working like a charm. I've created a snippet to test/show the behavior without extra dependencies: ;; This overlay overflows (let ((p (line-end-position)) (ov (make-overlay p p)) (msg (propertize "This overlay overflows to the next line. Bad, bad overlay..." 'face 'error)) (string (concat (propertize " " 'display `(space :align-to (- right-fringe ,(1+ (length msg))))) msg))) (overlay-put ov 'after-string string)) ;; This overlay doesn't overflow (let ((p (line-end-position)) (ov (make-overlay p p)) (msg (propertize "This overlay DOESN'T overflow to the next line. Woo-hoo!!!!!" 'face 'error)) (string (concat (propertize " " 'display
(space :align-to (- right-fringe (,(1+ (length msg)) . width)))) msg))) (overlay-put ov 'after-string string)) overlays https://user-images.githubusercontent.com/15175513/174352744-3036661a-b3af-421b-b0eb-f45592da6fa4.png — Reply to this email directly, view it on GitHub <#716 (comment) <[#716 (comment)](https://github.com/emacs-lsp/lsp-ui/issues/716#issuecomment-1159114632)>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVU3GXOSMCADJ7NBIIKHGR3VPS4NXANCNFSM5X5NVJKQ. You are receiving this because you authored the thread.Message ID: **@**.***> > Hi, @SamuelBanya <https://github.com/SamuelBanya>. To test the fix, yank the new function in a
lisp-interaction-modeor
emacs-lisp-modebuffer (I use
scratch), put the point after the last
)and call
eval-last-sexp(or
C-x C-e). The first LSP sideline created after this eval will use the new behavior. I use a
mybugs.elfile: (eval-after-load 'lsp-ui-sideline (defun ... custom-code-here ...)) I've never used
use-package`. Maybe it's a better alternative. — Reply to this email directly, view it on GitHub <#716 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVU3GXPLGNSSELLASK535SDVPYQITANCNFSM5X5NVJKQ. You are receiving this because you were mentioned.Message ID: @.***>
You don't need hooks. Here is the code I use:
(eval-after-load 'lsp-ui-sideline
'(progn
(defun lsp-ui-sideline--align (&rest lengths)
"Align sideline string by LENGTHS from the right of the window."
(cons (+ (apply '+ lengths)
(if (display-graphic-p) 1 2))
'width))))
Hey @gustavotcabral That totally worked!
Thanks for this, put it into my config, and this works on my MacOS version like a charm.
Good to see it got merged into the main branch as well. Sweet!
After doing most of the suggestions within these issues, I can confirm that this width issue still exists on MacOS: https://github.com/emacs-lsp/lsp-ui/issues/285 https://github.com/emacs-lsp/lsp-ui/issues/284
The bug occurs right after zooming in with 'text-scale-increase'.
I think this more or less has to deal with the default font size that is present when the LSP mode buffer is first enabled.
I think the fix would be to adjust accordingly to 'text-scale-increase', or adjust to the font size present. That way there would be no overlap anyway.
I was getting the same overlapping issues as featured in the two issues pages mentioned above.
My affected environment:
brew tap railwaycat/emacsmacport
brew install --cask emacs-mac
The only thing I could do for the time being is to nuke 'sideline' from my LSP config: