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 chunkPress ENTER or type command to continue问题描述:
明明已经安装了相关插件,但是在nvim中还是无法使用,添加
require("mason").setup()无效。
解决方法:
因为 `require(“mason”).setup()` 添加位置错了。正确位置如下:
local vim = vimlocal 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.gitPlug('junegunn/seoul256.vim')
-- Any valid git URL is allowedPlug('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 branchPlug('neoclide/coc.nvim', { ['branch'] = 'release' })
-- Use 'dir' option to install plugin in a non-default directoryPlug('junegunn/fzf', { ['dir'] = '~/.fzf' })
-- Post-update hook: run a shell command after installing or updating the pluginPlug('junegunn/fzf', { ['dir'] = '~/.fzf', ['do'] = './install --all' })
-- Post-update hook can be a lambda expressionPlug('junegunn/fzf', { ['do'] = function() vim.fn['fzf#install']()end })
-- If the vim plugin is in a subdirectory, use 'rtp' option to specify its pathPlug('nsf/gocode', { ['rtp'] = 'vim' })
-- On-demand loading: loaded when the specified command is executedPlug('preservim/nerdtree', { ['on'] = 'NERDTreeToggle' })
-- On-demand loading: loaded when a file with a specific file type is openedPlug('tpope/vim-fireplace', { ['for'] = 'clojure' })
-- Unmanaged plugin (manually installed and updated)Plug('~/my-prototype-plugin')
-- masonPlug ('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。