Skip to content

HigherOrderCO/tree-sitter-bend

Repository files navigation

tree-sitter-bend

Bend grammar for tree-sitter.

Usage

Neovim

Installation

First of all, you need to install nvim-treesitter with your favorite dependency manager, such as lazy.nvim.

After that, you should add this code snippet to your Neovim configuration right after calling require("nvim-treesitter.configs").setup(). The configuration file can be found or created at ~/.config/nvim/init.lua.

local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.bend = {
  install_info = {
    url = "https://github.com/HigherOrderCO/tree-sitter-bend",
    files = { "src/parser.c", "src/scanner.c" },
    branch = "main",
  },
}

vim.filetype.add({
  extension = {
    bend = "bend",
  },
})

vim.treesitter.language.register("bend", { "bend" })

Using lazy.nvim, your configuration could look like this:

plugins = {
  {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    config = function () 
      local configs = require("nvim-treesitter.configs")

      configs.setup({
        ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "elixir", "heex", "javascript", "html" },
        sync_install = false,
        highlight = { enable = true },
        indent = { enable = true },
      })
      
      local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
      parser_config.bend = {
        install_info = {
          url = "https://github.com/HigherOrderCO/tree-sitter-bend",
          files = { "src/parser.c", "src/scanner.c" },
          branch = "main",
        },
      }
      
      vim.filetype.add({
        extension = {
          bend = "bend",
        },
      })

      vim.treesitter.language.register("bend", { "bend" })
    end
  }
}

require("lazy").setup(plugins)

Finally, install the language grammar into the Tree-sitter plugin by running :TSInstall bend on Neovim.

Syntax highlighting

For syntax highlighting to work, you have to create a queries/bend directory in your Neovim configuration root and copy the file highlights.scm into it.

You might have to update the Tree-sitter plugin afterwards by running :TSUpdate on Neovim.

Contributing

The main grammar description can be found on grammar.js. Most other files are automatically generated by the Tree-sitter CLI using tree-sitter generate.

Collaborators

This project was started by Victor Hugo Gomes (@LaBatata101 on GitHub). Thanks!

About

Bend grammar for tree-sitter.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published