spacemacs icon indicating copy to clipboard operation
spacemacs copied to clipboard

add sonarlint in spacemacs

Open lebensterben opened this issue 3 years ago • 5 comments

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

lebensterben avatar Sep 27 '22 09:09 lebensterben

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 avatar Sep 27 '22 18:09 ir210

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))

ir210 avatar Oct 02 '22 14:10 ir210

@chavalife17

please verify whether it works.

lebensterben avatar Oct 02 '22 16:10 lebensterben

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!

github-actions[bot] avatar Oct 02 '23 16:10 github-actions[bot]

Still valid

smile13241324 avatar Jun 13 '24 14:06 smile13241324

This should be adding basic support for sonarlint via the lsp layer. I personally think it will need some polishing but so need the lsp-sonarlint package as well. If you need it please consider helping at the package level.

smile13241324 avatar Aug 22 '24 17:08 smile13241324