aboutsummaryrefslogtreecommitdiffstats
path: root/lua
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
parentAdd Travis CI with luacheck (diff)
downloadnvim-treesitter-5642507f6a35d2e25b1588a36d8ddfc525f1464d.tar
nvim-treesitter-5642507f6a35d2e25b1588a36d8ddfc525f1464d.tar.gz
nvim-treesitter-5642507f6a35d2e25b1588a36d8ddfc525f1464d.tar.bz2
nvim-treesitter-5642507f6a35d2e25b1588a36d8ddfc525f1464d.tar.lz
nvim-treesitter-5642507f6a35d2e25b1588a36d8ddfc525f1464d.tar.xz
nvim-treesitter-5642507f6a35d2e25b1588a36d8ddfc525f1464d.tar.zst
nvim-treesitter-5642507f6a35d2e25b1588a36d8ddfc525f1464d.zip
Make luacheck happy
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-treesitter/configs.lua6
-rw-r--r--lua/nvim-treesitter/fold.lua3
-rw-r--r--lua/nvim-treesitter/health.lua3
-rw-r--r--lua/nvim-treesitter/incremental_selection.lua2
-rw-r--r--lua/nvim-treesitter/locals.lua1
-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
-rw-r--r--lua/nvim-treesitter/ts_utils.lua13
-rw-r--r--lua/nvim-treesitter/utils.lua1
10 files changed, 23 insertions, 43 deletions
diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua
index c31ca4f29..43dc944bf 100644
--- a/lua/nvim-treesitter/configs.lua
+++ b/lua/nvim-treesitter/configs.lua
@@ -130,7 +130,7 @@ local function disable_mod_conf_autocmd(mod, lang)
if not config_mod or not M.is_enabled(mod, lang) then return end
- local cmd = string.format("lua require'nvim-treesitter.%s'.attach()", mod)
+ --local cmd = string.format("lua require'nvim-treesitter.%s'.attach()", mod)
-- TODO(kyazdani): detach the correct autocmd... doesn't work when using %s, cmd
for _, ft in pairs(parsers.lang_to_ft(lang)) do
api.nvim_command(string.format("autocmd! NvimTreesitter FileType %s", ft))
@@ -260,7 +260,7 @@ function M.setup_module(mod, data, mod_name)
end
end
elseif type(data) == 'table' and type(mod) == 'table' then
- for key, value in pairs(data) do
+ for key, value in pairs(data) do
M.setup_module(mod[key], value, key)
end
end
@@ -289,7 +289,7 @@ end
-- A module should contain an 'is_supported' function.
-- @param mod the module table
function M.is_module(mod)
- return type(mod) == 'table' and type(mod.is_supported) == 'function'
+ return type(mod) == 'table' and type(mod.is_supported) == 'function'
end
return M
diff --git a/lua/nvim-treesitter/fold.lua b/lua/nvim-treesitter/fold.lua
index 6a39461a7..401f52606 100644
--- a/lua/nvim-treesitter/fold.lua
+++ b/lua/nvim-treesitter/fold.lua
@@ -1,4 +1,3 @@
-local api = vim.api
local parsers = require'nvim-treesitter.parsers'
local M = {}
@@ -21,7 +20,7 @@ function M.get_fold_indic(lnum)
local parser = parsers.get_parser()
- local multiline_here, level = smallest_multiline_containing(parser:parse():root(), 0)
+ local _, level = smallest_multiline_containing(parser:parse():root(), 0)
return tostring(level)
end
diff --git a/lua/nvim-treesitter/health.lua b/lua/nvim-treesitter/health.lua
index e73ce7fb5..d3083e77b 100644
--- a/lua/nvim-treesitter/health.lua
+++ b/lua/nvim-treesitter/health.lua
@@ -2,13 +2,10 @@ local api = vim.api
local fn = vim.fn
local queries = require'nvim-treesitter.query'
-local locals = require'nvim-treesitter.locals'
-local highlight = require'nvim-treesitter.highlight'
local parsers = require'nvim-treesitter.parsers'
local health_start = vim.fn["health#report_start"]
local health_ok = vim.fn['health#report_ok']
-local health_info = vim.fn['health#report_info']
local health_warn = vim.fn['health#report_warn']
local health_error = vim.fn['health#report_error']
diff --git a/lua/nvim-treesitter/incremental_selection.lua b/lua/nvim-treesitter/incremental_selection.lua
index 6a9999303..3b76b25f2 100644
--- a/lua/nvim-treesitter/incremental_selection.lua
+++ b/lua/nvim-treesitter/incremental_selection.lua
@@ -58,7 +58,7 @@ local function select_incremental(get_parent)
return
end
- node = get_parent(nodes[#nodes])
+ local node = get_parent(nodes[#nodes])
if not node then return end
if node ~= nodes[#nodes] then
diff --git a/lua/nvim-treesitter/locals.lua b/lua/nvim-treesitter/locals.lua
index 8c7d400eb..d30953348 100644
--- a/lua/nvim-treesitter/locals.lua
+++ b/lua/nvim-treesitter/locals.lua
@@ -2,7 +2,6 @@
-- Locals are a generalization of definition and scopes
-- its the way nvim-treesitter uses to "understand" the code
local api = vim.api
-local ts = vim.treesitter
local queries = require'nvim-treesitter.query'
local parsers = require'nvim-treesitter.parsers'
diff --git a/lua/nvim-treesitter/refactor/highlight_definitions.lua b/lua/nvim-treesitter/refactor/highlight_definitions.lua
index bdbec1588..a581e37d5 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 5fd25e474..f2eda367c 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 8aab9538d..e5ee37ac1 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
diff --git a/lua/nvim-treesitter/ts_utils.lua b/lua/nvim-treesitter/ts_utils.lua
index 06f92c885..7d5e97cdd 100644
--- a/lua/nvim-treesitter/ts_utils.lua
+++ b/lua/nvim-treesitter/ts_utils.lua
@@ -219,10 +219,9 @@ end
-- @param bufnr buffer
-- @returns the definition node and the definition nodes scope node
function M.find_definition(node, bufnr)
- local bufnr = bufnr or api.nvim_get_current_buf()
+ local bufnr = bufnr or api.nvim_get_current_buf()
local node_text = M.get_node_text(node)[1]
local current_scope = M.containing_scope(node)
- local _, _, node_start = node:start()
local matching_def_nodes = {}
-- If a scope wasn't found then use the root node
@@ -234,7 +233,7 @@ function M.find_definition(node, bufnr)
for _, def in ipairs(locals.get_definitions(bufnr)) do
for _, def_node in ipairs(M.get_local_nodes(def)) do
if M.get_node_text(def_node)[1] == node_text then
- table.insert(matching_def_nodes, def_node)
+ table.insert(matching_def_nodes, def_node)
end
end
end
@@ -258,7 +257,7 @@ end
function M.get_local_nodes(local_def)
local result = {}
- M.recurse_local_nodes(local_def, function(_, node)
+ M.recurse_local_nodes(local_def, function(_, node)
table.insert(result, node)
end)
@@ -281,9 +280,9 @@ function M.recurse_local_nodes(local_def, accumulator, full_match, last_match)
else
for match_key, def in pairs(local_def) do
M.recurse_local_nodes(
- def,
- accumulator,
- full_match and (full_match..'.'..match_key) or match_key,
+ def,
+ accumulator,
+ full_match and (full_match..'.'..match_key) or match_key,
match_key)
end
end
diff --git a/lua/nvim-treesitter/utils.lua b/lua/nvim-treesitter/utils.lua
index f5c65a0a7..c87cee2d8 100644
--- a/lua/nvim-treesitter/utils.lua
+++ b/lua/nvim-treesitter/utils.lua
@@ -1,7 +1,6 @@
local api = vim.api
local fn = vim.fn
local luv = vim.loop
-local ts = vim.treesitter
local M = {}