luaneovimneovim-plugin

Error executing lua /home/user/.config/nvim/lua/init.lua:7: module 'vscode.colors' not found:


I'm trying to update the theme of my neovim similar to vscode. I found this Plugin for the neovim to do that: https://github.com/Mofiqul/vscode.nvim

I followed the documentation which what I did is put Plug 'Mofiqul/vscode.nvim' in the ~/.config/nvim/init.vim, and ran the command :PlugInstall which it installed the Plugin on the ~/.config/nvim/Plugged/vscode.nvim

After that I create a lua directory and a init.lua file to create the usage for the plugin: ~/.config/nvim/lua/init.lua

After I did those step when I tried to open nvim It shows me this:

Error detected while processing /home/user/.config/nvim/init.vim:
line    3:
E5108: Error executing lua /home/user/.config/nvim/lua/init.lua:7: module 'vscode.colors' not found:
        no field package.preload['vscode.colors']
        no file './vscode/colors.lua'
        no file '/usr/share/luajit-2.1.0-beta3/vscode/colors.lua'
        no file '/usr/local/share/lua/5.1/vscode/colors.lua'
        no file '/usr/local/share/lua/5.1/vscode/colors/init.lua'
        no file '/usr/share/lua/5.1/vscode/colors.lua'
        no file '/usr/share/lua/5.1/vscode/colors/init.lua'
        no file './vscode/colors.so'
        no file '/usr/local/lib/lua/5.1/vscode/colors.so'
        no file '/usr/lib/x86_64-linux-gnu/lua/5.1/vscode/colors.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './vscode.so'
        no file '/usr/local/lib/lua/5.1/vscode.so'
        no file '/usr/lib/x86_64-linux-gnu/lua/5.1/vscode.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        /home/user/.config/nvim/lua/init.lua:7: in main chunk
        [C]: in function 'require'
        [string ":lua"]:1: in main chunk

This is my init.vim file:

:set number

lua require('init')

call plug#begin()


Plug 'http://github.com/tpope/vim-surround' " Surrounding ysw)
Plug 'https://github.com/preservim/nerdtree' " NerdTree
Plug 'https://github.com/tpope/vim-commentary' " For Commenting gcc & gc
Plug 'https://github.com/vim-airline/vim-airline' " Status bar
Plug 'https://github.com/ap/vim-css-color' " CSS Color Preview
Plug 'https://github.com/rafi/awesome-vim-colorschemes' " Retro Scheme
Plug 'https://github.com/neoclide/coc.nvim'  " Auto Completion
Plug 'https://github.com/ryanoasis/vim-devicons' " Developer Icons
Plug 'https://github.com/tc50cal/vim-terminal' " Vim Terminal
Plug 'https://github.com/preservim/tagbar' " Tagbar for code navigation
Plug 'https://github.com/terryma/vim-multiple-cursors' " CTRL + N for multiple cursors
"Plug 'tomasiser/vim-code-dark'
"Plug 'catppuccin/nvim', { 'as': 'catppuccin' }
"Plug 'rktjmp/lush.nvim'
"Plug 'rockyzhang24/arctic.nvim'
Plug 'Mofiqul/vscode.nvim'


call plug#end()

" colorscheme catppuccin-mocha
"colorscheme codedark
" colorscheme arctic


set encoding=UTF-8

let g:NERDTreeDirArrowExpandable="+"
let g:NERDTreeDirArrowCollapsible="~"
let g:coc_disable_startup_warning = 1
let g:WebDevIconsUnicodeDecorateFolderNodes=1

Is any way to solve this ?


Solution

  • This error occurs because you are installing vim-plug using init.vim and the VSCode theme using init.lua file. Nvim can use either one, but not both files simultaneously [1].

    Install vim-plug using init.lua [2], and delete the init.vim file, vim-plug in lua should be something like:

    local Plug = vim.fn['plug#']
    vim.call('plug#begin')
    Plug 'Mofiqul/vscode.nvim'
    vim.call('plug#end')
    

    And after you follow the Usage of the plugin

    P.S.: Also, if you are using nvim, consider using lazyvim as your plug manager instead.