Merge branch 'master' of github.com:ray-x/navigator.lua

master
ray-x 3 months ago
commit 23489699f9

@ -4,7 +4,7 @@ local log = util.log
local partial = util.partial local partial = util.partial
local lsphelper = require('navigator.lspwrapper') local lsphelper = require('navigator.lspwrapper')
local uv = vim.uv or vim.loop 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_sep = require('navigator.util').path_sep()
local path_cur = require('navigator.util').path_cur() local path_cur = require('navigator.util').path_cur()

@ -76,7 +76,7 @@ local function def_preview(timeout_ms, method)
-- result = {vim.tbl_deep_extend("force", {}, unpack(result))} -- result = {vim.tbl_deep_extend("force", {}, unpack(result))}
-- log("def-preview", result) -- log("def-preview", result)
for _, value in pairs(result) do 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]) table.insert(data, value.result[1])
end end
end end

@ -6,7 +6,7 @@ local lsp = require('navigator.lspwrapper')
local trace = require('navigator.util').trace local trace = require('navigator.util').trace
-- local partial = util.partial -- local partial = util.partial
-- local cwd = vim.loop.cwd() -- local cwd = vim.loop.cwd()
local uv = vim.loop local uv = vim.uv or vim.loop
-- local lsphelper = require "navigator.lspwrapper" -- local lsphelper = require "navigator.lspwrapper"
local locations_to_items = lsphelper.locations_to_items local locations_to_items = lsphelper.locations_to_items
@ -28,10 +28,9 @@ local function order_locations(locations)
return locations return locations
end end
local function warmup_treesitter(options) local function warmup_treesitter()
local api = vim.api
local parsers = require('nvim-treesitter.parsers') 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) local parser = parsers.get_parser(bufnr)
if not parser then if not parser then
log('err: ts not loaded ' .. vim.o.ft) log('err: ts not loaded ' .. vim.o.ft)
@ -276,17 +275,8 @@ local ref_req = function()
_NgConfigValues.closer() _NgConfigValues.closer()
end end
local warmup_ts
if _NgConfigValues.treesitter_analysis then if _NgConfigValues.treesitter_analysis then
warmup_ts = uv.new_async(function() warmup_treesitter()
warmup_treesitter(cfg)
if warmup_ts:is_active() then
warmup_ts:close()
end
end)
vim.defer_fn(function()
warmup_ts:send()
end, 5)
end end
-- lsp.call_async("textDocument/references", ref_params, ref_hdlr) -- return asyncresult, canceller -- lsp.call_async("textDocument/references", ref_params, ref_hdlr) -- return asyncresult, canceller
local bufnr = vim.api.nvim_get_current_buf() 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) local local_nodes = ts_locals.get_locals(bufnr)
-- Make sure the nodes are unique. -- Make sure the nodes are unique.
local nodes_set = {} local nodes_set = {}
for _, loc in ipairs(local_nodes) do for _, nodes in ipairs(local_nodes) do
local loc = nodes["local"]
trace(loc) trace(loc)
if loc.definition then if loc.definition then
ts_locals.recurse_local_nodes(loc.definition, function(_, node, _, match) ts_locals.recurse_local_nodes(loc.definition, function(_, node, _, match)

@ -1,5 +1,6 @@
vim.cmd([[set runtimepath=$VIMRUNTIME]]) 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' local is_windows = os_name == 'Windows' or os_name == 'Windows_NT'
@ -26,7 +27,7 @@ local plugin_folder = function()
end end
local lazypath = package_root .. sep .. 'lazy.nvim' 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({ vim.fn.system({
'git', 'git',
'clone', 'clone',

@ -17,4 +17,5 @@ local func = function(p, uv)
assert(elapsed >= 1000, "elapsed should be at least delay ") assert(elapsed >= 1000, "elapsed should be at least delay ")
end end
func(print, vim.loop) local uv = vim.uv or vim.loop
func(print, uv)

Loading…
Cancel
Save