Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lsp layer changes latex keybindings #16390

Open
tigerjack opened this issue May 6, 2024 · 5 comments
Open

Lsp layer changes latex keybindings #16390

tigerjack opened this issue May 6, 2024 · 5 comments
Assignees

Comments

@tigerjack
Copy link

tigerjack commented May 6, 2024

Description :octocat:

Lsp layer changes keybindings in latex mode

Reproduction guide 🪲

  • Start Emacs with lsp and latex layers enabled
  • Open a .tex file

The issue goes away when disabling lsp layer

Observed behaviour: 👀 💔
Some keybindings are not present, such as SPC m b

Expected behaviour: ❤️ 😄
keybindings should not be modified

System Info 💻

  • OS: gnu/linux
  • Emacs: 29.3
  • Spacemacs: 0.999.0
  • Spacemacs branch: develop (rev. a58a7d7)
  • Graphic display: nil
  • Running in daemon: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
((latex :variables latex-enable-auto-fill t latex-enable-folding t))
  • System configuration features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Backtrace 🐾

<<BACKTRACE IF RELEVANT>>
@rommeswi
Copy link
Contributor

rommeswi commented May 9, 2024

I can confirm this behavior. It seems intended but might not be optimal:

;; Rebind latex keys to avoid conflicts with lsp mode

(if (eq latex-backend 'lsp)
(spacemacs/set-leader-keys-for-major-mode 'latex-mode
"au" 'TeX-command-run-all
"c" 'latex/build
"iC" 'org-ref-insert-cite-key
"ic" 'LaTeX-close-environment ;; C-c ]
"ie" 'LaTeX-environment) ;; C-c C-e
(spacemacs/set-leader-keys-for-major-mode 'latex-mode
"c" 'LaTeX-close-environment ;; C-c ]
"e" 'LaTeX-environment)) ;; C-c C-e

Moreover:

(let ((prefix (if (eq latex-backend 'lsp) "R" "r")))
(spacemacs/declare-prefix-for-mode 'latex-mode (concat "m" prefix) "reftex")
(spacemacs/set-leader-keys-for-major-mode 'latex-mode
(concat prefix "c") 'reftex-citation
(concat prefix "g") 'reftex-grep-document
(concat prefix "i") 'reftex-index-selection-or-word
(concat prefix "I") 'reftex-display-index
(concat prefix " " "TAB") 'reftex-index
(concat prefix "l") 'reftex-label
(concat prefix "p") 'reftex-index-phrase-selection-or-word
(concat prefix "P") 'reftex-index-visit-phrases-buffer
(concat prefix "r") 'reftex-reference
(concat prefix "s") 'reftex-search-document
(concat prefix "t") 'reftex-toc
(concat prefix "T") 'reftex-toc-recenter
(concat prefix "v") 'reftex-view-crossref)))

and:

  (unless (and (eq latex-backend 'lsp)
              (eq mode 'latex-mode))
   (spacemacs/declare-prefix-for-mode mode "mh" "help")
   (spacemacs/declare-prefix-for-mode mode "mx" "text/fonts")
   (spacemacs/set-leader-keys-for-major-mode mode
     "a"   'TeX-command-run-all                         ;; C-c C-a
     "b"   'latex/build))

All in the packages.el of the latex layer. I have to say I am also unhappy with how the latex layer moves around keybindings a lot, depending on configuration (outline minor mode for example is shifted to C-c @ without which-key telling you about it).

I don't have a good solution in mind. The latex layer seems a bit extreme in this in comparison to other layers I am using.

@tigerjack
Copy link
Author

tigerjack commented May 9, 2024

@rommeswi now that I know about all this latex-backend-related changes, I feel even more annoyed.

@rommeswi
Copy link
Contributor

rommeswi commented May 9, 2024

I never used the major mode menu in latex but always used the auctex bindings, so I never noticed. I might have checked out the major mode menu once and found it not useful. I never knew that without lsp there is actually a lot of useful stuff in there.

Currently, in the latex major mode SPC m =, SPC m a, SPC m b, SPC m h, SPC m r, SPC m x, SPC m F, SPC m G, SPC m T are exclusively for lsp and it removes all the other bindings. I think that is indeed something that cannot stay like this.

What can be done immediately is that lsp is allowed to override all the bindings but not remove the entire bunch.

@rommeswi
Copy link
Contributor

@smile13241324 do you think a change as I proposed above would be reasonable? LSP can override bindings but does not remove all the latex bindings?

@smile13241324
Copy link
Collaborator

Hi guys,

sure, lets review this layer.

My original intention was freeing the conventional bindings, used by lsp, by moving other features to not used keys.

Here I have also avoided loading features which should already be covered by the lsp protocol like formatting or inserting.

If I have accidentally removed features with this I am sorry, and would of course be open to reintroduce them on bindings which do not violate our key binding conventions.

Prs are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants