tree-sitter-grammars / tree-sitter-hyprlang

hyprlang grammar for tree-sitter
MIT License
116 stars 2 forks source link

bug: Hyprland doesn't load (`:TSBufEnable`, `:TSToggle hyprland`, `:TSEnable highlight` do not work), commentstring also doesn't work #18

Closed daUnknownCoder closed 3 months ago

daUnknownCoder commented 3 months ago

Did you check existing issues?

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

No response

Describe the bug

my current config is:

return {
  "nvim-treesitter/nvim-treesitter",
  build = ":TSUpdate",
  lazy = true,
  event = { "UIEnter" },
  version = false,
  dependencies = {
    -- ...
    {
      "JoosepAlviste/nvim-ts-context-commentstring",
      lazy = true,
    },
    -- ...
  },      
  cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" },
  init = function(plugin)
    require("lazy.core.loader").add_to_rtp(plugin)
    require("nvim-treesitter.query_predicates")
  end,
  config = function()
    local treesitter_status_ok, treesitter = pcall(require, "nvim-treesitter.configs")
    if not treesitter_status_ok then
      print("treesitter not found!")
    end
    vim.g.skip_ts_context_commentstring_module = true
    require("ts_context_commentstring").setup({
      enable_autocmd = false,
      languages = {
        hyprlang = "# %s",
      },
    })
    require("nvim-treesitter.install").prefer_git = true
    ---@diagnostic disable-next-line: missing-fields
    treesitter.setup({
      ensure_installed = {
        -- ...
        "hyprlang",
        -- ...
      },
      sync_install = false,
      auto_install = true,
      highlight = {
        enable = true,
        additional_vim_regex_highlighting = false,
      },
      indent = {
        enable = true,
      },
      incremental_selection = {
        enable = true,
        keymaps = {
          init_selection = "<c-space>",
          node_incremental = "<c-space>",
          scope_incremental = false,
          node_decremental = "<bs>",
        },
      },
    })
    vim.filetype.add({
      pattern = { [".*/hypr/.*%.conf"] = "hyprlang" },
    })
  end,
}

but it still doesnt work

Steps To Reproduce/Bad Parse Tree

image

note that im in ~/.config/hypr, nvim ~/.config/hypr/hyprland.conf from another directory doesnt work anyway

Expected Behavior/Parse Tree

it should work

Repro

No response

clason commented 3 months ago

This has nothing to do with this parser; please check your configuration. The filetype needs to be set to hyprlang, either automatically or manually.

daUnknownCoder commented 3 months ago

This has nothing to do with this parser; please check your configuration. The filetype needs to be set to hyprlang, either automatically or manually.

vim.bo.filetype returns conf even after adding it to my treesitter config... do i have to add it to my init.lua?

clason commented 3 months ago

Yes. Do not lazy load filetype config.

daUnknownCoder commented 3 months ago

And abt the commentstring thing? I have to install a new plugin for that stuff