Skip to content

Commit

Permalink
Merge pull request #33 from tzachar/master
Browse files Browse the repository at this point in the history
adapt to vim.treesitter.query.get_node_text
  • Loading branch information
theHamsta authored May 13, 2022
2 parents 0dc8069 + 3afb083 commit 75f5895
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lua/nvim-treesitter-refactor/navigation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local ts_utils = require "nvim-treesitter.ts_utils"
local utils = require "nvim-treesitter.utils"
local locals = require "nvim-treesitter.locals"
local configs = require "nvim-treesitter.configs"
local ts_query = vim.treesitter.query
local api = vim.api

local M = {}
Expand Down Expand Up @@ -70,7 +71,7 @@ function M.list_definitions(bufnr)
for _, node in ipairs(definitions) do
local lnum, col, _ = node.node:start()
local type = string.upper(node.type:sub(1, 1))
local text = ts_utils.get_node_text(node.node)[1] or ""
local text = ts_query.get_node_text(node.node, bufnr) or ""
table.insert(qf_list, {
bufnr = bufnr,
lnum = lnum + 1,
Expand Down Expand Up @@ -125,7 +126,7 @@ function M.list_definitions_toc()

local lnum, col, _ = def.node:start()
local type = string.upper(def.type:sub(1, 1))
local text = ts_utils.get_node_text(def.node)[1] or ""
local text = ts_query.get_node_text(def.node, bufnr) or ""
table.insert(loc_list, {
bufnr = bufnr,
lnum = lnum + 1,
Expand Down
3 changes: 2 additions & 1 deletion lua/nvim-treesitter-refactor/smart_rename.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local ts_utils = require "nvim-treesitter.ts_utils"
local locals = require "nvim-treesitter.locals"
local configs = require "nvim-treesitter.configs"
local utils = require "nvim-treesitter.utils"
local ts_query = vim.treesitter.query
local api = vim.api

local M = {}
Expand Down Expand Up @@ -42,7 +43,7 @@ function M.smart_rename(bufnr)
return
end

local node_text = ts_utils.get_node_text(node_at_point)[1]
local node_text = ts_query.get_node_text(node_at_point, bufnr)
local input = { prompt = "New name: ", default = node_text or "" }
if not vim.ui.input then
local new_name = vim.fn.input(input.prompt, input.default)
Expand Down

0 comments on commit 75f5895

Please sign in to comment.