Andersbakken / rtags

A client/server indexer for c/c++/objc[++] with integration for Emacs based on clang.
http://www.rtags.net
GNU General Public License v3.0
1.82k stars 253 forks source link

rtags-diagnostics disappears a few seconds after showing errors #1340

Open Deanseo opened 4 years ago

Deanseo commented 4 years ago

Describe the bug Let's say I make some invalid syntax error on purpose. Then rtags-diagnostics properly shows the compile errors just for a few seconds, then they all disappear.

Not only in *rtags-diagnostics* but also the buffer where you write code also loses all special fonts such as rtags-errline.

To Reproduce

  1. Write code, properly setup with CMakeLists.txt and make sure everything compiles fine.
  2. Write any random characters to make the code illegal like this:
    void bar() errr // illegal
    {
    /// Code
    }
  3. Wait for the error message to come at *rtags-diagnostics*, and disappear all of sudden in a few seconds.
  4. Wait for the error font such as rtags-errline to disappear along with it.

Expected behavior The error messages and those error face should stay.

Environment (please complete the following information):

Additional context It seems like there's another overlay that erases the diagnostics, but at this point I'm at a loss how to dig deeper.

My relative C++ environment in init.el is as follows:

(use-package rtags
  :ensure t
  :config
  (setq rtags-find-file-case-insensitive t)
  (setq rtags-symbolnames-case-insensitive t)
  (setq rtags-autostart-diagnostics t)
  (setq rtags-timeout 1100)
  (setq rtags-completions-enabled t)

  (rtags-set-periodic-reparse-timeout 1.8))

(use-package company-irony
  :ensure t
  :init
  (defun my-irony-mode-hook ()
    (define-key irony-mode-map [remap completion-at-point]
      'irony-completion-at-point-async)
    (define-key irony-mode-map [remap complete-symbol]
      'irony-completion-at-point-async))

  (add-hook 'c++-mode-hook 'irony-mode)
  (add-hook 'c-mode-hook 'irony-mode)
  (add-hook 'irony-mode-hook 'my-irony-mode-hook)
  (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)

  :config
  (setq company-global-modes '(c-mode c++-mode emacs-lisp-mode csharp-mode python-mode))
  (setq company-idle-delay 1)
  (setq company-tooltip-limit 15)
  (setq company-async-timeout 5)
  (setq company-minimum-prefix-length 3)
  (setq company-backends (delete 'company-semantic company-backends))

  (setq company-backends (delete 'company-dabbrev company-backends))
  (add-to-list 'company-backends 'company-irony)

  (global-company-mode))

(use-package company-irony-c-headers
  :ensure t
  :config
  (add-to-list 'company-backends 'company-irony-c-headers))

(use-package flycheck-rtags
  :ensure t
  :after rtags
  :init
  (defun my-flycheck-rtags-setup ()
    (flycheck-select-checker 'rtags)
    (setq-local flycheck-highlighting-mode nil) ;; RTags creates more accurate overlays.
    (setq-local flycheck-check-syntax-automatically nil)
    (flycheck-mode t))

  :config
  (add-hook 'c++-mode-hook #'my-flycheck-rtags-setup)
  (add-hook 'c-mode-hook #'my-flycheck-rtags-setup))

(use-package cmake-ide
  :ensure t
  :init
  (defun my-cmake-ide-hook ()
    (call-interactively #'cmake-ide-maybe-start-rdm))

  (add-hook 'c-mode-common-hook #'my-cmake-ide-hook))
bcclaywell commented 4 years ago

Any motion on this? I'm experiencing this issue too, with Emacs 26.3 and the latest Prelude c951f8e. I'm happy to be a guinea pig if there's a way I can trace what's happening.

In case it's a clue, here's what rc -m --elisp says when I add a non-existent function to my source file.

(list 'checkstyle (cons "/Users/bclaywel/workspace/fringe/main/main.c" (list (list nil 16 5 nil 'error "Semantic Issue: implicit declaration of function 'bad_function' is invalid in C99: -Wimplicit-function-declaration" nil) (list nil 29 26 nil 'error "Semantic Issue: use of undeclared identifier 'false'" nil) (list nil 38 12 nil 'error "Semantic Issue: use of undeclared identifier 'true'" nil))))
(list 'checkstyle (cons "/Users/bclaywel/workspace/fringe/main/main.c" nil))))

The line clearing all the highlights appears immediately after the line including the errors. I don't know why rc would immediately send another line that clears the errors like that.

xwl commented 4 years ago

I saw similar issues after rebuilding rtags with '--build-clang' configure option, where clang 5.0.0 is used by default. It seems solving my issue by changing the version to 8.0.0. So maybe this is some clang incompatibility issue. Maybe you can try with 8.0.0?

In addition, i don't think this is a lisp only issue. I can already see the suspicious error (the last list expression clearing all previous errors) coming from 'rdm' output. So probably some parsing issue inside rdm.

Deanseo commented 4 years ago

Just letting you all know that I'm still experiencing this issue and haven't found a good workaround either yet.

Hope it'll be fixed soon enough. 🤞

ARoxdale commented 3 years ago

I am also encountering this issue, with both g++ and clang++ builds. I'm using the rtags 3.43 package from melpa. The issue seems to be related to the rtags-diagnostics buffer being deleted/refreshed constantly.

zhihuiFan commented 2 years ago

This probably is because you install more than 1 LLVM toolset. In my case, I have llvm11 and llvm13.

my rdm is compiled and running with llvm11, and I build my compile_commands.json with llvm13, then I run into this issue. after I reset my rdm with llvm13, the issue gone.

How to setup rdm with given llvm version, just FYI.

  1. add the llvm-config to the PATH variable, then cmake will use it.
  2. set the LD_LIBRARY_PATH to the directory you install the LLVM.