fix treesitter node nil in logs

pull/268/head
ray-x 1 year ago
parent 99e126fe4e
commit 86ed353f62

@ -20,7 +20,8 @@ local function entry_to_item(entry)
if type == 'combine' then
-- '/^type ServerResponse struct {$/;"\ts\tpackage:client'
item.inline, item.type, item.containerName, item.ref = string.match(item.remain, '/^(.*)$/;"\t(%a)\t(.+)')
item.inline, item.type, item.containerName, item.ref =
string.match(item.remain, '/^(.*)$/;"\t(%a)\t(.+)')
else
-- '"\tm\tstruct:store.Customer\ttyperef:typename:string'
item.type, item.containerName, item.ref = string.match(item.remain, '"\t(%a)\t(.+)')
@ -56,7 +57,8 @@ local function ctags_gen()
local output = _NgConfigValues.ctags.tagfile
-- rm file first
util.rm_file(output)
local options = '-R --exclude=.git --exclude=node_modules --exclude=test --exclude=vendor --excmd=number '
local options =
'-R --exclude=.git --exclude=node_modules --exclude=test --exclude=vendor --excmd=number '
if _NgConfigValues.ctags then
cmd = _NgConfigValues.ctags.cmd
options = _NgConfigValues.ctags.options or options
@ -148,10 +150,14 @@ local function ctags(...)
end
local function testitem()
local e = [[ServerResponse internal/clients/server.go /^type ServerResponse struct {$/;" s package:client]]
local ecombine = [[ServerResponse internal/clients/server.go 5;/^type ServerResponse struct {$/;" s package:client]]
local enumber = [[CustomerID internal/store/models.go 17;" m struct:store.Customer typeref:typename:string]]
local enumber2 = [[CustomerDescription internal/controllers/customer.go 27;" c package:controllers]]
local e =
[[ServerResponse internal/clients/server.go /^type ServerResponse struct {$/;" s package:client]]
local ecombine =
[[ServerResponse internal/clients/server.go 5;/^type ServerResponse struct {$/;" s package:client]]
local enumber =
[[CustomerID internal/store/models.go 17;" m struct:store.Customer typeref:typename:string]]
local enumber2 =
[[CustomerDescription internal/controllers/customer.go 27;" c package:controllers]]
local enumber3 = [[add_servers lua/navigator/lspclient/clients.lua 680;" f]]
local i = entry_to_item(ecombine)
print(vim.inspect(i))

@ -254,10 +254,12 @@ local function lsp_startup(ft, retry, user_lsp_opts)
local default_config = {}
if lspconfig[lspclient] == nil then
vim.notify(
'lspclient' .. vim.inspect(lspclient) .. 'no longer support by lspconfig, please submit an issue',
vim.log.levels.WARN
)
vim.schedule(function()
vim.notify(
'lspclient' .. vim.inspect(lspclient) .. 'no longer support by lspconfig, please submit an issue',
vim.log.levels.WARN
)
end)
log('lspclient', lspclient, 'not supported')
goto continue
end
@ -265,7 +267,9 @@ local function lsp_startup(ft, retry, user_lsp_opts)
if lspconfig[lspclient].document_config and lspconfig[lspclient].document_config.default_config then
default_config = lspconfig[lspclient].document_config.default_config
else
vim.notify('missing document config for client: ' .. vim.inspect(lspclient), vim.log.levels.WARN)
vim.schedule(function()
vim.notify('missing document config for client: ' .. vim.inspect(lspclient), vim.log.levels.WARN)
end)
goto continue
end

@ -146,6 +146,9 @@ M.defaults = function()
on_init = function(client)
require('navigator.lspclient.python').on_init(client)
end,
on_new_config = function(new_config, new_root_dir)
-- require('navigator.lspclient.python').pyenv_path( new_root_dir)
end,
cmd = { 'pyright-langserver', '--stdio' },
filetypes = { 'python' },
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },

@ -146,8 +146,7 @@ local function fetch_lsp_references(bufnr, lsp_params, callback)
)
end
-- a function from smjonas/inc-rename.nvim
-- https://github.com/smjonas/inc-rename.nvim/blob/main/lua/inc_rename/init.lua
-- inspired by smjonas/inc-rename.nvim
local function teardown(switch_buffer)
state.should_fetch_references = true
state.cached_lines = nil
@ -171,8 +170,7 @@ local function restore_buffer()
end
-- Called when the user is still typing the command or the command arguments
-- a function from smjonas/inc-rename.nvim
-- https://github.com/smjonas/inc-rename.nvim/blob/main/lua/inc_rename/init.lua
-- inspired by smjonas/inc-rename.nvim
local function incremental_rename_preview(opts, preview_ns, preview_buf)
log(opts, preview_ns, preview_buf)
local new_name = opts.args
@ -232,8 +230,7 @@ local function incremental_rename_preview(opts, preview_ns, preview_buf)
state.preview_ns = preview_ns
end
-- a function from smjonas/inc-rename.nvim
-- https://github.com/smjonas/inc-rename.nvim/blob/main/lua/inc_rename/init.lua
-- function rewrite from smjonas/inc-rename.nvim
local function perform_lsp_rename(new_name, params)
params = params or make_position_params()
params.newName = new_name
@ -245,7 +242,7 @@ local function perform_lsp_rename(new_name, params)
end
if not result or vim.tbl_isempty(result) then
set_error('[nav-rename] Nothing renamed', vim.log.levels.WARN)
set_error('[nav-rename] Nothing renamed', vim.log.levels.INFO)
return
end
@ -430,7 +427,7 @@ function M.rename_inplace(new_name, options)
if state.confirm then
-- lets put back
log('execute rename')
inc_rename_execute({ args = state.new_name or vim.fn.expand('<cword>'), params = params })
inc_rename_execute({ args = state.new_name or vim.fn.expand('<cword>'), params = {} })
end
end
local try_use_client

@ -111,7 +111,9 @@ function M.find_definition(range, bufnr)
local r, c = definition:range()
return { start = { line = r, character = c } }
else
trace('error: def not found in ', bufnr, definition:range(), definition:type(), definition:parent():type())
if definition then
trace('error: def not found in ', bufnr, definition:range(), definition:type(), definition:parent():type())
end
end
end

Loading…
Cancel
Save