Skip to content

nvim-neorocks/rocks-treesitter.nvim

Repository files navigation


rocks-treesitter.nvim


Report Bug · Request Feature · Ask Question

A "just works" tree-sitter setup for rocks.nvim!

LuaRocks

Warning

This module is WIP and does not have a stable release yet.

🌟 Summary

rocks-treesitter.nvim is a rocks.nvim module that helps you manage and use tree-sitter parsers.

It aims to be a minimal replacement for nvim-treesitter.

Parsers, bundled with queries, are hosted on rocks-binaries (dev), so that you don't have to compile them on your machine.

Do I need this plugin?

No. Plugins that depend on tree-sitter parsers can specify the dependencies in their rockspecs.

You can also install the parsers manually, using :Rocks install tree-sitter-<lang>. To enable highlighting for parser <lang>, all you need to do is create a ftplugin/<lang>.lua file, and in it, call vim.treesitter.start().

See also the rocks.nvim README's tree-sitter section.

This plugin is for convenience.

📝 Requirements

  • An up-to-date rocks.nvim.

🔨 Installation

Simply run :Rocks install rocks-treesitter.nvim, and you are good to go!

📚 Usage

This plugin works out of the box and doesn't need any configuration. However, you can override its default configuration in one of two ways:

  • In rocks.toml
  • With a Lua config

Warning

  • Tree-sitter and treesitter highlighting are an experimental feature of Neovim. As with nvim-treesitter, please consider tree-sitter support with this plugin experimental.

  • We are not affiliated with the nvim-treesitter maintainers. If you are facing issues with tree-sitter support in rocks.nvim, please don't bug them.

🔧 Configuration

Using rocks.toml

You can add a [treesitter] section to your rocks.toml, and use it to set any options you would otherwise pass to require("nvim-treesitter.configs").setup {}1.

[treesitter]
# auto_highlight = "all"
# NOTE: These are parsers, not filetypes.
auto_highlight = [
  "haskell",
  "dhall",
  "rust",
  "toml"
]
auto_install = "prompt" # true | false

[treesitter.parser_map]
# You can add custom filetype to parser mappings.
# Determine the filetype with ':lua =vim.bo[0].filetype'.
# NOTE: You don't actually have to add these examples.
# They are added by default.
PKGBUILD = "bash"
cls = "latex"
sty = "latex"

With lua:

Or, you add a lua table to your vim.g.rocks_nvim setting:

vim.g.rocks_nvim = {
    -- rocks.nvim config
    treesitter = {
        auto_highlight = { },
        auto_install = "prompt",
        parser_map = { },
    },
}

Important

If both configuration methods are used, the lua configuration is given higher priority, to support things like :h exrc.

🚧 Current limitations

  • Currently, we are having issues building the tree-sitter parsers for Windows in our rocks-binaries CI. It is likely that you will run into the same issues if you are on Windows.

📖 License

rocks-treesitter.nvim is licensed under GPLv3.

Footnotes

  1. See nvim-treesitter for configuration options.