Closed3

mason.nvimでインストールするLSP, Formatterを管理したい

sakikasakika

:Mason でLSPやFormatterをインストールする形になるが、インストールしたものを保存しておきたい。
(別端末で環境を作る時につらいので)

sakikasakika

https://github.com/williamboman/mason-lspconfig.nvim
これで管理できるのはLSPだけみたい。
試しにFormatterである stylua を指定してみたけどインストールされた様子はない。

local mason_lspconfig = require('mason-lspconfig')
mason_lspconfig.setup({
  ensure_installed = {
    'sumneko_lua',
  },
  automatic_installation = true,
})
sakikasakika

https://github.com/jayp0521/mason-null-ls.nvim

Formatterはこっちで管理できそう。

  use({
    'jayp0521/mason-null-ls.nvim',
    after = {
      'null-ls.nvim',
      'mason.nvim',
    },
    config = function()
      local mason_null_ls = require('mason-null-ls')
      mason_null_ls.setup({
        ensure_installed = {
          { 'stylua', version = 'v0.14.2' },
        },
        automatic_installation = true,
      })
      mason_null_ls.check_install(true)
    end,

stylua の最新をインストールしようとしたが、下記のエラーが出たのでバージョンを下げることに。

[ERROR 土  9/17 20:44:37 2022] ...acker/start/mason.nvim/lua/mason-core/installer/init.lua:146: Installation failed for Package(name=stylua) error="...acker/start/mason.nvim/lua/mason-core/installer/init.lua:113: ...start/mason.nvim/lua/mason-core/managers/github/init.lua:56: Failed to fetch latest release from GitHub API. Refer to :h mason-errors-github-api for more information."

:h mason-errors-github-api みてみると、Github APIの制限に引っかかってしまった?
そうなると他のインストールも失敗しそうだけども

==============================================================================
INSTALLATION ERRORS                                             *mason-errors*

                                                     *mason-errors-github-api*
For some installers, the GitHub API is used to fetch information about
releases. This API imposes a rate limit that may be triggered, causing
installations to fail. The reasons why a rate limit is triggered are many, for
example being behind a public API, or using other software that also send
requests to the GitHub API.

To circumvent this, mason will utilize the GitHub CLI when
available, leading to API requests being subject to a much higher rate limit
threshold when authenticated. Should you run into errors with communicating
with GitHub's API, it's recommended to install, and authenticate, the GitHub
CLI: https://cli.github.com/.

このスクラップは2022/09/17にクローズされました