4 releases

0.2.37 Oct 18, 2024
0.2.37-alpha.3 Aug 30, 2024
0.2.37-alpha.1 Aug 23, 2024

#1137 in Parser implementations

Download history 138/week @ 2024-08-18 252/week @ 2024-08-25 41/week @ 2024-09-01 2/week @ 2024-09-08 37/week @ 2024-09-15 34/week @ 2024-09-22 34/week @ 2024-09-29 6/week @ 2024-10-06 126/week @ 2024-10-13 35/week @ 2024-10-20 15/week @ 2024-10-27 3/week @ 2024-11-03

78 downloads per month
Used in bend-language-server

MIT license

1.5MB
62K SLoC

C 62K SLoC // 0.0% comments Scheme 158 SLoC JavaScript 98 SLoC // 0.2% comments Rust 33 SLoC // 0.1% comments

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.

VSCode

You can use syntax highlighting on VSCode through our VSCode extension, check out its repository here.

Contributing

The grammar descriptions can be found in the directory ./grammar, called by the main file ./grammar.js. Most other files are automatically generated by the tree-sitter CLI using tree-sitter generate.

Dependencies

~2.8–4MB
~78K SLoC