mirror of
https://github.com/ray-x/navigator.lua
synced 2024-11-05 12:00:21 +00:00
Fix: nil error processing treesitter query results, nil error when (#300)
viewing references (deprecated method), remaining vim.loop -> vim.uv conversion
This commit is contained in:
parent
29d5f05bf9
commit
d02d4c1c52
@ -4,7 +4,7 @@ local log = util.log
|
||||
local partial = util.partial
|
||||
local lsphelper = require('navigator.lspwrapper')
|
||||
local uv = vim.uv or vim.loop
|
||||
local cwd = vim.loop.cwd()
|
||||
local cwd = uv.cwd()
|
||||
|
||||
local path_sep = require('navigator.util').path_sep()
|
||||
local path_cur = require('navigator.util').path_cur()
|
||||
|
@ -75,7 +75,7 @@ local function def_preview(timeout_ms, method)
|
||||
-- result = {vim.tbl_deep_extend("force", {}, unpack(result))}
|
||||
-- log("def-preview", result)
|
||||
for _, value in pairs(result) do
|
||||
if value ~= nil and not vim.tbl_isempty(value.result) then
|
||||
if value ~= nil and value.result ~= nil and not vim.tbl_isempty(value.result) then
|
||||
table.insert(data, value.result[1])
|
||||
end
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ local lsp = require('navigator.lspwrapper')
|
||||
local trace = require('navigator.util').trace
|
||||
-- local partial = util.partial
|
||||
-- local cwd = vim.loop.cwd()
|
||||
local uv = vim.loop
|
||||
local uv = vim.uv or vim.loop
|
||||
-- local lsphelper = require "navigator.lspwrapper"
|
||||
local locations_to_items = lsphelper.locations_to_items
|
||||
|
||||
@ -28,10 +28,9 @@ local function order_locations(locations)
|
||||
return locations
|
||||
end
|
||||
|
||||
local function warmup_treesitter(options)
|
||||
local api = vim.api
|
||||
local function warmup_treesitter()
|
||||
local parsers = require('nvim-treesitter.parsers')
|
||||
local bufnr = options.bufnr or api.nvim_get_current_buf()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local parser = parsers.get_parser(bufnr)
|
||||
if not parser then
|
||||
log('err: ts not loaded ' .. vim.o.ft)
|
||||
@ -276,17 +275,8 @@ local ref_req = function()
|
||||
_NgConfigValues.closer()
|
||||
end
|
||||
|
||||
local warmup_ts
|
||||
if _NgConfigValues.treesitter_analysis then
|
||||
warmup_ts = uv.new_async(function()
|
||||
warmup_treesitter(cfg)
|
||||
if warmup_ts:is_active() then
|
||||
warmup_ts:close()
|
||||
end
|
||||
end)
|
||||
vim.defer_fn(function()
|
||||
warmup_ts:send()
|
||||
end, 5)
|
||||
warmup_treesitter()
|
||||
end
|
||||
-- lsp.call_async("textDocument/references", ref_params, ref_hdlr) -- return asyncresult, canceller
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
|
@ -228,7 +228,8 @@ local function get_definitions(bufnr)
|
||||
local local_nodes = ts_locals.get_locals(bufnr)
|
||||
-- Make sure the nodes are unique.
|
||||
local nodes_set = {}
|
||||
for _, loc in ipairs(local_nodes) do
|
||||
for _, nodes in ipairs(local_nodes) do
|
||||
local loc = nodes["local"]
|
||||
trace(loc)
|
||||
if loc.definition then
|
||||
ts_locals.recurse_local_nodes(loc.definition, function(_, node, _, match)
|
||||
|
@ -1,5 +1,6 @@
|
||||
vim.cmd([[set runtimepath=$VIMRUNTIME]])
|
||||
local os_name = vim.loop.os_uname().sysname
|
||||
local uv = vim.uv or vim.loop
|
||||
local os_name = uv.os_uname().sysname
|
||||
|
||||
local is_windows = os_name == 'Windows' or os_name == 'Windows_NT'
|
||||
|
||||
@ -26,7 +27,7 @@ local plugin_folder = function()
|
||||
end
|
||||
|
||||
local lazypath = package_root .. sep .. 'lazy.nvim'
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
if not uv.fs_stat(lazypath) then
|
||||
vim.fn.system({
|
||||
'git',
|
||||
'clone',
|
||||
|
@ -17,4 +17,5 @@ local func = function(p, uv)
|
||||
assert(elapsed >= 1000, "elapsed should be at least delay ")
|
||||
end
|
||||
|
||||
func(print, vim.loop)
|
||||
local uv = vim.uv or vim.loop
|
||||
func(print, uv)
|
||||
|
Loading…
Reference in New Issue
Block a user