nvim、nvchad、mason,懒惰尝试添加远程插件

问题描述 投票:0回答:1

我正在尝试在 nvim 上安装“numirias/semshi”,我使用 mason 作为插件管理器。它是这样添加到plugins.lua中的:

local plugins = {
    {
        "williamboman/mason.nvim",
        opts = {
            ensure_installed = {
                "pyright",
                "numirias/semshi",
            }
        },
    },

跑步时

:MasonInstallAll

我收到一条错误消息,提示找不到软件包,但 Pyright 已安装并正常工作。感谢任何帮助

neovim
1个回答
0
投票

Lazy 是一个完整的插件管理器,可以处理 neovim 的各种插件。没有真正的插件是 Lazy 无法通过正确的配置来处理的。另一方面,Mason 专门处理 LSP(语言服务器协议)。 LSP 处理与您直接使用的语言相关的事情...诸如语法突出显示、能够根据代码结构选择内容、linting 等。 Pyright 属于该领域,还有其他插件可以扩展 Mason,使其能够处理调试适配器和其他一些特定类别。要运行 Mason,只需使用

:Mason
打开 UI,然后从那里选择您想要的插件并通过 Mason 安装它们。对于懒惰,尝试这样的事情:

-- <Path to your nvim config>/lazy/init.lua
local m = {}

m.checkExists = function()
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)
end

m.init = function()
require("lazy").setup("lazy.plugins", {
    dev = {
        -- directory where you store your local plugin projects
        path = "~/plugins",
        fallback = false,
    },
  git = {
    -- defaults for the `Lazy log` command
    -- log = { "-10" }, -- show the last 10 commits
    log = { "-8" }, -- show commits from the last 3 days
    timeout = 600, -- kill processes that take more than 10 minutes
    url_format = "https://github.com/%s.git",
    -- lazy.nvim requires git >=2.19.0. If you really want to use lazy with an older version,
    -- then set the below to false. This should work, but is NOT supported and will
    -- increase downloads a lot.
    filter = true,
  },
    ui = {
        icons = {
            cmd = "⌘",
            config = "🛠",
            event = "📅",
            ft = "📂",
            init = "⚙",
            keys = "🗝",
            plugin = "🔌",
            runtime = "💻",
            source = "📄",
            start = "🚀",
            task = "📌",
        },
    },
})
end


return m
-- <Path to your nvim config>/lazy/plugins/lsp.lua
-- You can have as many files as you want in this plugins directory. 
-- Obviously use the plugins that you want here. This is from my config; follow this same structure, but modify the plugins to fit your needs.
return {
    {
        "VonHeikemen/lsp-zero.nvim",
        branch = "v1.x",
        dependencies = {
            { "neovim/nvim-lspconfig" },
            { "uga-rosa/cmp-dictionary" },
            {
                "williamboman/mason.nvim",
                config = function()
                    require("pluginInit.mason")
                end,
            },
            { "williamboman/mason-lspconfig.nvim" },
            { "hrsh7th/nvim-cmp" },
            { "hrsh7th/cmp-nvim-lsp" },
            { "hrsh7th/cmp-buffer" },
            { "hrsh7th/cmp-path" },
            { "saadparwaiz1/cmp_luasnip" },
            -- WARNING: cmp-nvim-lua seems to be causing issues in nvim config files for now. Reinstall if the issue can be easily resolved when back on wifi.
            --
            { "hrsh7th/cmp-nvim-lua" },
            { "hrsh7th/cmp-cmdline" },
            { "b0o/SchemaStore.nvim" },
            { "L3MON4D3/LuaSnip" },
        },
        config = function()
            -- require("pluginInit.lsp")
            require("oldfaithful.lsp")
        end,
    },
    {
        "jose-elias-alvarez/null-ls.nvim",
        config = function()
            require("pluginInit.null_ls")
        end,
        dependencies = {
            "nvim-lua/plenary.nvim",
        },
    },
    {
        "ray-x/lsp_signature.nvim",
        config = function()
            require("pluginInit.lsp_signature")
        end,
    },
    {
        "nvimdev/lspsaga.nvim",
        config = function()
            require("lspsagaConfig")
        end,
        dependencies = {
            "nvim-tree/nvim-web-devicons",
            "nvim-lspconfig",
            "nvim-treesitter/nvim-treesitter",
        },
    },
    {
        "numToStr/Comment.nvim",
        config = function()
            require("pluginInit.comment")
        end,
    },
    {
        "folke/todo-comments.nvim",
        dependencies = "nvim-lua/plenary.nvim",
        config = function()
            require("pluginInit.todo_comment")
        end,
        opts = {
            keywords = require("utils.todoComments"),
        },
    },
    {
        "folke/trouble.nvim",
        dependencies = "nvim-tree/nvim-web-devicons",
        config = function()
            require("pluginInit.trouble")
        end,
    },
    {
        "windwp/nvim-autopairs",
        config = function()
            require("nvim-autopairs").setup({})
        end,
    },
    {
        "kylechui/nvim-surround",
        config = function()
            require("nvim-surround").setup({})
        end,
    },
    { "windwp/nvim-ts-autotag", ft = { "typescript", "typescriptreact" } },
    {
        "JoosepAlviste/nvim-ts-context-commentstring",
        ft = { "typescript", "typescriptreact" },
    },
    {
        "L3MON4D3/LuaSnip",
        version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
        build = "make install_jsregexp",
        config = function()
            require("pluginInit.luasnip")
        end,
    },
}

然后从您的

<Path to nvim config>/init.lua
文件中调用设置函数,例如:

require("lazy.init").checkExists()
require("lazy.init").init()
© www.soinside.com 2019 - 2024. All rights reserved.