Skip to content

Cannot get the parser to work with nvim-treesitter #33

@Chamal1120

Description

@Chamal1120

I added the parser.c file for my nvim-treesitter config as below.

treesitter.lua

return {
  "nvim-treesitter/nvim-treesitter",
  lazy = false,
  build = ":TSUpdate",
  config = function()
    -- Register custom parser for ballerina grammar
    local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
    parser_config.ballerina = {
      install_info = {
        url = "~/.config/nvim/tree-sitter-parsers/tree-sitter-ballerina",
        files = { "src/parser.c" },
        generate_requires_npm = false,
      },
      filetype = "ballerina",
    }

    -- treesitter configs
    local config = require("nvim-treesitter.configs")
    config.setup({
      auto_install = true,
      highlight = {
        enable = true,
        disable = { "latex" },
        additional_vim_regex_highlighting = false,
      },
      indent = { enable = true },
    })
  end,
}

Also added .bal as a detectable file type for neovim as below.

init.lua

-- Custom filetype matchings
vim.filetype.add({
  extension = {
    bal = 'ballerina' -- Detect as bellerina files
  },
  pattern = {
    [".*/hypr/.*%.conf"] = "hyprlang", -- Detect as hyprlang files
  },
})

When I open a .bal file nvim-treesitter even showed the "installing ballerina tressitter.." message as well.

But I don't get proper still syntax highlighting yet.

It shows like below

Image

It is not shown in :TSModuleInfo either

Image

I might be doing this wrong. Please correct me if it is the case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions