Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for various problems relating to treesitter interactions and upstream changes #300

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/navigator/cclshierarchy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion lua/navigator/definition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 4 additions & 14 deletions lua/navigator/reference.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion lua/navigator/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions playground/init.lua
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion thread.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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