skip to Main Content

I reinstalled neovim and followed the suggestions in this video. Lua syntax highlighting worked perfectly fine, until I added the following file lazy.lua file (and a require in my init.lua)

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)


require("lazy").setup("my.plugins")

It is this last line that breaks things. If I comment it out, things work as before. If I leave it uncommented then:

I get this error whenever I open a Lua file:

Error detected while processing function <SNR>22_NetrwBrowseChgDir[194]..<SNR>22_NetrwEditFile[10]..BufRea
dPost Autocommands for "*":                                                                               
Error executing lua callback: /usr/share/nvim/runtime/filetype.lua:36: function <SNR>22_NetrwBrowseChgDir[
194]..<SNR>22_NetrwEditFile[10]..BufReadPost Autocommands for "*"..FileType Autocommands for "*"..function
 <SNR>1_LoadFTPlugin[20]..script /usr/share/nvim/runtime/ftplugin/lua.lua: Vim(runtime):E5113: Error while
 calling lua chunk: /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:107: no parser for 'lua' langu
age, see :help treesitter-parsers                                                                         
stack traceback:                                                                                          
        [C]: in function 'error'                                                                          
        /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:107: in function 'add'                    
        /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:111: in function 'new'                
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:41: in function '_create_parser'                   
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:108: in function 'get_parser'                      
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:416: in function 'start'                           
        /usr/share/nvim/runtime/ftplugin/lua.lua:2: in main chunk                                         
        [C]: in function 'nvim_cmd'                                                                       
        /usr/share/nvim/runtime/filetype.lua:36: in function </usr/share/nvim/runtime/filetype.lua:35>    
        [C]: in function 'pcall'                                                                          
        vim/shared.lua: in function <vim/shared.lua:0>                                                    
        [C]: in function '_with'                                                                          
        /usr/share/nvim/runtime/filetype.lua:35: in function </usr/share/nvim/runtime/filetype.lua:10>    
stack traceback:                                                                                          
        [C]: in function '_with'                                                                          
        /usr/share/nvim/runtime/filetype.lua:35: in function </usr/share/nvim/runtime/filetype.lua:10>    

I get a similar error with vimscript which I also don’t get if I comment out the last line.


Background info: I am on Linux (Ubuntu), and have not added any other things to my .config/nvim folder, apart from a few key remappings. I have never installed treesitter, and the command TSupdate in nvim gives E492: Not an editor command: TSupdate. Yet there is a treesitter directory in my /usr/share/nvim/runtime/lua/vim/.

Here is the output of tree inside ~/.config/nvim:

├── init.lua
├── lazy-lock.json
└── lua
    └── my
        ├── core
        │   ├── init.lua
        │   ├── keymaps.lua
        │   └── options.lua
        ├── lazy.lua
        └── plugins
            └── init.lua

And the contents of init.lua inside ~/.config/nvim are:

require("my.core")
require("my.lazy")

The contents of lazy.lua is file at the start of this question. The contents of core/ is just some minor unrelated keymappings and options changes. The contents of plugins/init.lua is either empty, or the following, both of which produce the error:

return {
    "nvim-lua/plenary.nvim",
    "christoomey/vim-tmux-navigator",
}

What could possibly explain this? How could adding a require("lazy").setup("my.plugins") suddenly break the parser?

EDIT:
running :checkhealth inside vim gives the following:

==============================================================================
lazy: require("lazy.health").check()

lazy.nvim ~
- {lazy.nvim} version `11.14.1`
- OK {git} `version 2.34.1`
- OK no existing packages found by other package managers
- OK packer_compiled.lua not found

luarocks ~
- checking `hererocks` installation
- OK no plugins require `luarocks`, so you can ignore any warnings below
- OK {python3} `Python 3.11.7`
- ERROR {/home/noahj/.local/share/nvim/lazy-rocks/hererocks/bin/luarocks} not installed
- WARNING {/home/noahj/.local/share/nvim/lazy-rocks/hererocks/bin/lua} version `5.1` not installed
- WARNING Lazy won't be able to install plugins that require `luarocks`.
  Here's what you can do:
   - fix your `luarocks` installation
   - disable *hererocks* with `opts.rocks.hererocks = false`
   - disable `luarocks` support completely with `opts.rocks.enabled = false`

==============================================================================
vim.deprecated: require("vim.deprecated.health").check()

- OK No deprecated functions detected

==============================================================================
vim.health: require("vim.health.health").check()

Configuration ~
- OK no issues found

Runtime ~
- OK $VIMRUNTIME: /usr/share/nvim/runtime

Performance ~
- OK Build type: RelWithDebInfo

Remote Plugins ~
- OK Up to date

terminal ~
- ERROR command failed: infocmp -L
  infocmp: couldn't open terminfo file (null).
  
- $COLORTERM="truecolor"

External Tools ~
- WARNING ripgrep not available

==============================================================================
vim.lsp: require("vim.lsp.health").check()

- LSP log level : WARN
- Log path: /home/noahj/.local/state/nvim/lsp.log
- Log size: 0 KB

vim.lsp: Active Clients ~
- No active clients

vim.lsp: File Watcher ~
- file watching "(workspace/didChangeWatchedFiles)" disabled on all clients

vim.lsp: Position Encodings ~
- No active clients

==============================================================================
vim.provider: require("vim.provider.health").check()

Clipboard (optional) ~
- OK Clipboard tool found: xsel

Node.js provider (optional) ~
- Node.js: v12.22.9
  
- WARNING Missing "neovim" npm (or yarn, pnpm) package.
  - ADVICE:
    - Run in shell: npm install -g neovim
    - Run in shell (if you use yarn): yarn global add neovim
    - Run in shell (if you use pnpm): pnpm install -g neovim
    - You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim

Perl provider (optional) ~
- WARNING "Neovim::Ext" cpan module is not installed
  - ADVICE:
    - See :help |provider-perl| for more information.
    - You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim
- WARNING No usable perl executable found

Python 3 provider (optional) ~
- WARNING No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
- WARNING Could not load Python :
  /home/noahj/anaconda3/bin/python3 does not have the "neovim" module.
  python3.12 not found in search path or not executable.
  /home/noahj/anaconda3/bin/python3.11 does not have the "neovim" module.
  /usr/bin/python3.10 does not have the "neovim" module.
  python3.9 not found in search path or not executable.
  python3.8 not found in search path or not executable.
  python3.7 not found in search path or not executable.
  /home/noahj/anaconda3/bin/python does not have the "neovim" module.
  - ADVICE:
    - See :help |provider-python| for more information.
    - You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim
- Executable: Not found

Python virtualenv ~
- OK no $VIRTUAL_ENV

Ruby provider (optional) ~
- Ruby: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]
- WARNING `neovim-ruby-host` not found.
  - ADVICE:
    - Run `gem install neovim` to ensure the neovim RubyGem is installed.
    - Run `gem environment` to ensure the gem bin directory is in $PATH.
    - If you are using rvm/rbenv/chruby, try "rehashing".
    - See :help |g:ruby_host_prog| for non-standard gem installations.
    - You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim

==============================================================================
vim.treesitter: require("vim.treesitter.health").check()

- Nvim runtime ABI version: 14

2

Answers


  1. Neovim doesn’t like it when it can’t access language parsers for a few languages.

    According to the docs, lazy.nvim "resets the runtime path to $VIMRUNTIME and your config directory". That renders the builtin parsers unreachable. The solution would be to either turn this default setting off or to install the required parsers with the nvim-treesitter plugin.

    Here is how I do it:

    local opts = {
      ensure_installed = {
        'c',
        'lua',
        'vim',
        'vimdoc',
        'query',
        'markdown',
        'markdown_inline',
      },
    }
    
    local function config()
      require('nvim-treesitter.configs').setup(opts)
    end
    return {
      'nvim-treesitter/nvim-treesitter',
      config = config,
      build = ':TSUpdate',
    }
    
    
    Login or Signup to reply.
  2. Had the exact same problem, installing the nvim-treesitter plugin as mentioned by Worm solved it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search