Skip to content

fix: require path for treesitter textobjects on main branch#14

Merged
mawkler merged 1 commit intomawkler:mainfrom
cathyprime:treesitter_main
Oct 7, 2025
Merged

fix: require path for treesitter textobjects on main branch#14
mawkler merged 1 commit intomawkler:mainfrom
cathyprime:treesitter_main

Conversation

@cathyprime
Copy link
Contributor

@cathyprime cathyprime commented May 25, 2025

In new treesitter/treesitter-textobjects version master branch have been frozen and now main is being used, the changes for treesitter-textobjects include change of path, this pr fixes that while remaining compatible with master branch changes

@mawkler
Copy link
Owner

mawkler commented May 25, 2025

Thanks for the contribution! Does repeatint with ;/, work for you in the new main breanch of treesitter/treesitter-textobjects? As far as I understand the new branch is still very much under construction

@cathyprime
Copy link
Contributor Author

even though the branch is under construction, everything is working with main branch for now :P
I'll keep watch on changes and make more prs when more changes are there :3

@chuan2984
Copy link

just did the same thing myself before seeing this pull request, everything is working as intended

@chuan29812
Copy link

chuan29812 commented May 28, 2025

I lied, you actually need more than that to make it work with the new API. repeat_move in textobject changed its return value, it only returns ; or , if its any of the f,F,t,T keys. So backward, foward, next and prev need to handle these differently.
Heres what im doing to get it working, not sure if its optimal

function M.backward()
  local keys = ts_repeatable_move.repeat_last_move({ forward = false, repeated = true })
  if type(keys) == "string" then
    vim.cmd([[normal! ]] .. vim.v.count1 .. keys)
    return true
  else
    return keys
  end
end

this might need to be tested with the mater branch for backward compatibility, should be good enough to cover it tho

@delphinus
Copy link
Contributor

@chuan29812 I found the problem you pointed out has been solved. repeat_last_move() now has a signature: fun(opts_extend: TSTextObjects.MoveOpts?): nil. Yes, this function never returns string.

https://github.com/nvim-treesitter/nvim-treesitter-textobjects/blob/1b2d85d3de6114c4bcea89ffb2cd1ce9e3a19931/lua/nvim-treesitter-textobjects/repeatable_move.lua#L29-L42

Changes in this PR is enough to use with either main or master of nvim-treesitter-textobjects, I think. Can you merge this? @mawkler

@mawkler
Copy link
Owner

mawkler commented Oct 7, 2025

I tried this PR but I keep getting this error with nvim-treesitter-textobjects:

Click to expand
Failed to source `~/code/nvim-test/.repro/data/nvim/lazy/nvim-treesitter-textobjects/plugin/nvim-treesitter-textobjects.vim`

vim/_editor.lua:0: ~/code/nvim-test/test-init.lua..nvim_exec2() called at ~/code/nvim-test/test-init.lua:0[1]..~/code/nvim-test/.repro/data/nvim/lazy/nvim-treesitter-textobj
ects/plugin/nvim-treesitter-textobjects.vim, line 3: Vim(lua):E5108: Error executing lua ...eesitter-textobjects/lua/nvim-treesitter-textobjects.lua:1: module 'nvim-treesitter.configs' not found:
        no field package.preload['nvim-treesitter.configs']
        cache_loader: module 'nvim-treesitter.configs' not found
        cache_loader_lib: module 'nvim-treesitter.configs' not found
        no file '/nix/store/mqvkwip1inkha3p1n8p00cs0vmfdykkv-luajit-2.1.1741730670-env/share/lua/5.1/nvim-treesitter/configs.lua'
        no file '/nix/store/mqvkwip1inkha3p1n8p00cs0vmfdykkv-luajit-2.1.1741730670-env/share/lua/5.1/nvim-treesitter/configs/init.lua'
        no file '/nix/store/mqvkwip1inkha3p1n8p00cs0vmfdykkv-luajit-2.1.1741730670-env/lib/lua/5.1/nvim-treesitter/configs.so'
        no file '/nix/store/mqvkwip1inkha3p1n8p00cs0vmfdykkv-luajit-2.1.1741730670-env/lib/lua/5.1/nvim-treesitter.so'
stack traceback:
        [C]: in function 'require'
        ...eesitter-textobjects/lua/nvim-treesitter-textobjects.lua:1: in main chunk
        [C]: in function 'require'
        [string ":lua"]:1: in main chunk
        [C]: in function 'nvim_exec2'
        vim/_editor.lua: in function 'cmd'
        ....repro/data/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:510: in function <....repro/data/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:509>
        [C]: in function 'xpcall'
        ...t/.repro/data/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:135: in function 'try'
        ....repro/data/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:509: in function 'source'
        ....repro/data/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:457: in function 'source_runtime'
        ...
        ....repro/data/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:354: in function <....repro/data/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:353>
        [C]: in function 'xpcall'
        ...t/.repro/data/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:135: in function 'try'
        ....repro/data/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:353: in function '_load'
        ....repro/data/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:197: in function 'load'
        ....repro/data/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:127: in function 'startup'
        ...m-test/.repro/data/nvim/lazy/lazy.nvim/lua/lazy/init.lua:112: in function 'setup'
        ...-test/.repro/data/nvim/lazy/lazy.nvim/lua/lazy/minit.lua:61: in function 'setup'
        ...-test/.repro/data/nvim/lazy/lazy.nvim/lua/lazy/minit.lua:100: in function 'repro'
        ~/code/nvim-test/test-init.lua:4: in main chunk

# stacktrace:
  - vim/_editor.lua:0 _in_ **cmd**
  - test-init.lua:4

Here's the config I'm using:

Click to expand
-- Use this config by running `nvim -u path/to/this/file`

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    {
      'cathyprime/demicolon.nvim',
      branch = 'treesitter_main',
      dependencies = {
        {
          'nvim-treesitter/nvim-treesitter',
          lazy = false,
          branch = 'main',
          build = ':TSUpdate',
        },
        'nvim-treesitter/nvim-treesitter-textobjects',
      },
      opts = {},
    },
  },
})

@delphinus
Copy link
Contributor

@mawkler Your config uses the main of nvim-treesitter and the master of nvim-treesitter-textobjects. You should the same branch for both.

  spec = {
    {
      'cathyprime/demicolon.nvim',
      branch = 'treesitter_main',
      dependencies = {
        {
          'nvim-treesitter/nvim-treesitter',
          lazy = false,
          branch = 'main',
          build = ':TSUpdate',
        },
        { 'nvim-treesitter/nvim-treesitter-textobjects', branch = 'main' },
      },
      opts = {},
    },
  },

@mawkler
Copy link
Owner

mawkler commented Oct 7, 2025

Ah good catch, thanks!

The PR seems to work as intended on both main and master. Thanks for your contribution!

@mawkler mawkler merged commit 36f9dda into mawkler:main Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants