syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.56k stars 4.9k forks source link

Lsp layer changes latex keybindings #16390

Open tigerjack opened 1 month ago

tigerjack commented 1 month ago

Description :octocat:

Lsp layer changes keybindings in latex mode

Reproduction guide :beetle:

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:

Backtrace :paw_prints:

<<BACKTRACE IF RELEVANT>>
rommeswi commented 1 month ago

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 commented 1 month ago

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

rommeswi commented 1 month ago

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 commented 1 week ago

@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 commented 1 week ago

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.