Skip to content

@property for lua won't work #875

Open

Description

@luiza177

I'm trying to add a query to target key-value pairs in Lua, such as:

local test = {
  foo = "bar"
}

So, in ~/.config/nvim/after/queries/lua/textobjects.scm I have this:

;;extends
(field
  name: (identifier) @property.lhs
  value: (_) @property.inner) @property.outer

In my textobjects config I have it assigned like so:

			textobjects = {
				select = {
					enable = true,
					lookahead = true,
					keymaps = {
						-- ...
						["av"] = { query = "@property.outer", desc = "Outer property" }, 
						["iv"] = { query = "@property.inner", desc = "Value" }, 
						["lv"] = { query = "@property.lhs", desc = "Key" }, 
                                                -- ...
					},
				},
				-- ...
		})

I've checked the query with :EditQuery, I've tried :TSEditQueryUserAfter which points to the correct file. In theory, if I go civ at foo, I should be able to change "bar" to whatever. I've checked with :InspectTree, but nothing happens. :checkhealth nvim-treesitter looks all good. I've also tried changing the ;;extends line to pretty much every variation of 1 or 2 ;, with or without spaces, nothing seems to help. What am I missing?

Activity

  1. kiyoon commented on Apr 1, 2026

    @kiyoon
    Collaborator

    Can you use main branch of this plugin? I think the config is older unsupported version.

  2. luiza177 commented on Apr 1, 2026

    @luiza177
    Author

    I believe I already am. Just in case I added branch = "main", but nothing changed. Also, I have it as a dependency of the regular nvim-treesitter, like so:

    return {
      "nvim-treesitter/nvim-treesitter",
      branch = "master",
      build = ":TSUpdate",
      cmd = { "TSUpdate", "TSInstall", "TSLog", "TSUninstall" },
      event = { "BufReadPre", "BufNewFile" },
      dependencies = {
        "windwp/nvim-ts-autotag",
        {
          "nvim-treesitter/nvim-treesitter-context",
          opts = function()
            local tsc = require("treesitter-context")
            Snacks.toggle({
              name = "Treesitter Context",
              get = tsc.enabled,
              set = function(state)
                if state then
                  tsc.enable()
                else
                  tsc.disable()
                end
              end,
            }):map("<leader>ut")
            return { mode = "cursor", max_lines = 3 }
          end,
        },
        { "nvim-treesitter/nvim-treesitter-textobjects", branch = "main" }, -- HERE
        "HiPhish/rainbow-delimiters.nvim",
      },
    -- ...
    }

    I've also tried having it as its own file, with nvim-treesitter as a dependency instead, and that didn't help either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions