spacemacs icon indicating copy to clipboard operation
spacemacs copied to clipboard

Lsp layer changes latex keybindings

Open tigerjack opened this issue 1 year ago • 5 comments

Description :octocat:

Lsp layer changes keybindings in latex mode

Reproduction guide :beetle:

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

The issue goes away when disabling lsp layer

Observed behaviour: :eyes: :broken_heart: Some keybindings are not present, such as SPC m b

Expected behaviour: :heart: :smile: keybindings should not be modified

System Info :computer:

  • OS: gnu/linux
  • Emacs: 29.3
  • Spacemacs: 0.999.0
  • Spacemacs branch: develop (rev. a58a7d79b)
  • 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 :paw_prints:

<<BACKTRACE IF RELEVANT>>

tigerjack avatar May 06 '24 10:05 tigerjack

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.

rommeswi avatar May 09 '24 02:05 rommeswi

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

tigerjack avatar May 09 '24 08:05 tigerjack

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 avatar May 09 '24 23:05 rommeswi

@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?

rommeswi avatar Jun 21 '24 03:06 rommeswi

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.

smile13241324 avatar Jun 24 '24 18:06 smile13241324