Skip to content

Commit

Permalink
Merge pull request #13 from rshkarin/update-mappings
Browse files Browse the repository at this point in the history
Update mappings
  • Loading branch information
rshkarin committed Jul 14, 2024
2 parents b9ae43a + 2917274 commit b579a00
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ local DEFAULT_SETTINGS = {

#### Basic Customization

Using this configuration, only linters specified in `ensure_installed` will be installed, ones specified in `nvim-lint` will be ignored.
Using this configuration, linters specified in `ensure_installed` will be installed directly from the mason's registry, and ones specified in `nvim-lint` will be translated to Mason format and installed.
**NOTE:** The linters in `ensure_installed` should be written in the format of the mason's registry (https://mason-registry.dev/).

```lua
require ('mason-nvim-lint').setup({
ensure_installed = {'eslint_d', 'revive'},
ensure_installed = { 'bacon' }, -- bacon linter for rust is not available in nvim-lint, so it's specified to be directly installed from the mason's registry
})
```

Expand Down
17 changes: 16 additions & 1 deletion lua/mason-nvim-lint/install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,22 @@ function M.try_install(mason_linter_identifier)
local Package = require "mason-core.package"
local package_name, version = Package.Parse(mason_linter_identifier)

resolve_package(package_name)
local resolved_package = resolve_package(package_name)

if resolved_package == nil then
if not settings.current.quiet_mode then
vim.notify(
("[mason-nvim-lint] Linter %q cannot be resolved into a Mason package. Make sure to only provide valid linter names.")
:format(
package_name
),
vim.log.levels.WARN
)
return
end
end

resolved_package
:if_present(
---@param pkg Package
function(pkg)
Expand Down
4 changes: 3 additions & 1 deletion lua/mason-nvim-lint/mapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ M.nvimlint_to_package = {
["gdlint"] = "gdtoolkit",
["golangcilint"] = "golangci-lint",
["hadolint"] = "hadolint",
["htmlhint"] = "htmlhint",
["jsonlint"] = "jsonlint",
["ktlint"] = "ktlint",
["luacheck"] = "luacheck",
Expand All @@ -47,13 +48,14 @@ M.nvimlint_to_package = {
["sqlfluff"] = "sqlfluff",
["standardrb"] = "standardrb",
["stylelint"] = "stylelint",
["snyk_iac"] = "snyk",
["tflint"] = "tflint",
["tfsec"] = "tfsec",
["trivy"] = "trivy",
["vale"] = "vale",
["vint"] = "vint",
["vulture"] = "vulture",
["write-good"] = "write-good",
["write_good"] = "write-good",
["yamllint"] = "yamllint",
}

Expand Down

0 comments on commit b579a00

Please sign in to comment.