From 6c9ce98d03b49c99cd7b2ced63f1e595c4cb0145 Mon Sep 17 00:00:00 2001 From: ray-x Date: Fri, 11 Jun 2021 21:33:22 +1000 Subject: [PATCH] Update kemap document --- README.md | 9 ++++++++- lua/navigator/lspwrapper.lua | 10 +++++----- lua/navigator/render.lua | 14 ++++++-------- lua/navigator/treesitter.lua | 10 +++++----- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 8eba013..62555c9 100644 --- a/README.md +++ b/README.md @@ -259,7 +259,14 @@ require.'navigator'.setup({ | n | ]r | next treesitter reference/usage| | n | [r | previous treesitter reference/usage| | n | \k | toggle reference highlight | - +| i/n | \ | previous item in list| +| i/n | \ | next item in list| +| i/n | \ | previous item in list| +| i/n | \ | next item in list| +| i/n | \ | Open preview/Apply action| +| n | \ | Open preview/Apply action| +| i/n | \ | Previous in list| +| i/n | \ | next page in list| ### Colors: diff --git a/lua/navigator/lspwrapper.lua b/lua/navigator/lspwrapper.lua index 83f4d0b..fbfd33c 100644 --- a/lua/navigator/lspwrapper.lua +++ b/lua/navigator/lspwrapper.lua @@ -173,7 +173,7 @@ local function ts_functions(uri) end local unload = false if not api.nvim_buf_is_loaded(bufnr) then - log("! load buf !", uri, bufnr) + trace("! load buf !", uri, bufnr) vim.fn.bufload(bufnr) unload = true end @@ -181,13 +181,13 @@ local function ts_functions(uri) local funcs = ts_func(bufnr) if unload then local cmd = string.format("bd %d", bufnr) - log(cmd) + trace(cmd) -- vim.cmd(cmd) -- todo: not sure if it is needed end ts_nodes[uri] = funcs ts_nodes_time[uri] = os.time() trace(funcs, ts_nodes) - log(string.format("elapsed time: %.4f\n", os.clock() - x)) + trace(string.format("elapsed time: %.4f\n", os.clock() - x)) -- how long it tooks return funcs end @@ -213,7 +213,7 @@ local function ts_defination(uri, range) log(cmd) -- vim.cmd(cmd) -- todo: not sure if it is needed end - log(string.format(" ts def elapsed time: %.4f\n", os.clock() - x), def_range) + trace(string.format(" ts def elapsed time: %.4f\n", os.clock() - x), def_range) -- how long it takes return def_range end @@ -276,7 +276,7 @@ function M.locations_to_items(locations) end end end - log(uri_def[item.uri], item.range) + trace(uri_def[item.uri], item.range) -- set to log if need to get all in rnge local def = uri_def[item.uri] if def and def.start and item.range then if def.start.line == item.range.start.line then diff --git a/lua/navigator/render.lua b/lua/navigator/render.lua index 329e401..c445c82 100644 --- a/lua/navigator/render.lua +++ b/lua/navigator/render.lua @@ -15,7 +15,7 @@ local function get_pads(win_width, text, postfix) local trim = false local margin = win_width - #text - #postfix if margin < 0 then - log('line too long', win_width, #text, #postfix) + trace('line too long', win_width, #text, #postfix) if #postfix > 1 then trim = true end @@ -27,15 +27,13 @@ local function get_pads(win_width, text, postfix) local space local i = math.floor((sz + 10) / 10) i = i * 10 - #text - log(i, #text, #postfix, postfix, text, win_width) + trace(i, #text, #postfix, postfix, text, win_width) if i + #text + #postfix < win_width then local rem = win_width - i - #text - #postfix rem = math.floor(rem / 10) if rem > 0 then i = i + rem * 10 - -- rem = (i + #text) % 10 - -- i = i - rem - log(i) + -- log(i) end end @@ -138,7 +136,7 @@ function M.prepare_for_render(items, opts) ts_report = ts_report .. '🦕 ' end local header_len = #ts_report + 4 -- magic number 2 - log(ts_report, header_len) + trace(ts_report, header_len) item.text = item.text:gsub('%s*[%[%(%{]*%s*$', '') if item.call_by ~= nil and #item.call_by > 0 then @@ -174,11 +172,11 @@ function M.prepare_for_render(items, opts) end if #space + #item.text + #ts_report >= win_width then if #item.text + #ts_report > win_width then - log("exceeding", #item.text, #ts_report, win_width) + trace("exceeding", #item.text, #ts_report, win_width) space = ' ' else local remain = win_width - #item.text - #ts_report - log("remain", remain) + trace("remain", remain) space = string.rep(' ', remain) end end diff --git a/lua/navigator/treesitter.lua b/lua/navigator/treesitter.lua index 5744f69..dea4841 100644 --- a/lua/navigator/treesitter.lua +++ b/lua/navigator/treesitter.lua @@ -79,11 +79,11 @@ function M.find_definition(range, bufnr) local definition = locals.find_definition(node_at_point, bufnr) if definition ~= node_at_point then - log("def found:", definition:range(), definition:type()) + trace("err: def found:", definition:range(), definition:type()) local r, c = definition:range() return {start = {line = r, character = c}} else - log("def not found in ", bufnr) + trace("err: def not found in ", bufnr) end end @@ -337,8 +337,8 @@ local function get_all_nodes(bufnr, filter, summary) end if item.node_scope then - log(item.type, tsdata:type(), item.node_text, item.kind, item.node_text, "range", - item.node_scope.start.line, item.node_scope['end'].line) + trace(item.type, tsdata:type(), item.node_text, item.kind, item.node_text, "range", + item.node_scope.start.line, item.node_scope['end'].line) -- set to log if need to trace result end goto continue end @@ -392,7 +392,7 @@ function M.buf_func(bufnr) ["type"] = true }, true) if #all_nodes < 1 then - log("no node found for ", bufnr) + trace("no node found for ", bufnr) -- set to log return end