summaryrefslogtreecommitdiff
path: root/lua/nvim-treesitter/refactor
diff options
context:
space:
mode:
authorStephan Seitz <stephan.seitz@fau.de>2020-07-04 18:28:17 +0200
committerThomas Vigouroux <39092278+vigoux@users.noreply.github.com>2020-07-05 19:21:06 +0200
commit5642507f6a35d2e25b1588a36d8ddfc525f1464d (patch)
treed95ae24b0220deb9ce8674fea83fa6aba0747240 /lua/nvim-treesitter/refactor
parent1ce1c73249cf5620726f9b00fd58cac1747b1e70 (diff)
Make luacheck happy
Diffstat (limited to 'lua/nvim-treesitter/refactor')
-rw-r--r--lua/nvim-treesitter/refactor/highlight_definitions.lua17
-rw-r--r--lua/nvim-treesitter/refactor/navigation.lua15
-rw-r--r--lua/nvim-treesitter/refactor/smart_rename.lua5
3 files changed, 12 insertions, 25 deletions
diff --git a/lua/nvim-treesitter/refactor/highlight_definitions.lua b/lua/nvim-treesitter/refactor/highlight_definitions.lua
index bdbec158..a581e37d 100644
--- a/lua/nvim-treesitter/refactor/highlight_definitions.lua
+++ b/lua/nvim-treesitter/refactor/highlight_definitions.lua
@@ -1,7 +1,6 @@
-- This module highlights reference usages and the corresponding
-- definition on cursor hold.
-local parsers = require'nvim-treesitter.parsers'
local ts_utils = require'nvim-treesitter.ts_utils'
local locals = require'nvim-treesitter.locals'
local api = vim.api
@@ -17,7 +16,7 @@ function M.highlight_usages(bufnr)
local node_at_point = ts_utils.get_node_at_cursor()
local references = locals.get_references(bufnr)
- if not node_at_point or not vim.tbl_contains(references, node_at_point) then
+ if not node_at_point or not vim.tbl_contains(references, node_at_point) then
return
end
@@ -29,9 +28,9 @@ function M.highlight_usages(bufnr)
if usage_node ~= node_at_point then
api.nvim_buf_add_highlight(
- bufnr,
- usage_namespace,
- 'TSDefinitionUsage',
+ bufnr,
+ usage_namespace,
+ 'TSDefinitionUsage',
start_row,
start_col,
end_col)
@@ -42,9 +41,9 @@ function M.highlight_usages(bufnr)
local start_row, start_col, _, end_col = def_node:range()
api.nvim_buf_add_highlight(
- bufnr,
- usage_namespace,
- 'TSDefinition',
+ bufnr,
+ usage_namespace,
+ 'TSDefinition',
start_row,
start_col,
end_col)
@@ -60,9 +59,11 @@ function M.attach(bufnr)
cmd(string.format('augroup NvimTreesitterUsages_%d', bufnr))
cmd 'au!'
+ -- luacheck: push ignore 631
cmd(string.format([[autocmd CursorHold <buffer=%d> lua require'nvim-treesitter.refactor.highlight_definitions'.highlight_usages(%d)]], bufnr, bufnr))
cmd(string.format([[autocmd CursorMoved <buffer=%d> lua require'nvim-treesitter.refactor.highlight_definitions'.clear_usage_highlights(%d)]], bufnr, bufnr))
cmd(string.format([[autocmd InsertEnter <buffer=%d> lua require'nvim-treesitter.refactor.highlight_definitions'.clear_usage_highlights(%d)]], bufnr, bufnr))
+ -- luacheck: pop
cmd 'augroup END'
end
diff --git a/lua/nvim-treesitter/refactor/navigation.lua b/lua/nvim-treesitter/refactor/navigation.lua
index 5fd25e47..f2eda367 100644
--- a/lua/nvim-treesitter/refactor/navigation.lua
+++ b/lua/nvim-treesitter/refactor/navigation.lua
@@ -7,18 +7,6 @@ local api = vim.api
local M = {}
-local function node_to_qf(node, kind)
- local lnum, col, _ = def.node:start()
-
- return {
- bufnr = bufnr,
- lnum = lnum + 1,
- col = col + 1,
- text = ts_utils.get_node_text(def.node)[1] or '',
- kind = kind
- }
-end
-
function M.goto_definition(bufnr)
local bufnr = bufnr or api.nvim_get_current_buf()
local node_at_point = ts_utils.get_node_at_cursor()
@@ -70,10 +58,9 @@ function M.attach(bufnr)
end
function M.detach(bufnr)
- local buf = bufnr or api.nvim_get_current_buf()
local config = configs.get_module('refactor.navigation')
- for fn_name, mapping in pairs(config.keymaps) do
+ for _, mapping in pairs(config.keymaps) do
api.nvim_buf_del_keymap(bufnr, 'n', mapping)
end
end
diff --git a/lua/nvim-treesitter/refactor/smart_rename.lua b/lua/nvim-treesitter/refactor/smart_rename.lua
index 8aab9538..e5ee37ac 100644
--- a/lua/nvim-treesitter/refactor/smart_rename.lua
+++ b/lua/nvim-treesitter/refactor/smart_rename.lua
@@ -35,7 +35,7 @@ function M.smart_rename(bufnr)
end
for _, node in ipairs(nodes_to_rename) do
- local start_row, start_col, end_row, end_col = node:range()
+ local start_row, start_col, _, end_col = node:range()
local line = api.nvim_buf_get_lines(bufnr, start_row, start_row + 1, false)[1]
if line then
@@ -56,10 +56,9 @@ function M.attach(bufnr)
end
function M.detach(bufnr)
- local buf = bufnr or api.nvim_get_current_buf()
local config = configs.get_module('refactor.smart_rename')
- for fn_name, mapping in pairs(config.keymaps) do
+ for _, mapping in pairs(config.keymaps) do
api.nvim_buf_del_keymap(bufnr, 'n', mapping)
end
end