Skip to content

Not compatible with Neovim 0.12.2 #39

Description

@n0099

When opening any nix file that contains attr set with string value like

{ a = "test"; }

will throw

Decoration provider "start" (ns=nvim.treesitter.highlighter):                                                         
Lua: ...2/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:0: ...m6l2dvi58gi469-vimplugin-hmts.nvim-1.3.0/plugin/hmts.lua:127: attempt to call method 'parent' (a nil value)                                                          
stack traceback:                                                                                                      
        [builtin#36]: at 0x7334ac556980                                                                               
        ...2/share/nvim/runtime/lua/vim/treesitter/languagetree.lua: in function ''                                   
        ...2/share/nvim/runtime/lua/vim/treesitter/languagetree.lua: in function 'parse'                              
        ....2/share/nvim/runtime/lua/vim/treesitter/highlighter.lua: in function <....2/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:0>      

local node = match[predicate[2]]:parent()

Adding

print(vim.inspect({ match = match, predicate = predicate, child_node = match[predicate[2]] }))

before that line will print:

{
  child_node = <1>{ <userdata 1> },
  match = { <table 1>, { <userdata 2> } },
  predicate = { "hmts-path?", 1, "programs", "(firefox|floorp|librewolf|thunderbird)", "profiles", ".*", "userC(hrome|ontent)" }
}

that predicate is added by me: https://github.com/n0099/nixos/blob/1cd0919123e58411aa5e51f722dba45edc63324b/modules/vim.nix#L10, after removed that it would becomes

{
  child_node = <1>{ <userdata 1> },
  match = { { <userdata 2> },
    [4] = <table 1>
  },
  predicate = { "hmts-path?", 4, "home", "file", ".*", "text" }
}

from

attrpath: (_) @_path (#hmts-path? @_path "home" "file" ".*" "text")

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