跳转到内容
新建笔记

E5113: Error while calling lua chunk: D:/program/MinGW/share/nvim-win64/init.lua:44: module 'mason'

Error detected while processing D:\program\MinGW\share\nvim-win64\init.lua:
E5113: Error while calling lua chunk: D:/program/MinGW/share/nvim-win64/init.lua:44: module 'mason' not found:
no field package.preload['mason']
no file '.\mason.lua'
no file 'D:\program\MinGW\share\nvim-win64\bin\lua\mason.lua'
no file 'D:\program\MinGW\share\nvim-win64\bin\lua\mason\init.lua'
no file '.\mason.dll'
no file 'D:\program\MinGW\share\nvim-win64\bin\mason.dll'
no file 'D:\program\MinGW\share\nvim-win64\bin\loadall.dll'
stack traceback:
[C]: in function 'require'
D:/program/MinGW/share/nvim-win64/init.lua:44: in main chunk
Press ENTER or type command to continue

问题描述:

明明已经安装了相关插件,但是在nvim中还是无法使用,添加

require("mason").setup()

无效。

解决方法:

因为 `require(“mason”).setup()` 添加位置错了。正确位置如下:

local vim = vim
local Plug = vim.fn['plug#']
vim.call('plug#begin', 'D:/program/MinGW/share/nvim-win64/nvim-data/plugged')
-- Shorthand notation for GitHub; translates to https://github.com/junegunn/seoul256.vim.git
Plug('junegunn/seoul256.vim')
-- Any valid git URL is allowed
Plug('https://github.com/junegunn/vim-easy-align.git')
-- Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug('fatih/vim-go', { ['tag'] = '*' })
-- Using a non-default branch
Plug('neoclide/coc.nvim', { ['branch'] = 'release' })
-- Use 'dir' option to install plugin in a non-default directory
Plug('junegunn/fzf', { ['dir'] = '~/.fzf' })
-- Post-update hook: run a shell command after installing or updating the plugin
Plug('junegunn/fzf', { ['dir'] = '~/.fzf', ['do'] = './install --all' })
-- Post-update hook can be a lambda expression
Plug('junegunn/fzf', { ['do'] = function()
vim.fn['fzf#install']()
end })
-- If the vim plugin is in a subdirectory, use 'rtp' option to specify its path
Plug('nsf/gocode', { ['rtp'] = 'vim' })
-- On-demand loading: loaded when the specified command is executed
Plug('preservim/nerdtree', { ['on'] = 'NERDTreeToggle' })
-- On-demand loading: loaded when a file with a specific file type is opened
Plug('tpope/vim-fireplace', { ['for'] = 'clojure' })
-- Unmanaged plugin (manually installed and updated)
Plug('~/my-prototype-plugin')
-- mason
Plug ('williamboman/mason.nvim')
vim.call('plug#end')
-- Color schemes should be loaded after plug#end().
-- We prepend it with 'silent!' to ignore errors when it's not yet installed.
-- vim.cmd('silent! colorscheme seoul256')
-- 在最后添加需要启用的插件
require("mason").setup()

来源:CSDN 原文,首次发布于 2024-07-11。