{
"path": "/now/native-treesitter-in-neovim",
"site": "at://did:plc:ia2zdnhjaokf5lazhxrmj6eu/site.standard.publication/3mbykzswhqc2x",
"$type": "site.standard.document",
"title": "Native Treesitter in Neovim",
"content": {
"$type": "site.standard.content.markdown",
"markdown": "As fate would have it, I make a blog post about [returning to Neovim](https://stevedylan.dev/posts/returning-to-neovim/), and for some reason an update to nvim-treesitter breaks my ability to see syntax highlighting for nushell. A very small annoyance, but enough for me to replace it. I remember seeing this [awesome post](https://boltless.me/posts/neovim-config-without-plugins-2025/) by boltless so I knew it was possible. Turned out to be super simple!\n\nFirst I needed something to install the parsers. I ended up following boltless' recommendation of using `luarocks` and making a small script to automate installing necessary parsers: \n\n```rust\ndef tsi [parser: string] {\n let tree = $\"($env.HOME)/.local/share/nvim/site\"\n luarocks --lua-version=5.1 $\"--tree=($tree)\" install $\"tree-sitter-($parser)\"\n}\n```\n\nInstalling them is simple as `tsi rust` or whichever language I need to grab. Next I needed to add these parsers to my packpath, so I added a new `treesitter.lua` to `core` with the following contents. \n\n```lua\n-- Native treesitter parsers installed via luarocks\nlocal rocks_path = vim.fn.stdpath(\"data\") .. \"/site/lib/luarocks/rocks-5.1\"\nfor _, parser_dir in ipairs(vim.fn.glob(rocks_path .. \"/tree-sitter-*/*/\", true, true)) do\n vim.opt.runtimepath:prepend(parser_dir)\nend\n```\n\nOne of the last steps is an `autocmd` to start up tree sitter with the open buffer. \n\n```lua\nvim.api.nvim_create_autocmd(\"FileType\", {\n callback = function(ev)\n pcall(vim.treesitter.start, ev.buf)\n end\n})\n```\n\nA nice small bonus: adding the following to `treesitter.lua` lets me use folds with `za`. \n\n```lua\nvim.o.foldenable = true\nvim.o.foldlevel = 99\nvim.o.foldmethod = \"expr\"\nvim.o.foldexpr = \"v:lua.vim.treesitter.foldexpr()\"\n```\n\nNow everything works how I expect it to, and I've learned more about how treesitter works! Would also highly recommend [this post](https://thevaluable.dev/tree-sitter-neovim-overview/) that goes way deeper into the subject. Nothing beats the rush of solving a small problem to make my dev env faster and smoother!"
},
"coverImage": {
"$type": "blob",
"ref": {
"$link": "bafkreibuxyp2gth3igqik7fxu4cm4nducetgp67hhlx36bwahgnuw4xmoa"
},
"mimeType": "image/png",
"size": 2522
},
"publishedAt": "2026-03-17T23:26:50.622Z",
"textContent": "As fate would have it, I make a blog post about returning to Neovim, and for some reason an update to nvim-treesitter breaks my ability to see syntax highlighting for nushell. A very small annoyance, but enough for me to replace it. I remember seeing this awesome post by boltless so I knew it was possible. Turned out to be super simple!\n\nFirst I needed something to install the parsers. I ended up following boltless' recommendation of using luarocks and making a small script to automate installing necessary parsers: \n\n``rust\ndef tsi [parser: string] {\n let tree = $\"($env.HOME)/.local/share/nvim/site\"\n luarocks --lua-version=5.1 $\"--tree=($tree)\" install $\"tree-sitter-($parser)\"\n}\n`\n\nInstalling them is simple as tsi rust or whichever language I need to grab. Next I needed to add these parsers to my packpath, so I added a new treesitter.lua to core with the following contents. \n\n`lua\n-- Native treesitter parsers installed via luarocks\nlocal rocks_path = vim.fn.stdpath(\"data\") .. \"/site/lib/luarocks/rocks-5.1\"\nfor _, parser_dir in ipairs(vim.fn.glob(rocks_path .. \"/tree-sitter-//\", true, true)) do\n vim.opt.runtimepath:prepend(parser_dir)\nend\n`\n\nOne of the last steps is an autocmd to start up tree sitter with the open buffer. \n\n`lua\nvim.api.nvim_create_autocmd(\"FileType\", {\n callback = function(ev)\n pcall(vim.treesitter.start, ev.buf)\n end\n})\n`\n\nA nice small bonus: adding the following to treesitter.lua lets me use folds with za. \n\n`lua\nvim.o.foldenable = true\nvim.o.foldlevel = 99\nvim.o.foldmethod = \"expr\"\nvim.o.foldexpr = \"v:lua.vim.treesitter.foldexpr()\"\n``\n\nNow everything works how I expect it to, and I've learned more about how treesitter works! Would also highly recommend this post that goes way deeper into the subject. Nothing beats the rush of solving a small problem to make my dev env faster and smoother!"
}