0.0.1 • Published 1 year ago

tree-sitter-cue v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

tree-sitter-cue

Build Status Discord

Cue grammar for tree-sitter.

AST and highlights in Neovim

Setup in neovim

-- This is required to not have cue files marked as `cuesheet`
vim.filetype.add({
  extension = {
    cue = "cue",
  },
})

local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.cue = {
  install_info = {
    url = "https://github.com/eonpatapon/tree-sitter-cue", -- local path or git repo
    files = { "src/parser.c", "src/scanner.c" },
  },
}

treesitter.setup {
  ensure_installed = {
    "cue",
    ...
  }
}

For tree-sitter to really work, copy ./queries/*.scm in your nvim configuration (usually ~/.config/nvim) in a directory queries/cue/.

Alternatively the queries directory can be put in any directory referenced in nvim runtimepath.

Custom captures

You can customize highlighting further by remapping captures to nvim highlighting groups like so:

treesitter.setup {
  highlight = {
    enable = true,
    additional_vim_regex_highlighting = false,
    custom_captures = {
      --- cue
      ["operator.default"] = "Statement",
      ["operator.regexp"] = "Statement",
      ["operator.unify"] = "Statement",
      ["operator.disjunct"] = "Label",
      ["definition"] = "Bold"
    }
  }
}
0.0.1

1 year ago