Skip to content

Commit

Permalink
Use nvim-treesitter's compat module for now
Browse files Browse the repository at this point in the history
  • Loading branch information
andymass committed Apr 17, 2023
1 parent 57499f5 commit 327eb6f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
14 changes: 0 additions & 14 deletions lua/treesitter-matchup/compat.lua

This file was deleted.

4 changes: 2 additions & 2 deletions lua/treesitter-matchup/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ end

local vim = vim
local api = vim.api
local ts = require'treesitter-matchup.compat'
local ts_compat = require'nvim-treesitter.compat'
local configs = require'nvim-treesitter.configs'
local parsers = require'nvim-treesitter.parsers'
local queries = require'treesitter-matchup.third-party.query'
Expand Down Expand Up @@ -155,7 +155,7 @@ function M.containing_scope(node, bufnr, key)
end

local function _node_text(node, bufnr)
local text = ts.get_node_text(node, bufnr)
local text = ts_compat.get_node_text(node, bufnr)
return text:match("(%S+).*")
end

Expand Down
4 changes: 2 additions & 2 deletions lua/treesitter-matchup/third-party/query.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-- See nvim-treesitter.LICENSE-APACHE-2.0

local api = vim.api
local ts = require 'treesitter-matchup.compat'
local ts_compat = require 'nvim-treesitter.compat'
local tsrange = require "nvim-treesitter.tsrange"
local utils = require "nvim-treesitter.utils"
local parsers = require "nvim-treesitter.parsers"
Expand Down Expand Up @@ -52,7 +52,7 @@ do
---@param query_name string
function M.get_query(lang, query_name)
if cache[lang][query_name] == nil then
cache[lang][query_name] = ts.get_query(lang, query_name)
cache[lang][query_name] = ts_compat.get_query(lang, query_name)
end

return cache[lang][query_name]
Expand Down

7 comments on commit 327eb6f

@peku-jamf
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andymass fyi, after this commit integration of vim-matchup and TS stopped working for me and I'm getting lots of errors
image

@andymass
Copy link
Owner Author

@andymass andymass commented on 327eb6f Apr 18, 2023 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peku-jamf
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is most likely the reason, thanks

@andymass
Copy link
Owner Author

@andymass andymass commented on 327eb6f Apr 18, 2023 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnoRebel
Copy link

@AnoRebel AnoRebel commented on 327eb6f Apr 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get this, mostly on html files and parenthesis, both on Neovim 0.9(stable) and v0.10.0-dev-124+gcff02e993:

E5108: Error executing lua ...vim/lazy/vim-matchup/lua/treesitter-matchup/internal.lua:158: attempt to call field 'get_node_text' (a nil value)
stack traceback:
	...vim/lazy/vim-matchup/lua/treesitter-matchup/internal.lua:158: in function '_node_text'
	...vim/lazy/vim-matchup/lua/treesitter-matchup/internal.lua:177: in function 'get_delim'
	[string "luaeval()"]:1: in main chunk

And some other CursorHold and InsertLeave autocmd errors, like:

Error detected while processing CursorMovedI Autocommands for "*"..function 3[3]..4[71]..matchup#delim#get_current[1]..<SNR>48_get_delim_multi[3]..matchup#ts_engine#get_delim[3]..<SNR>44_forward:
Error detected while processing CursorMoved Autocommands for "*"..function 3[3]..4[71]..matchup#delim#get_current[1]..<SNR>48_get_delim_multi[3]..matchup#ts_engine#get_delim[3]..<SNR>44_forward:
Error detected while processing InsertLeave Autocommands for "*"..function 4[71]..matchup#delim#get_current[1]..<SNR>48_get_delim_multi[3]..matchup#ts_engine#get_delim[3]..<SNR>44_forward:

@andymass
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnoRebel what version of nvim-treesiter are you on?

@AnoRebel
Copy link

@AnoRebel AnoRebel commented on 327eb6f Apr 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andymass

Nvim Treesitter:
- version: 0.9.0
- tag: v0.9.0
- branch: master
- commit: cc360a9

Please sign in to comment.