Make luacheck happy

This commit is contained in:
Stephan Seitz 2020-07-04 18:28:17 +02:00
parent 77f723acd7
commit 2c4a1d36d8
10 changed files with 23 additions and 43 deletions

View file

@ -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

View file

@ -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

View file

@ -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']

View file

@ -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

View file

@ -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'

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,7 +1,6 @@
local api = vim.api
local fn = vim.fn
local luv = vim.loop
local ts = vim.treesitter
local M = {}