Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin says "snyk, htmlhint, golangci_lint" aren't in Mason registry but they are. #8

Open
lawlondon opened this issue May 7, 2024 · 2 comments

Comments

@lawlondon
Copy link

lawlondon commented May 7, 2024

As title says, I get the notification Linters [golangci-lint, snyk, htmlhint] are absent in the mason's registry. However they do appear to be in mason's registry.

Here is my relevant config:
`
return {
'neovim/nvim-lspconfig',
dependencies = {
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline',
'hrsh7th/nvim-cmp',
'L3MON4D3/LuaSnip',
'saadparwaiz1/cmp_luasnip',
'j-hui/fidget.nvim',
'luckasRanarison/tailwind-tools.nvim',
'onsails/lspkind-nvim',
'stevearc/conform.nvim',
'zapling/mason-conform.nvim',
'mfussenegger/nvim-lint',
'rshkarin/mason-nvim-lint',
},

config = function()
local lsp_capabilities = vim.tbl_deep_extend('force', {}, vim.lsp.protocol.make_client_capabilities(), require('cmp_nvim_lsp').default_capabilities())

local default_setup = function(server)
  require('lspconfig')[server].setup {
    capabilities = lsp_capabilities,
  }
end

require('fidget').setup {}
require('mason').setup()
require('mason-lspconfig').setup {
  ensure_installed = {
    -- C, C++
    'clangd',
    -- C#
    'omnisharp',
    -- CSS
    'cssls',
    -- DOCKER
    'dockerls',
    -- GO
    'gopls',
    -- HTML
    'html',
    -- JSON
    'jsonls',
    -- JAVA
    'jdtls',
    -- JS/TS
    'tsserver',
    -- JULIA
    'julials',
    -- LUA
    'lua_ls',
    -- MARKDOWN
    'markdown_oxide',
    -- PHP
    'intelephense',
    -- PYTHON
    'pyright',
    -- RUBY
    'ruby_lsp',
    -- RUST
    'rust_analyzer',
    -- SQL
    'sqlls',
    -- SVELTE
    'svelte',
    -- TAILWIND
    'tailwindcss',
  },
  handlers = {
    default_setup,
    ['lua_ls'] = function()
      local lspconfig = require 'lspconfig'
      lspconfig.lua_ls.setup {
        capabilities = lsp_capabilities,
        settings = {
          Lua = {
            runtime = { version = 'Lua 5.1' },
            diagnostics = {
              globals = { 'vim', 'it', 'describe', 'before_each', 'after_each' },
            },
          },
        },
      }
    end,
  },
}

local conform = require 'conform'
conform.setup {
  formatters_by_ft = {
    javascript = { 'prettier' },
    typescript = { 'prettier' },
    javascriptreact = { 'prettier' },
    typescriptreact = { 'prettier' },
    svelte = { 'prettier' },
    css = { 'prettier' },
    html = { 'prettier' },
    json = { 'prettier' },
    yaml = { 'prettier' },
    markdown = { 'prettier' },
    graphql = { 'prettier' },
    liquid = { 'prettier' },
    lua = { 'stylua' },
    python = { 'isort', 'black' },
    c = { 'clang-format' },
    cpp = { 'clang-format' },
    c_sharp = { 'csharpier' },
    go = { 'gofmt' },
    rust = { 'rustfmt' },
    php = { 'pretty-php' },
  },
  format_on_save = {
    lsp_fallback = true,
    async = false,
    timeout_ms = 1000,
  },
}

require('mason-conform').setup()

local lint = require 'lint'
lint.linters_by_ft = {
  c = { 'cpplint' },
  cpp = { 'cpplint' },
  javascript = { 'eslint_d' },
  typescript = { 'eslint_d' },
  javascriptreact = { 'eslint_d' },
  typescriptreact = { 'eslint_d' },
  html = { 'htmlhint' },
  css = { 'stylelint' },
  lua = { 'luacheck' },
  python = { 'ruff' },
  go = { 'golangci-lint' },
  rust = { 'snyk' },
  php = { 'phpcs' },
}

vim.api.nvim_create_autocmd({ 'BufWritePost' }, {
  callback = function()
    require('lint').try_lint()
  end,
})

require('mason-nvim-lint').setup()

local cmp = require 'cmp'
cmp.setup {
  snippet = {
    expand = function(args)
      require('luasnip').lsp_expand(args.body)
    end,
  },
  auto_brackets = {},
  completion = {
    completeopt = 'menu,menuone,noinsert',
  },
  mapping = cmp.mapping.preset.insert {
    ['<C-b>'] = cmp.mapping.scroll_docs(-4),
    ['<C-f>'] = cmp.mapping.scroll_docs(4),
    ['<C-Space>'] = cmp.mapping.complete(),
    ['<C-e>'] = cmp.mapping.abort(),
    ['<CR>'] = cmp.mapping.confirm { select = true },
  },
  sources = cmp.config.sources({
    { name = 'nvim_lsp' },
    { name = 'luasnip' },
  }, {
    { name = 'buffer' },
  }),
  formatting = {
    format = require('lspkind').cmp_format {
      before = require('tailwind-tools.cmp').lspkind_format,
    },
  },

  cmp.setup.cmdline({ '/', '?' }, {
    mapping = cmp.mapping.preset.cmdline(),
    sources = {
      { name = 'buffer' },
    },
  }),

  cmp.setup.cmdline(':', {
    mapping = cmp.mapping.preset.cmdline(),
    sources = cmp.config.sources({
      { name = 'path' },
    }, {
      { name = 'cmdline' },
    }),
    matching = { disallow_symbol_nonprefix_matching = false },
  }),
}

--keymaps
--
local map = vim.keymap.set

vim.api.nvim_create_autocmd('LspAttach', {
  desc = 'LSP Actions',
  callback = function(event)
    local opts = { buffer = event.buf }

    map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
    map('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
    map('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
    map('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
    map('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
    map('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
    map('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
    map('n', '<F2>', ':IncRename ', opts)
    map({ 'n', 'x' }, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<CR>', opts)
    map('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
  end,
})

local wk = require 'which-key'
wk.register {
  g = {
    name = 'Goto',
    d = 'Definition',
    D = 'Declaration',
    i = 'Implementation',
    o = 'Type Definiton',
    r = 'Reference',
    s = 'Signature',
  },
}

end,
}
`

@lawlondon lawlondon changed the title Plugin says "cppcheck, snyk, htmlhint, golangci_lint" aren't in Mason registry but they are. Plugin says "snyk, htmlhint, golangci_lint" aren't in Mason registry but they are. May 8, 2024
@LeonardoMor
Copy link
Contributor

Getting the same problem here

LeonardoMor added a commit to LeonardoMor/ui that referenced this issue Jul 8, 2024
Squashed commit of the following:

commit 5d6c844978b0b7a8acfc607cbfdab3dfb63d8392
Author: Leonardo Mora <leonardo_mora@dell.com>
Date:   Mon Jul 8 12:09:01 2024 -0600

    feat(nvim-lint): add snyk and htmlhint

    See: rshkarin/mason-nvim-lint#8

commit 984d655b220a3b235b81fcbcc6c3eb0c3d9a0e0c
Author: Leonardo Mora <leonardo_mora@dell.com>
Date:   Mon Jul 8 11:57:02 2024 -0600

    fix(nvim-lint): correct ansible-lint mapping

    See: rshkarin/mason-nvim-lint#9

commit 806b42fa650f97a8bac445bd727552261dee81ec
Author: Leonardo Mora <leonardo_mora@dell.com>
Date:   Mon Jul 8 11:55:03 2024 -0600

    feat(nvim-lint): add checkmake

    Linter for Makefiles. See: rshkarin/mason-nvim-lint#10

commit a376b63f49fd02f3502b006108fc373b1efb5611
Author: Leonardo Mora <leonardo_mora@dell.com>
Date:   Sun Jul 7 19:41:15 2024 -0600

    refactor(formatters): better name
siduck pushed a commit to NvChad/ui that referenced this issue Jul 9, 2024
* fix(nvim-lint): add/correct some linters

Squashed commit of the following:

commit 5d6c844978b0b7a8acfc607cbfdab3dfb63d8392
Author: Leonardo Mora <leonardo_mora@dell.com>
Date:   Mon Jul 8 12:09:01 2024 -0600

    feat(nvim-lint): add snyk and htmlhint

    See: rshkarin/mason-nvim-lint#8

commit 984d655b220a3b235b81fcbcc6c3eb0c3d9a0e0c
Author: Leonardo Mora <leonardo_mora@dell.com>
Date:   Mon Jul 8 11:57:02 2024 -0600

    fix(nvim-lint): correct ansible-lint mapping

    See: rshkarin/mason-nvim-lint#9

commit 806b42fa650f97a8bac445bd727552261dee81ec
Author: Leonardo Mora <leonardo_mora@dell.com>
Date:   Mon Jul 8 11:55:03 2024 -0600

    feat(nvim-lint): add checkmake

    Linter for Makefiles. See: rshkarin/mason-nvim-lint#10

commit a376b63f49fd02f3502b006108fc373b1efb5611
Author: Leonardo Mora <leonardo_mora@dell.com>
Date:   Sun Jul 7 19:41:15 2024 -0600

    refactor(formatters): better name

* fix(MasonInstallAll): fix linters installation. Fixes #308

* refactor(get_pkgs): expose this function

I find this extremely useful. So added this to have access to this
table.

* refactor(get_pkgs): consider data when handling duplicates

The way it was, you could end up with duplicates introduced by the
incoming data list.

* refactor: no need to re-assign the source table when using
vim.list_extend
@rshkarin
Copy link
Owner

@lawlondon you have a mistake in your nvim-lint configuration. The linter for Go should be golangcilint, otherwise mason-nvim-lint cannot find the mapping to golangci-lint in the Mason registry. Additionally, I have updated the mappings for htmlhint and snyk, as they were added recently and were not specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants