Ian on the Internet

Updating neovim's treesitter config

Since I wrote about configuring my dev environment, my neovim configuration has rotted a bit.

The latest version of neovim in Homebrew is now 0.12.3, which, it turns out, requires switching from the master branch to the main branch. According to the main branch's README.md, the two branches are effectively different plug-ins and essentially nothing transfers between the two. I only discovered this after a brew upgrade led to some kind of (now-forgotten) breakage reported as Lua errors coming from nvim-treesitter.

My first attempt to fix things led me to find a couple of people's shared nvim configurations that did all sorts of fancy things, but I've lost the links. Having had to go through the process again on a different laptop, I've discovered a simpler configuration approach: just use the main branch's defaults, and use Maksym Hazevych's treesitter-autoinstall.nvim plug-in with its defaults.

My entire init.lua now looks like this:

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(
  {
    { "nvim-treesitter/nvim-treesitter", lazy = false, build = ":TSUpdate" },
    { "catppuccin/nvim", name = "catppuccin", priority = 1000 },
    { "mks-h/treesitter-autoinstall.nvim" },
  }
)

require("treesitter-autoinstall").setup()

-- let catpuccin figure out that tree-sitter is installed
require("catppuccin").setup({
    auto_integrations = true,
})

vim.cmd.colorscheme "catppuccin-mocha"

vim.cmd.set "number"
vim.cmd.set "ruler"

#development #documentation