diff --git a/README.md b/README.md index 3a7e9ab..4a0bd50 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ Out of the box, SonarLint automatically checks your code against the following r * `lsp-sonarlint-test-file-pattern` - Regex to find test file, most rules are not evaluated on test files. * `lsp-sonarlint-show-analyzer-logs` - Show analyzer logs. * `lsp-sonarlint-verbose-logs` - Make SonarLint logs verbose. -* `lsp-sonarlint-server-download-url` - SonarLint server download URL. +* `lsp-sonarlint-vscode-plugin-url` - SonarLint language server download URL. * `lsp-sonarlint-plugin-autodownload` - Not ask for confirmation and download analyzers if they are missing. ### Plugins supported settings diff --git a/languages/go/lsp-sonarlint-go.el b/languages/go/lsp-sonarlint-go.el deleted file mode 100644 index 096de0b..0000000 --- a/languages/go/lsp-sonarlint-go.el +++ /dev/null @@ -1,60 +0,0 @@ -;;; lsp-sonarlint-go.el --- lsp-sonarlint Go module -*- lexical-binding: t; -*- - -;; Copyright (C) 2020 Fermin Munoz -;; URL: https://gitlab.com/sasanidas/lsp-sonarlint -;; Keywords: languages - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: -;; Specific configuration for the SonarLint Go plugin. - -;; This is NOT and official SonarLint extension. - - -;;; Code: - -(defgroup lsp-sonarlint-go nil - "lsp-sonarlint Go analyzer group" - :group 'lsp-sonarlint - :version '(lsp-sonarlint-go . "1.12.0")) - -(defcustom lsp-sonarlint-go-enabled nil - "Enable lsp-sonarlint-go plugin." - :group 'lsp-sonarlint-go - :type 'boolean) - -(defcustom lsp-sonarlint-go-download-url - "https://repo.maven.apache.org/maven2/org/sonarsource/slang/sonar-go-plugin/1.12.0.4259/sonar-go-plugin-1.12.0.4259.jar" - "Go plugin download URL." - :group 'lsp-sonarlint-go - :type 'string) - -(defcustom lsp-sonarlint-go-analyzer-path -(concat - (file-name-directory load-file-name) - "sonar-go.jar") - "Lsp-sonarlint Go analyzer location." - :group 'lsp-sonarlint-go - :type 'file) - -(defvar lsp-sonarlint-go-doc-url "https://www.sonarsource.com/go/" - "Documentation sonarsource URL.") - -(defvar lsp-sonarlint-go-repository-url "https://github.com/SonarSource/slang/" - "Official sonarlint code extension repository.") - - -(provide 'lsp-sonarlint-go) -;;; lsp-sonarlint-go.el ends here diff --git a/languages/html/lsp-sonarlint-html.el b/languages/html/lsp-sonarlint-html.el deleted file mode 100644 index 7ba187b..0000000 --- a/languages/html/lsp-sonarlint-html.el +++ /dev/null @@ -1,63 +0,0 @@ -;;; lsp-sonarlint-html.el --- lsp-sonarlint html module -*- lexical-binding: t; -*- - -;; Copyright (C) 2020 Fermin Munoz -;; URL: https://gitlab.com/sasanidas/lsp-sonarlint -;; Keywords: languages - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: -;; Specific configuration for the SonarLint HTML plugin. - -;; This is NOT and official SonarLint extension. - - -;;; Code: - -(defgroup lsp-sonarlint-html nil - "lsp-sonarlint html analyzer group" - :group 'lsp-sonarlint - :version '(lsp-sonarlint-html . "3.7.1")) - -(defcustom lsp-sonarlint-html-enabled nil - "Enable lsp-sonarlint-html plugin." - :group 'lsp-sonarlint-html - :type 'boolean) - -(defcustom lsp-sonarlint-html-download-url - "https://repo.maven.apache.org/maven2/org/sonarsource/html/sonar-html-plugin/3.7.1.3306/sonar-html-plugin-3.7.1.3306.jar" - "HTML plugin download URL." - :group 'lsp-sonarlint-html - :type 'string) - -(defcustom lsp-sonarlint-html-analyzer-path -(concat - (file-name-directory load-file-name) - "sonar-html.jar") - "Lsp-sonarlint HTML analyzer location." - :group 'lsp-sonarlint-html - :type 'file) - -(defvar lsp-sonarlint-html-doc-url "https://www.sonarsource.com/html/" - "Documentation sonarsource URL.") - -(defvar lsp-sonarlint-html-repository-url "https://github.com/SonarSource/sonar-html" - "Official sonarlint code extension repository.") - - - - - -(provide 'lsp-sonarlint-html) -;;; lsp-sonarlint-html.el ends here diff --git a/languages/java/lsp-sonarlint-java.el b/languages/java/lsp-sonarlint-java.el deleted file mode 100644 index 04bc4bc..0000000 --- a/languages/java/lsp-sonarlint-java.el +++ /dev/null @@ -1,60 +0,0 @@ -;;; lsp-sonarlint-java.el --- lsp-sonarlint java module -*- lexical-binding: t; -*- - -;; Copyright (C) 2020 Fermin Munoz -;; URL: https://gitlab.com/sasanidas/lsp-sonarlint -;; Keywords: languages - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: -;; Specific configuration for the SonarLint Java plugin. - -;; This is NOT and official SonarLint extension. - - -;;; Code: - -(defgroup lsp-sonarlint-java nil - "lsp-sonarlint java analyzer group" - :group 'lsp-sonarlint - :version '(lsp-sonarlint-java . "7.18.0")) - -(defcustom lsp-sonarlint-java-enabled nil - "Enable lsp-sonarlint-java plugin." - :group 'lsp-sonarlint-java - :type 'boolean) - -(defcustom lsp-sonarlint-java-download-url - "https://repo.maven.apache.org/maven2/org/sonarsource/java/sonar-java-plugin/7.18.0.31443/sonar-java-plugin-7.18.0.31443.jar" - "Java plugin download URL." - :group 'lsp-sonarlint-java - :type 'string) - -(defcustom lsp-sonarlint-java-analyzer-path -(concat - (file-name-directory load-file-name) - "sonar-java.jar") - "Lsp-sonarlint java analyzer location." - :group 'lsp-sonarlint-java - :type 'file) - -(defvar lsp-sonarlint-java-doc-url "https://www.sonarsource.com/java/" - "Documentation sonarsource URL.") - -(defvar lsp-sonarlint-java-repository-url "https://github.com/SonarSource/sonar-java" - "Official sonarlint code extension repository.") - - -(provide 'lsp-sonarlint-java) -;;; lsp-sonarlint-java.el ends here diff --git a/languages/javascript/lsp-sonarlint-javascript.el b/languages/javascript/lsp-sonarlint-javascript.el deleted file mode 100644 index 82e86c2..0000000 --- a/languages/javascript/lsp-sonarlint-javascript.el +++ /dev/null @@ -1,63 +0,0 @@ -;;; lsp-sonarlint-javascript.el --- lsp-sonarlint javascript module -*- lexical-binding: t; -*- - -;; Copyright (C) 2020 Fermin Munoz -;; URL: https://gitlab.com/sasanidas/lsp-sonarlint -;; Keywords: languages - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: -;; Specific configuration for the SonarLint Javascript plugin. - -;; This is NOT and official SonarLint extension. - - -;;; Code: - -(defgroup lsp-sonarlint-javascript nil - "lsp-sonarlint javascript analyzer group" - :group 'lsp-sonarlint - :version '(lsp-sonarlint-javascript . "10.1.0")) - -(defcustom lsp-sonarlint-javascript-enabled nil - "Enable lsp-sonarlint-javascript plugin." - :group 'lsp-sonarlint-javascript - :type 'boolean) - -(defcustom lsp-sonarlint-javascript-download-url - "https://repo.maven.apache.org/maven2/org/sonarsource/javascript/sonar-javascript-plugin/10.1.0.21143/sonar-javascript-plugin-10.1.0.21143.jar" - "Javascript plugin download URL." - :group 'lsp-sonarlint-javascript - :type 'string) - -(defcustom lsp-sonarlint-javascript-analyzer-path -(concat - (file-name-directory load-file-name) - "sonar-javascript.jar") - "Lsp-sonarlint javascript analyzer location." - :group 'lsp-sonarlint-javascript - :type 'file) - -(defvar lsp-sonarlint-javascript-doc-url "https://www.sonarsource.com/js/" - "Documentation sonarsource URL.") - -(defvar lsp-sonarlint-javascript-repository-url "https://github.com/SonarSource/SonarJS" - "Official sonarlint code extension repository.") - - - - - -(provide 'lsp-sonarlint-javascript) -;;; lsp-sonarlint-javascript.el ends here diff --git a/languages/php/lsp-sonarlint-php.el b/languages/php/lsp-sonarlint-php.el deleted file mode 100644 index f0d551a..0000000 --- a/languages/php/lsp-sonarlint-php.el +++ /dev/null @@ -1,63 +0,0 @@ -;;; lsp-sonarlint-php.el --- lsp-sonarlint php module -*- lexical-binding: t; -*- - -;; Copyright (C) 2020 Fermin Munoz -;; URL: https://gitlab.com/sasanidas/lsp-sonarlint -;; Keywords: languages - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: -;; Specific configuration for the SonarLint PHP plugin. - -;; This is NOT and official SonarLint extension. - - -;;; Code: - -(defgroup lsp-sonarlint-php nil - "lsp-sonarlint php analyzer group" - :group 'lsp-sonarlint - :version '(lsp-sonarlint-php . "3.28.0")) - -(defcustom lsp-sonarlint-php-enabled nil - "Enable lsp-sonarlint-php plugin." - :group 'lsp-sonarlint-php - :type 'boolean) - -(defcustom lsp-sonarlint-php-download-url - "https://repo.maven.apache.org/maven2/org/sonarsource/php/sonar-php-plugin/3.28.0.9490/sonar-php-plugin-3.28.0.9490.jar" - "Php plugin download URL." - :group 'lsp-sonarlint-php - :type 'string) - -(defcustom lsp-sonarlint-php-analyzer-path -(concat - (file-name-directory load-file-name) - "sonar-php.jar") - "Lsp-sonarlint php analyzer location." - :group 'lsp-sonarlint-php - :type 'file) - -(defvar lsp-sonarlint-php-doc-url "https://www.sonarsource.com/php/" - "Documentation sonarsource URL.") - -(defvar lsp-sonarlint-php-repository-url "https://github.com/SonarSource/sonar-php" - "Official sonarlint code extension repository.") - - - - - -(provide 'lsp-sonarlint-php) -;;; lsp-sonarlint-php.el ends here diff --git a/languages/python/lsp-sonarlint-python.el b/languages/python/lsp-sonarlint-python.el deleted file mode 100644 index b22f29d..0000000 --- a/languages/python/lsp-sonarlint-python.el +++ /dev/null @@ -1,63 +0,0 @@ -;;; lsp-sonarlint-python.el --- lsp-sonarlint python module -*- lexical-binding: t; -*- - -;; Copyright (C) 2020 Fermin Munoz -;; URL: https://gitlab.com/sasanidas/lsp-sonarlint -;; Keywords: languages - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: -;; Specific configuration for the SonarLint python plugin. - -;; This is NOT and official SonarLint extension. - - -;;; Code: - -(defgroup lsp-sonarlint-python nil - "lsp-sonarlint python analyzer group" - :group 'lsp-sonarlint - :version '(lsp-sonarlint-python . "4.2.0")) - -(defcustom lsp-sonarlint-python-enabled nil - "Enable lsp-sonarlint-python plugin." - :group 'lsp-sonarlint-python - :type 'boolean) - -(defcustom lsp-sonarlint-python-download-url - "https://repo.maven.apache.org/maven2/org/sonarsource/python/sonar-python-plugin/4.2.0.11487/sonar-python-plugin-4.2.0.11487.jar" - "Python plugin download URL." - :group 'lsp-sonarlint-python - :type 'string) - -(defcustom lsp-sonarlint-python-analyzer-path -(concat - (file-name-directory load-file-name) - "sonar-python.jar") - "Lsp-sonarlint python analyzer location." - :group 'lsp-sonarlint-python - :type 'file) - -(defvar lsp-sonarlint-python-doc-url "https://www.sonarsource.com/python/" - "Documentation sonarsource URL.") - -(defvar lsp-sonarlint-python-repository-url "https://github.com/SonarSource/sonar-python" - "Official sonarlint code extension repository.") - - - - - -(provide 'lsp-sonarlint-python) -;;; lsp-sonarlint-python.el ends here diff --git a/languages/text/lsp-sonarlint-text.el b/languages/text/lsp-sonarlint-text.el deleted file mode 100644 index 5909800..0000000 --- a/languages/text/lsp-sonarlint-text.el +++ /dev/null @@ -1,63 +0,0 @@ -;;; lsp-sonarlint-text.el --- lsp-sonarlint text module -*- lexical-binding: t; -*- - -;; Copyright (C) 2020 Fermin Munoz -;; URL: https://gitlab.com/sasanidas/lsp-sonarlint -;; Keywords: languages - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: -;; Specific configuration for the SonarLint text plugin. - -;; This is NOT and official SonarLint extension. - - -;;; Code: - -(defgroup lsp-sonarlint-text nil - "lsp-sonarlint text analyzer group" - :group 'lsp-sonarlint - :version '(lsp-sonarlint-text . "2.0.1")) - -(defcustom lsp-sonarlint-text-enabled nil - "Enable lsp-sonarlint-text plugin." - :group 'lsp-sonarlint-text - :type 'boolean) - -(defcustom lsp-sonarlint-text-download-url - "https://repo.maven.apache.org/maven2/org/sonarsource/text/sonar-text-plugin/2.0.1.611/sonar-text-plugin-2.0.1.611.jar" - "Text plugin download URL." - :group 'lsp-sonarlint-text - :type 'string) - -(defcustom lsp-sonarlint-text-analyzer-path -(concat - (file-name-directory load-file-name) - "sonar-text.jar") - "Lsp-sonarlint text analyzer location." - :group 'lsp-sonarlint-text - :type 'file) - -(defvar lsp-sonarlint-text-doc-url "https://www.sonarsource.com/" - "Documentation sonarsource URL.") - -(defvar lsp-sonarlint-text-repository-url "https://github.com/SonarSource/sonar-text" - "Official sonarlint code extension repository.") - - - - - -(provide 'lsp-sonarlint-text) -;;; lsp-sonarlint-text.el ends here diff --git a/languages/typescript/lsp-sonarlint-typescript.el b/languages/typescript/lsp-sonarlint-typescript.el deleted file mode 100644 index 027da68..0000000 --- a/languages/typescript/lsp-sonarlint-typescript.el +++ /dev/null @@ -1,59 +0,0 @@ -;;; lsp-sonarlint-typescript.el --- lsp-sonarlint typescript module -*- lexical-binding: t; -*- - -;; Copyright (C) 2021 Gueorgui Tcherednitchenko -;; Author: Gueorgui Tcherednitchenko -;; Keywords: languages - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: -;; Specific configuration for the sonarlint typescript plugin. - -;; This is NOT and official SonarLint extension. - - -;;; Code: - -(defgroup lsp-sonarlint-typescript nil - "lsp-sonarlint typescript analyzer group" - :group 'lsp-sonarlint - :version '(lsp-sonarlint-typescript . "10.1.0")) - -(defcustom lsp-sonarlint-typescript-enabled nil - "Enable lsp-sonarlint-typescript plugin." - :group 'lsp-sonarlint-typescript - :type 'boolean) - -(defcustom lsp-sonarlint-typescript-download-url - "https://repo.maven.apache.org/maven2/org/sonarsource/javascript/sonar-javascript-plugin/10.1.0.21143/sonar-javascript-plugin-10.1.0.21143.jar" - "Typescript plugin download URL." - :group 'lsp-sonarlint-typescript - :type 'string) - -(defcustom lsp-sonarlint-typescript-analyzer-path -(concat - (file-name-directory load-file-name) - "sonar-javascript.jar") ;; Note: it is the same as for javascript, and that is intentional - "Lsp-sonarlint typescript analyzer location." - :group 'lsp-sonarlint-typescript - :type 'file) - -(defvar lsp-sonarlint-typescript-doc-url "https://www.sonarsource.com/ts/" - "Documentation sonarsource URL.") - -(defvar lsp-sonarlint-typescript-repository-url "https://github.com/SonarSource/SonarJS" - "Official sonarlint code extension repository.") - -(provide 'lsp-sonarlint-typescript) -;;; lsp-sonarlint-typescript.el ends here diff --git a/languages/xml/lsp-sonarlint-xml.el b/languages/xml/lsp-sonarlint-xml.el deleted file mode 100644 index 6181ba1..0000000 --- a/languages/xml/lsp-sonarlint-xml.el +++ /dev/null @@ -1,60 +0,0 @@ -;;; lsp-sonarlint-xml.el --- lsp-sonarlint xml module -*- lexical-binding: t; -*- - -;; Copyright (C) 2020 Fermin Munoz -;; URL: https://gitlab.com/sasanidas/lsp-sonarlint -;; Keywords: languages - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: -;; Specific configuration for the SonarLint XML plugin. - -;; This is NOT and official SonarLint extension. - - -;;; Code: - -(defgroup lsp-sonarlint-xml nil - "lsp-sonarlint xml analyzer group" - :group 'lsp-sonarlint - :version '(lsp-sonarlint-xml . "2.7.0")) - -(defcustom lsp-sonarlint-xml-enabled nil - "Enable lsp-sonarlint-xml plugin." - :group 'lsp-sonarlint-xml - :type 'boolean) - -(defcustom lsp-sonarlint-xml-download-url - "https://repo.maven.apache.org/maven2/org/sonarsource/xml/sonar-xml-plugin/2.7.0.3820/sonar-xml-plugin-2.7.0.3820.jar" - "Xml plugin download URL." - :group 'lsp-sonarlint-xml - :type 'string) - -(defcustom lsp-sonarlint-xml-analyzer-path -(concat - (file-name-directory load-file-name) - "sonar-xml.jar") - "Lsp-sonarlint xml analyzer location." - :group 'lsp-sonarlint-xml - :type 'file) - -(defvar lsp-sonarlint-xml-doc-url "https://www.sonarsource.com/xml/" - "Documentation sonarsource URL.") - -(defvar lsp-sonarlint-xml-repository-url "https://github.com/SonarSource/sonar-xml" - "Official sonarlint code extension repository.") - - -(provide 'lsp-sonarlint-xml) -;;; lsp-sonarlint-xml.el ends here diff --git a/lsp-sonarlint.el b/lsp-sonarlint.el index 44e730d..b258da8 100644 --- a/lsp-sonarlint.el +++ b/lsp-sonarlint.el @@ -4,7 +4,8 @@ ;; Author: Fermin MF ;; Created: 13 Jun 2020 -;; Version: 0.0.1 +;; Updated: 20 Sep 2023 +;; Version: 0.0.2 ;; Keywords: languages, tools, php, javascript, typescript, go, xml, html, java, python ;; URL: https://github.com/emacs-lsp/lsp-sonarlint ;; Package-Requires: ((emacs "27.1") (dash "2.12.0") (lsp-mode "6.3") (ht "2.3")) @@ -44,30 +45,72 @@ :link '(url-link "https://github.com/emacs-lsp/lsp-sonarlint") :package-version '(lsp-mode . "6.4")) -(defcustom lsp-sonarlint-server-path - (concat - (file-name-directory load-file-name) - "server/sonarlint-language-server.jar") - "SonarLint Language Server jar file location." +(defcustom lsp-sonarlint-cfamily-enabled t + "Enable lsp-sonarlint-cfamily plugin." :group 'lsp-sonarlint - :type 'file) + :type 'boolean) -(defcustom lsp-sonarlint-modes-enabled '(php-mode - go-mode - html-mode - web-mode - js-mode - js2-mode - rjsx-mode - typescript-mode - typescript-tsx-mode - python-mode - java-mode - xml-mode - nxml-mode) - "List of major modes that enable SonarLint backend for LSP mode." +(defcustom lsp-sonarlint-go-enabled t + "Enable lsp-sonarlint-go plugin." :group 'lsp-sonarlint - :type 'file) + :type 'boolean) + +(defcustom lsp-sonarlint-html-enabled t + "Enable lsp-sonarlint-html plugin." + :group 'lsp-sonarlint + :type 'boolean) + +(defcustom lsp-sonarlint-java-enabled t + "Enable lsp-sonarlint-java plugin." + :group 'lsp-sonarlint + :type 'boolean) + +(defcustom lsp-sonarlint-javascript-enabled t + "Enable lsp-sonarlint-javascript plugin." + :group 'lsp-sonarlint + :type 'boolean) + +(defcustom lsp-sonarlint-php-enabled t + "Enable lsp-sonarlint-php plugin." + :group 'lsp-sonarlint + :type 'boolean) + +(defcustom lsp-sonarlint-python-enabled t + "Enable lsp-sonarlint-python plugin." + :group 'lsp-sonarlint + :type 'boolean) + +(defcustom lsp-sonarlint-text-enabled t + "Enable lsp-sonarlint-text plugin." + :group 'lsp-sonarlint + :type 'boolean) + +(defcustom lsp-sonarlint-typescript-enabled t + "Enable lsp-sonarlint-typescript plugin." + :group 'lsp-sonarlint + :type 'boolean) + +(defcustom lsp-sonarlint-xml-enabled t + "Enable lsp-sonarlint-xml plugin." + :group 'lsp-sonarlint + :type 'boolean) + +(defun lsp-sonarlint-modes-enabled () + "Get mode list which sonarlint should active." + (-mapcat (lambda (mode-dict) + (let ((mode-enabled (eval (car mode-dict)))) + (when mode-enabled + (cdr mode-dict) ))) + '((lsp-sonarlint-cfamily-enabled . ("c" "cpp" "objective-c" "cuda")) + (lsp-sonarlint-go-enabled . ("go")) + (lsp-sonarlint-html-enabled . ("html")) + (lsp-sonarlint-java-enabled . ("java")) + (lsp-sonarlint-javascript-enabled . ("js")) + (lsp-sonarlint-php-enabled . ("php")) + (lsp-sonarlint-python-enabled . ("python")) + (lsp-sonarlint-text-enabled . ("text")) + (lsp-sonarlint-typescript-enabled . ("typescript")) + (lsp-sonarlint-xml-enabled . ("xml"))))) (defcustom lsp-sonarlint-disable-telemetry t "Disable sending anonymous usage statistics to SonarSource. @@ -99,23 +142,63 @@ e.g. `-Xmx1024m`." :group 'lsp-sonarlint :type 'string) -(defcustom lsp-sonarlint-server-download-url - "https://repox.jfrog.io/repox/sonarsource/org/sonarsource/sonarlint/ls/sonarlint-language-server/2.19.0.72769/sonarlint-language-server-2.19.0.72769.jar" - "SonarLint Language Server jar file download URL." +(lsp-defcustom lsp-sonarlint--compilecommands-path-property "" + "Property of compilecommands path." + :group 'lsp-sonarlint + :lsp-path "sonarlint.pathToCompileCommands") + +(defvar lsp-sonarlint--old-compilecommands-path-property "" + "Variable for storing old compilecommands.json path.") + +(defconst lsp-sonarlint-vscode-plugin-version-hash-tbl + '(("3.21.0" . "%2B74430") + ("3.20.2" . "%2B74272")) + "Alist of vscode plugin and commit hash.") + +(defcustom lsp-sonarlint-vscode-plugin-version + "3.21.0" + "Specify the version of SonarLint VSCode Plugin." + :group 'lsp-sonarlint + :type 'string) + +(defcustom lsp-sonarlint-vscode-plugin-url + (let ((vscode-plugin-version-table (assoc lsp-sonarlint-vscode-plugin-version lsp-sonarlint-vscode-plugin-version-hash-tbl))) + (when (null vscode-plugin-version-table) + ;; Set default value + (setq vscode-plugin-version-table '("3.21.0" . "%2B74430"))) + (let ((vscode-plugin-version (car vscode-plugin-version-table)) + (vscode-plugin-hash (cdr vscode-plugin-version-table))) + (concat "https://github.com/SonarSource/sonarlint-vscode/releases/download/" vscode-plugin-version vscode-plugin-hash "/sonarlint-vscode-" vscode-plugin-version ".vsix"))) + "SonarLint VSCode Plugin VISX file download URL." :group 'lsp-sonarlint :type 'string) +(defcustom lsp-sonarlint-vscode-plugin-store-path + (file-name-concat (file-name-directory load-file-name) "sonarlint" "download/") + "SonarLint VSCode Plugin VISX file store path." + :group 'lsp-sonarlint + :type 'string) + +(defcustom lsp-sonarlint-vscode-plugin-extract-path + (file-name-concat (file-name-directory load-file-name) "sonarlint" "extract/") + "SonarLint VSCode Plugin VISX file extract path." + :group 'lsp-sonarlint + :type 'string) + +(defcustom lsp-sonarlint-server-path (let ((server-path (concat lsp-sonarlint-vscode-plugin-extract-path "extension/server/"))) + (if (file-exists-p server-path) + (car (directory-files (concat lsp-sonarlint-vscode-plugin-extract-path "extension/server/") t ".*\.jar")) + nil)) + "SonarLint Language Server jar file location." + :group 'lsp-sonarlint + :type 'file) + (defcustom lsp-sonarlint-plugin-autodownload nil "Whether to go ahead and download missing plugins not asking for a confirmation. Useful for batch testing." :group 'lsp-sonarlint :type 'boolean) -(let ((languages-directory-path (concat (file-name-directory load-file-name) "languages"))) - (if (file-directory-p languages-directory-path) - (add-to-list 'load-path languages-directory-path) - (error "There was an error with the `load-file-name` function"))) - (defun lsp-sonarlint--remove-duplicate-plugins (jars) "Return copy of JARS with duplicates removed. The duplicates may occur if the same plugin implements different languages, @@ -123,54 +206,73 @@ for example sonar-javascript.jar covers both JavaScript and TypeScript. If a duplicate occurs, SonarLint will throw an exception." (cl-remove-duplicates jars :test #'equal :key (lambda (jar-path) (file-name-base jar-path)))) +(defun lsp-sonarlint--download-plugins () + "Check if sonarlint vscode plugin exists. If not, download it from web. +And extract it to `lsp-sonarlint-vscode-plugin-extract-path` specified path." + (let* ((vscode-plugin--file-name (file-name-with-extension (file-name-base lsp-sonarlint-vscode-plugin-url) (file-name-extension lsp-sonarlint-vscode-plugin-url))) + (vscode-plugin--store-file-path (concat lsp-sonarlint-vscode-plugin-store-path vscode-plugin--file-name))) + (unless (file-exists-p lsp-sonarlint-vscode-plugin-store-path) + (mkdir lsp-sonarlint-vscode-plugin-store-path t)) + (unless (file-exists-p vscode-plugin--store-file-path) + (when (or lsp-sonarlint-plugin-autodownload + (yes-or-no-p + (format "Sonarlint language server plugin not found, do you want to download it? "))) + (url-copy-file lsp-sonarlint-vscode-plugin-url vscode-plugin--store-file-path))) + (when (file-exists-p lsp-sonarlint-vscode-plugin-extract-path) + (delete-directory lsp-sonarlint-vscode-plugin-extract-path t)) + (unless (file-exists-p lsp-sonarlint-vscode-plugin-extract-path) + (mkdir lsp-sonarlint-vscode-plugin-extract-path t)) + (lsp-unzip vscode-plugin--store-file-path lsp-sonarlint-vscode-plugin-extract-path))) + (defun lsp-sonarlint--plugin-list () "Check for the enabled extensions and return a path list. If the analyzer path is not a file, and lsp-sonarlint-plugin-autodownload is not nil it offers to download the analyzer, and does that." - (let* ((lsp-sonarlint--enabled-plugins - (-filter (lambda (member) - (when (eval - (intern (concat (format "%s" (car member) ) "-enabled"))) - t)) - (custom-group-members 'lsp-sonarlint t)))) - - (lsp-sonarlint--remove-duplicate-plugins - (-map (lambda (enabled-member) - (let* ((enabled-member--download-url - (eval (intern (concat (format "%s" (car enabled-member) ) "-download-url")))) - (enabled-member--analyzer-path - (eval (intern (concat (format "%s" (car enabled-member) ) "-analyzer-path"))))) - (unless (file-exists-p - enabled-member--analyzer-path) - (when (or lsp-sonarlint-plugin-autodownload - (yes-or-no-p - (format "%s language plugin not found, do you want to download it? " - (car enabled-member)))) - (url-copy-file enabled-member--download-url enabled-member--analyzer-path))) - enabled-member--analyzer-path)) - lsp-sonarlint--enabled-plugins)))) + (let* ((lsp-sonarlint--analyzers-list (directory-files (concat lsp-sonarlint-vscode-plugin-extract-path "extension/analyzers/") t ".*\.jar"))) + lsp-sonarlint--analyzers-list)) (defun lsp-sonarlint--code-action-open-rule (_workspace params) "Create a buffer with rendered rule from PARAMS text in it. Extracts the title ahd htmlDescription, and renders the HTML in a temporary buffer." (with-temp-buffer - (let* ((rule-title (format "

%s


" (ht-get params "name"))) - (rule-body (ht-get params "htmlDescription"))) + (let* ((rule-title (format "

%s

" (ht-get params "name"))) + (rule-summary (format "%s
" (ht-get params "htmlDescription"))) + (rule-body-array (ht-get params "htmlDescriptionTabs"))) (insert rule-title) - (insert "\n") - (insert rule-body)) - (shr-render-buffer (current-buffer)))) - + (insert rule-summary) + (insert "\n") + + (seq-doseq (rule-body rule-body-array) + (let ((rule-body-title (format "

%s

" (ht-get rule-body "title"))) + (rule-body-content (format "%s
" (ht-get (ht-get rule-body "ruleDescriptionTabNonContextual") "htmlContent")))) + (insert rule-body-title) + (insert "\n") + (insert rule-body-content)))) + (with-current-buffer (get-buffer-create "*html*") + (when buffer-read-only + (view-mode-exit))) + (shr-render-buffer (current-buffer)) + (if (not buffer-read-only) + (view-mode-enter)) + (local-set-key (kbd "q") 'quit-window) + (switch-to-buffer (current-buffer)))) (defun lsp-sonarlint-server-start-fun (port) "Start lsp-sonarlint in TCP mode listening to port PORT." + (when (eq lsp-sonarlint-server-path nil) + (let ((download-times 1)) + (unless (or (> download-times 3) + (equal (lsp-sonarlint--download-plugins) 0)) + (setq download-times (1+ download-times)) + (delete-directory lsp-sonarlint-vscode-plugin-store-path t) + (delete-directory lsp-sonarlint-vscode-plugin-extract-path t))) + (setq lsp-sonarlint-server-path (car (directory-files (concat lsp-sonarlint-vscode-plugin-extract-path "extension/server/") t ".*\.jar")))) (-concat - `("java" "-jar" ,(eval lsp-sonarlint-server-path) ,(format "-port=%d" port)) - (mapcar (lambda (plugin-path) (format "-analyzers=%s" plugin-path)) - (lsp-sonarlint--plugin-list)))) - + `("java" "-jar" ,(eval lsp-sonarlint-server-path) ,(format "-port=%d" port)) + '("-analyzers") (mapcar (lambda (plugin-path) (format "%s" plugin-path)) + (lsp-sonarlint--plugin-list)))) (defconst lsp-sonarlint--action-handlers '()) @@ -179,7 +281,8 @@ temporary buffer." ("sonarlint.testFilePattern" lsp-sonarlint-test-file-pattern) ("sonarlint.output.showAnalyzerLogs" lsp-sonarlint-show-analyzer-logs) ("sonarlint.output.verboseLogs" lsp-sonarlint-verbose-logs) - ("sonarlint.ls.vmargs" lsp-sonarlint-vmargs))) + ("sonarlint.ls.vmargs" lsp-sonarlint-vmargs) + )) (defun lsp-sonarlint--request-handlers () "SonarLint-specific request handlers. @@ -204,6 +307,19 @@ See REQUEST-HANDLERS in lsp--client in lsp-mode." (puthash "sonarlint/getJavaConfig" (lambda (_workspace _params) nil) ht) ht)) +(defun lsp-sonarlint--get-compilecommands-path (&optional current-dir) + "Return the first found path of compile_commands.json file from `CURRENT-DIR' directory up to parent directories." + (unless current-dir + (setq current-dir default-directory)) + (let* ((target-file (file-name-concat current-dir "compile_commands.json")) + (parent-dir (file-name-parent-directory current-dir))) + (if (and (file-exists-p current-dir) + (not (file-exists-p target-file))) + (if parent-dir + (lsp-sonarlint--get-compilecommands-path parent-dir) + (concat (lsp--suggest-project-root) "compile_commands.json")) + target-file))) + (defun lsp-sonarlint--notification-handlers () "SonarLint-specific notification handlers. See NOTIFICATION-HANDLERS in lsp--client in lsp-mode." @@ -223,17 +339,41 @@ See NOTIFICATION-HANDLERS in lsp--client in lsp-mode." ;; paying attention and will notice anyway. (puthash "sonarlint/showNotificationForFirstSecretsIssue" (lambda (_workspace _params) nil) ht) (puthash "sonarlint/showRuleDescription" #'lsp-sonarlint--code-action-open-rule ht) + ;; Setting initiate value of CompilationDatabase. And setting a hook for updating this value while window changing. + (puthash "sonarlint/needCompilationDatabase" (lambda (_workspace _params) + (message "Try to set sonarlint.pathToCompileCommands to \"%s\"" (lsp-sonarlint--get-compilecommands-path)) + + (with-lsp-workspace _workspace + (setq lsp-sonarlint--compilecommands-path-property (lsp-sonarlint--get-compilecommands-path)) + (lsp--set-configuration (lsp-configuration-section "sonarlint"))) + (add-hook 'window-state-change-hook 'lsp-sonarlint--window-change-hook) + ) ht) ht)) +(defun lsp-sonarlint--window-change-hook () + "Hook while window has changed." + ;; Return if buffer without filename + (when (and (buffer-file-name) + lsp-mode + c-buffer-is-cc-mode) + (setq lsp-sonarlint--compilecommands-path-property (lsp-sonarlint--get-compilecommands-path)) + (when (not (equal lsp-sonarlint--compilecommands-path-property + lsp-sonarlint--old-compilecommands-path-property)) + (with-lsp-workspace (lsp-find-workspace 'sonarlint (buffer-file-name)) + (lsp--set-configuration (lsp-configuration-section "sonarlint")) + (setq lsp-sonarlint--old-compilecommands-path-property lsp-sonarlint--compilecommands-path-property) + (message "Change compilation database to %s" lsp-sonarlint--compilecommands-path-property))))) + (lsp-register-client (make-lsp-client :new-connection (lsp-tcp-server-command 'lsp-sonarlint-server-start-fun) - :major-modes lsp-sonarlint-modes-enabled + :activation-fn (lambda (_file-name _mode) + (-contains? (lsp-sonarlint-modes-enabled) (lsp-buffer-language))) :priority -1 :request-handlers (lsp-sonarlint--request-handlers) :notification-handlers (lsp-sonarlint--notification-handlers) - :multi-root t :add-on? t + :multi-root t :server-id 'sonarlint :action-handlers (ht<-alist lsp-sonarlint--action-handlers) :initialization-options (lambda () @@ -242,6 +382,7 @@ See NOTIFICATION-HANDLERS in lsp--client in lsp-mode." :productName "Emacs")) :initialized-fn (lambda (workspace) (with-lsp-workspace workspace + (setq lsp-sonarlint--old-compilecommands-path-property lsp-sonarlint--compilecommands-path-property) (lsp--set-configuration (lsp-configuration-section "sonarlint")))))) diff --git a/server/LICENSE b/server/LICENSE deleted file mode 100644 index 7a4a3ea..0000000 --- a/server/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/server/sonarlint-language-server.jar b/server/sonarlint-language-server.jar deleted file mode 100644 index 7daf4cd..0000000 Binary files a/server/sonarlint-language-server.jar and /dev/null differ