GithubHelp home page GithubHelp logo

Comments (8)

stsewd avatar stsewd commented on May 18, 2024 2

@stsewd could you elaborate on what you mean? I'm running into the same issue...

@dlants create a file in ~/.config/nvim/after/queries/go/textobjects.scm (node) @mycustomobject with your custom queries, and then in your config

require'nvim-treesitter.configs'.setup {
  textobjects = {
    select = {
      enable = true,
      lookahead = true,

      keymaps = {
        -- You can use the capture groups defined in textobjects.scm
        ["af"] = "@mycustomobject",
     },
   },
}

from nvim-treesitter-textobjects.

kiyoon avatar kiyoon commented on May 18, 2024 1

@mawkler Maybe you need to put ; extends

from nvim-treesitter-textobjects.

rfwatson avatar rfwatson commented on May 18, 2024

I experienced the same attempt to index local 'query' (a nil value) error when trying to define custom textobjects for the Go language. I threw in some debugging and discovered that the plugin was falling back to the comment language at some point during the text object flow. I've got no idea if this should be expected, but removing unused languages including the comment language silenced the error.

Unfortunately, the custom textobjects still don't seem to trigger for me after this change.

from nvim-treesitter-textobjects.

stsewd avatar stsewd commented on May 18, 2024

I think this option should be deprecated and instead recommend putting your custom queries on ~/.config/nvim/after/queries/go/textobjects.scm

from nvim-treesitter-textobjects.

dlants avatar dlants commented on May 18, 2024

@stsewd could you elaborate on what you mean? I'm running into the same issue...

from nvim-treesitter-textobjects.

mawkler avatar mawkler commented on May 18, 2024

@stsewd I can't get your solution to work. I tried creating the following textobjects.csm file

;; ~/.config/nvim/after/queries/typescript/textobjects.scm
(method_definition) @mymethod

And I'm using the following minimal lazy.nvim config:

{
  'nvim-treesitter/nvim-treesitter',
  dependencies = 'nvim-treesitter/nvim-treesitter-textobjects',
  build = ':TSUpdate',
  config = function()
    require('nvim-treesitter.configs').setup({
      ensure_installed = 'all',
      highlight = {
        enable = true,
      },
      textobjects = {
        move = {
          enable = true,
          goto_next_start = {
            [']m'] = '@mymethod'
          }
        }
      }
    })
  end
}

Nothing happens when I press ]m inside a TypeScript file (with a bunch of methods). I want ]m to jump to the next method. What am I doing wrong?

from nvim-treesitter-textobjects.

mawkler avatar mawkler commented on May 18, 2024

@kiyoon That works, thank you!

Do you have a link to some resource that explains what ; extends does? I couldn't find any info online.

from nvim-treesitter-textobjects.

sogaiu avatar sogaiu commented on May 18, 2024

FWIW, not sure if it's the same, but I learned about using ; extends in the context of nvim-treesitter here.

from nvim-treesitter-textobjects.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.