diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2022-09-12 15:00:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-12 15:00:01 +0200 |
| commit | f0d21848167a3f1a2b4fb64c60ad81f02b9e8a95 (patch) | |
| tree | 7a6e46052ca1d30801dc445387b35f159263609e /lua | |
| parent | chore: update generated code (#408) (diff) | |
| download | mason-f0d21848167a3f1a2b4fb64c60ad81f02b9e8a95.tar mason-f0d21848167a3f1a2b4fb64c60ad81f02b9e8a95.tar.gz mason-f0d21848167a3f1a2b4fb64c60ad81f02b9e8a95.tar.bz2 mason-f0d21848167a3f1a2b4fb64c60ad81f02b9e8a95.tar.lz mason-f0d21848167a3f1a2b4fb64c60ad81f02b9e8a95.tar.xz mason-f0d21848167a3f1a2b4fb64c60ad81f02b9e8a95.tar.zst mason-f0d21848167a3f1a2b4fb64c60ad81f02b9e8a95.zip | |
feat: add phpcs, phpcbf, phpmd, phpstan and twigcs (#399)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/mason-registry/index.lua | 5 | ||||
| -rw-r--r-- | lua/mason-registry/phpcbf/init.lua | 45 | ||||
| -rw-r--r-- | lua/mason-registry/phpcs/init.lua | 45 | ||||
| -rw-r--r-- | lua/mason-registry/phpmd/init.lua | 46 | ||||
| -rw-r--r-- | lua/mason-registry/phpstan/init.lua | 45 | ||||
| -rw-r--r-- | lua/mason-registry/twigcs/init.lua | 47 | ||||
| -rw-r--r-- | lua/mason/mappings/language.lua | 4 |
7 files changed, 235 insertions, 2 deletions
diff --git a/lua/mason-registry/index.lua b/lua/mason-registry/index.lua index 51e4fcf7..2ed6c006 100644 --- a/lua/mason-registry/index.lua +++ b/lua/mason-registry/index.lua @@ -133,6 +133,10 @@ return { ["php-cs-fixer"] = "mason-registry.php-cs-fixer", ["php-debug-adapter"] = "mason-registry.php-debug-adapter", phpactor = "mason-registry.phpactor", + phpcbf = "mason-registry.phpcbf", + phpcs = "mason-registry.phpcs", + phpmd = "mason-registry.phpmd", + phpstan = "mason-registry.phpstan", ["powershell-editor-services"] = "mason-registry.powershell-editor-services", prettier = "mason-registry.prettier", prettierd = "mason-registry.prettierd", @@ -193,6 +197,7 @@ return { texlab = "mason-registry.texlab", textlint = "mason-registry.textlint", tflint = "mason-registry.tflint", + twigcs = "mason-registry.twigcs", ["typescript-language-server"] = "mason-registry.typescript-language-server", ["vala-language-server"] = "mason-registry.vala-language-server", vale = "mason-registry.vale", diff --git a/lua/mason-registry/phpcbf/init.lua b/lua/mason-registry/phpcbf/init.lua new file mode 100644 index 00000000..8cae909a --- /dev/null +++ b/lua/mason-registry/phpcbf/init.lua @@ -0,0 +1,45 @@ +local Pkg = require "mason-core.package" +local _ = require "mason-core.functional" +local github = require "mason-core.managers.github" +local std = require "mason-core.managers.std" +local platform = require "mason-core.platform" +local path = require "mason-core.path" + +return Pkg.new { + name = "phpcbf", + desc = _.dedent [[ + PHP_CodeSniffer(phpcbf) automatically corrects coding standard violations that would be detected by PHP_CodeSniffer(phpcs). + ]], + homepage = "https://github.com/squizlabs/PHP_CodeSniffer", + languages = { Pkg.Lang.PHP }, + categories = { Pkg.Cat.Formatter }, + ---@async + ---@param ctx InstallContext + install = function(ctx) + github + .download_release_file({ + repo = "squizlabs/PHP_CodeSniffer", + asset_file = "phpcbf.phar", + out_file = platform.is.win and "phpcbf.phar" or "phpcbf", + }) + .with_receipt() + platform.when { + unix = function() + std.chmod("+x", { "phpcbf" }) + ctx:link_bin("phpcbf", "phpcbf") + end, + win = function() + ctx:link_bin( + "phpcbf", + ctx:write_shell_exec_wrapper( + "phpcbf", + ("php %q"):format(path.concat { + ctx.package:get_install_path(), + "phpcbf.phar", + }) + ) + ) + end, + } + end, +} diff --git a/lua/mason-registry/phpcs/init.lua b/lua/mason-registry/phpcs/init.lua new file mode 100644 index 00000000..17515ba2 --- /dev/null +++ b/lua/mason-registry/phpcs/init.lua @@ -0,0 +1,45 @@ +local Pkg = require "mason-core.package" +local _ = require "mason-core.functional" +local github = require "mason-core.managers.github" +local std = require "mason-core.managers.std" +local platform = require "mason-core.platform" +local path = require "mason-core.path" + +return Pkg.new { + name = "phpcs", + desc = _.dedent [[ + PHP_CodeSniffer(phpcs) tokenizes PHP, JavaScript and CSS files to detect violations of a defined standard. + ]], + homepage = "https://github.com/squizlabs/PHP_CodeSniffer", + languages = { Pkg.Lang.PHP }, + categories = { Pkg.Cat.Linter }, + ---@async + ---@param ctx InstallContext + install = function(ctx) + github + .download_release_file({ + repo = "squizlabs/PHP_CodeSniffer", + asset_file = "phpcs.phar", + out_file = platform.is.win and "phpcs.phar" or "phpcs", + }) + .with_receipt() + platform.when { + unix = function() + std.chmod("+x", { "phpcs" }) + ctx:link_bin("phpcs", "phpcs") + end, + win = function() + ctx:link_bin( + "phpcs", + ctx:write_shell_exec_wrapper( + "phpcs", + ("php %q"):format(path.concat { + ctx.package:get_install_path(), + "phpcs.phar", + }) + ) + ) + end, + } + end, +} diff --git a/lua/mason-registry/phpmd/init.lua b/lua/mason-registry/phpmd/init.lua new file mode 100644 index 00000000..a7810c54 --- /dev/null +++ b/lua/mason-registry/phpmd/init.lua @@ -0,0 +1,46 @@ +local Pkg = require "mason-core.package" +local _ = require "mason-core.functional" +local github = require "mason-core.managers.github" +local std = require "mason-core.managers.std" +local platform = require "mason-core.platform" +local path = require "mason-core.path" + +return Pkg.new { + name = "phpmd", + desc = _.dedent [[ + PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD. + PHPMD can be seen as an user friendly frontend application for the raw metrics stream measured by PHP Depend. + ]], + homepage = "https://github.com/phpmd/phpmd", + languages = { Pkg.Lang.PHP }, + categories = { Pkg.Cat.Linter }, + ---@async + ---@param ctx InstallContext + install = function(ctx) + github + .download_release_file({ + repo = "phpmd/phpmd", + asset_file = "phpmd.phar", + out_file = platform.is.win and "phpmd.phar" or "phpmd", + }) + .with_receipt() + platform.when { + unix = function() + std.chmod("+x", { "phpmd" }) + ctx:link_bin("phpmd", "phpmd") + end, + win = function() + ctx:link_bin( + "phpmd", + ctx:write_shell_exec_wrapper( + "phpmd", + ("php %q"):format(path.concat { + ctx.package:get_install_path(), + "phpmd.phar", + }) + ) + ) + end, + } + end, +} diff --git a/lua/mason-registry/phpstan/init.lua b/lua/mason-registry/phpstan/init.lua new file mode 100644 index 00000000..bc0bf3ff --- /dev/null +++ b/lua/mason-registry/phpstan/init.lua @@ -0,0 +1,45 @@ +local Pkg = require "mason-core.package" +local _ = require "mason-core.functional" +local github = require "mason-core.managers.github" +local std = require "mason-core.managers.std" +local platform = require "mason-core.platform" +local path = require "mason-core.path" + +return Pkg.new { + name = "phpstan", + desc = _.dedent [[ + PHP Static Analysis Tool - discover bugs in your code without running it! + ]], + homepage = "https://github.com/phpstan/phpstan", + languages = { Pkg.Lang.PHP }, + categories = { Pkg.Cat.Linter }, + ---@async + ---@param ctx InstallContext + install = function(ctx) + github + .download_release_file({ + repo = "phpstan/phpstan", + asset_file = "phpstan.phar", + out_file = platform.is.win and "phpstan.phar" or "phpstan", + }) + .with_receipt() + platform.when { + unix = function() + std.chmod("+x", { "phpstan" }) + ctx:link_bin("phpstan", "phpstan") + end, + win = function() + ctx:link_bin( + "phpstan", + ctx:write_shell_exec_wrapper( + "phpstan", + ("php %q"):format(path.concat { + ctx.package:get_install_path(), + "phpstan.phar", + }) + ) + ) + end, + } + end, +} diff --git a/lua/mason-registry/twigcs/init.lua b/lua/mason-registry/twigcs/init.lua new file mode 100644 index 00000000..ea947c15 --- /dev/null +++ b/lua/mason-registry/twigcs/init.lua @@ -0,0 +1,47 @@ +local Pkg = require "mason-core.package" +local _ = require "mason-core.functional" +local github = require "mason-core.managers.github" +local std = require "mason-core.managers.std" +local platform = require "mason-core.platform" +local path = require "mason-core.path" + +return Pkg.new { + name = "twigcs", + desc = _.dedent [[ + The missing checkstyle for twig! + Twigcs aims to be what phpcs is to php. + It checks your codebase for violations on coding standards. + ]], + homepage = "https://github.com/friendsoftwig/twigcs", + languages = { Pkg.Lang.Twig }, + categories = { Pkg.Cat.Linter }, + ---@async + ---@param ctx InstallContext + install = function(ctx) + github + .download_release_file({ + repo = "friendsoftwig/twigcs", + asset_file = "twigcs.phar", + out_file = platform.is.win and "twigcs.phar" or "twigcs", + }) + .with_receipt() + platform.when { + unix = function() + std.chmod("+x", { "twigcs" }) + ctx:link_bin("twigcs", "twigcs") + end, + win = function() + ctx:link_bin( + "twigcs", + ctx:write_shell_exec_wrapper( + "twigcs", + ("php %q"):format(path.concat { + ctx.package:get_install_path(), + "twigcs.phar", + }) + ) + ) + end, + } + end, +} diff --git a/lua/mason/mappings/language.lua b/lua/mason/mappings/language.lua index b032e90e..78b6545e 100644 --- a/lua/mason/mappings/language.lua +++ b/lua/mason/mappings/language.lua @@ -79,7 +79,7 @@ return { opencl = { "opencl-language-server" }, openfoam = { "foam-language-server" }, perl = { "perlnavigator" }, - php = { "intelephense", "php-cs-fixer", "php-debug-adapter", "phpactor", "psalm" }, + php = { "intelephense", "php-cs-fixer", "php-debug-adapter", "phpactor", "phpcbf", "phpcs", "phpmd", "phpstan", "psalm" }, powershell = { "powershell-editor-services" }, prisma = { "prisma-language-server" }, protobuf = { "buf", "buf-language-server" }, @@ -106,7 +106,7 @@ return { terraform = { "terraform-ls", "tflint" }, text = { "grammarly-languageserver", "ltex-ls", "proselint", "textlint", "vale" }, toml = { "taplo" }, - twig = { "curlylint" }, + twig = { "curlylint", "twigcs" }, typescript = { "chrome-debug-adapter", "deno", "eslint-lsp", "eslint_d", "firefox-debug-adapter", "node-debug2-adapter", "prettier", "prettierd", "rome", "typescript-language-server", "xo" }, v = { "vls" }, vala = { "vala-language-server" }, |
