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.58k stars 4.9k forks source link

add sonarlint in spacemacs #15751

Open lebensterben opened 1 year ago

lebensterben commented 1 year ago

Discussed in https://github.com/syl20bnr/spacemacs/discussions/15750

Originally posted by **chavalife17** September 27, 2022 I tried to install a package that is about sonarlint (https://github.com/emacs-lsp/lsp-sonarlint) I've used this config after installed this package ``` dotspacemacs-additional-packages '( lsp-sonarlint ) (defun dotspacemacs/user-config () "Configuration for user code: This function is called at the very end of Spacemacs startup, after layer configuration. Put your configuration code here, except for variables that should be set before packages are loaded." (setq lombok-jar-path (expand-file-name "/Users/mypc/lombok/lombok.jar" ) ) (setq lsp-java-vmargs `( "-XX:+UseParallelGC" "-XX:GCTimeRatio=4" "-XX:AdaptiveSizePolicyWeight=90" "-Dsun.zip.disableMemoryMapping=true" "-Xmx1G" "-Xms100m" ,(concat "-javaagent:" lombok-jar-path) ) ) (use-package lsp-sonarlint :defer t) (use-package lsp-sonarlint-java :after lsp-java :custom (lsp-sonarlint-java-enabled t)) (global-set-key (kbd "C-c m c") 'mc/edit-lines) (global-set-key (kbd "C->") 'mc/mark-next-like-this) (global-set-key (kbd "C-<") 'mc/mark-previous-like-this) (global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this) ) ``` my problem is spacemacs can enabled jdtls and lsp-sonarlint but I can't see a suggestion of my code. When I start spacemacs, I can see a jdtls started message but in sonarlint always has started. In this image example, in another ide, I can receive a suggestion about method references instanced of lambdas but in spacemacs no image Can someone helps me? thanks for your answers
ir210 commented 1 year ago

I just tried it (thank you for introducing me to this lsp-sonarlint) via both package-install and (use-package) and basically did what you did there.

lsp-sonarlint works for me:

image

I am not really sure what happened but it didn't work for me once, but after restarting spacemacs it worked again. I'll try to use this package for my daily work and will report if I find anything.

ir210 commented 1 year ago

So, after a restart, lsp-sonarlint didn't work anymore for me. So, I did an investigation and found that since you use :defer t for lsp-sonarlint, lsp-sonarlint-java was loaded and configured too soon. Here is the configuration that works for me so far.

(use-package lsp-sonarlint
    :defer t)
(use-package lsp-sonarlint-java
    :after (lsp-sonarlint lsp-java)
    :custom (lsp-sonarlint-java-enabled t))
lebensterben commented 1 year ago

@chavalife17

please verify whether it works.

github-actions[bot] commented 9 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!

smile13241324 commented 3 weeks ago

Still valid