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.64k stars 4.89k forks source link

spacemacs-jump-handlers not set properly for C++ on emacs 27 #12984

Closed emacs18 closed 1 month ago

emacs18 commented 4 years ago

I would like to report that "g d" does not work for c++ buffers on first loading a c++ file, but works when the buffer is reloaded. This problem occurs only on emacs 27, but not on emacs 26. I build my own emacs using latest source code from git repository on Red Hat 6.6. I also use latest develop branch of spacemacs.

I have lsp-mode enabled using ccls backend. When I start emacs and open a c++ file, then "g d" does not work at first, because spacemacs-jump-handlers value is this:

(spacemacs/helm-gtags-maybe-dwim evil-goto-definition dumb-jump-go)

If I now hit "SPC b R" to revert the buffer to force re-initializing the buffer, then "g d" starts working which is not surprising since spacemacs-jump-handlers value is now this:

((lsp-ui-peek-find-definitions :async t)
 spacemacs/helm-gtags-maybe-dwim evil-goto-definition dumb-jump-go)

Note that the value of spacemacs-jump-handlers-c++-mode is

((lsp-ui-peek-find-definitions :async t)
 spacemacs/helm-gtags-maybe-dwim)

Why does it require re-loading a c++ file in order initialize spacemacs-jump-handlers correctly on emacs 27? Once it is set correctly, then subsequent c++ files loaded work fine without requiring reloading.

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

Jeff-avatar commented 2 years ago

I noticed this issue still exists for spacemacs 27.2. Any way to fix it? @emacs18

Jeff-avatar commented 2 years ago

BTW: I am on the develop branch, MacOs system. @github-actions

emacs18 commented 2 years ago

I do not see this problem anymore on emacs 27.2, ubuntu 20.04, and latest spacemacs, i.e., g d command works first time. Following shows my startup file which differs from default with regard to C++ and lsp.

$ diff -u core/templates/.spacemacs.template .spacemacs/init.el
--- core/templates/.spacemacs.template  2021-12-30 15:15:01.199174208 -0800
+++ .spacemacs/init.el  2021-12-30 15:07:54.353227980 -0800
@@ -40,10 +40,27 @@
      ;; ----------------------------------------------------------------
      ;; auto-completion
      ;; better-defaults
+     (c-c++
+      :variables
+      c-c++-adopt-subprojects t
+      c-c++-backend 'lsp-ccls
+      c-c++-default-mode-for-headers 'c++-mode
+      c-c++-enable-c++11 t
+      c-c++-enable-clang-support t
+      c-c++-lsp-sem-highlight-rainbow t
+      )
      emacs-lisp
      ;; git
      helm
-     ;; lsp
+     ;; compleseus
+     (lsp :variables
+          ;; Default prefix key is "s-l" which means "l pressed with super". I
+          ;; have no idea what this "super" prefix key is on linux.
+          lsp-keymap-prefix "C-;"
+          ;; This remaps "g d" and similar bindings to use lsp commands.
+          lsp-remap-xref-keybindings t
+          lsp-ui-sideline-show-hover t
+          lsp-enable-file-watchers nil)
      ;; markdown
      multiple-cursors
      ;; org
@@ -79,7 +96,7 @@
    ;; installs only the used packages but won't delete unused ones. `all'
    ;; installs *all* packages supported by Spacemacs and never uninstalls them.
    ;; (default is `used-only')
-   dotspacemacs-install-packages 'used-only))
+   dotspacemacs-install-packages 'used-but-keep-unused))

 (defun dotspacemacs/init ()
   "Initialization:
github-actions[bot] commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!