diff --git a/index.html b/index.html new file mode 100644 index 0000000..c4f016a --- /dev/null +++ b/index.html @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/lua/navigator/cclshierarchy.lua b/lua/navigator/cclshierarchy.lua index 5a84de3..10f3d44 100644 --- a/lua/navigator/cclshierarchy.lua +++ b/lua/navigator/cclshierarchy.lua @@ -16,7 +16,7 @@ local function call_hierarchy_handler(direction, err, result, ctx, cfg, error_me assert(#vim.lsp.buf_get_clients() > 0, "Must have a client running to use lsp_tags") if err ~= nil then log("hierarchy error", ctx, "dir", direction, "result", result, "err", err) - print("ERROR: " .. error_message) + vim.notify("ERROR: " .. error_message, vim.lsp.log_levels.WARN) return end -- local funcs = vim.lsp.util.locations_to_items(result) diff --git a/lua/navigator/definition.lua b/lua/navigator/definition.lua index 01f36bc..519955a 100644 --- a/lua/navigator/definition.lua +++ b/lua/navigator/definition.lua @@ -8,7 +8,7 @@ local TextView = require("guihua.textview") local definition_hdlr = util.mk_handler(function(err, locations, ctx, _) -- log(locations) if err ~= nil then - print(err, ctx) + vim.notify(err, ctx, vim.lsp.log_levels.WARN) return end if type(locations) == "number" then @@ -16,7 +16,7 @@ local definition_hdlr = util.mk_handler(function(err, locations, ctx, _) log("unable to handle request") end if locations == nil or vim.tbl_isempty(locations) then - print "Definition not found" + vim.notify "Definition not found" return end if vim.tbl_islist(locations) then @@ -43,7 +43,7 @@ local function def_preview(timeout_ms) local result = vim.lsp.buf_request_sync(0, method, params, timeout_ms or 1000) if result == nil or vim.tbl_isempty(result) then - print("No result found: " .. method) + vim.notify("No result found: " .. method, vim.lsp.log_levels.WARN) return nil end @@ -58,7 +58,7 @@ local function def_preview(timeout_ms) end if vim.tbl_isempty(data) then - print("No result found: " .. method) + vim.notify("No result found: " .. method, vim.lsp.log_levels.WARN) return nil end diff --git a/lua/navigator/diagnostics.lua b/lua/navigator/diagnostics.lua index 396264a..e03adc4 100644 --- a/lua/navigator/diagnostics.lua +++ b/lua/navigator/diagnostics.lua @@ -427,7 +427,7 @@ end -- TODO: update the marker if _NgConfigValues.diagnostic_scrollbar_sign then - print("config deprecated, set lsp.diagnostic_scrollbar_sign instead") + vim.notify("config deprecated, set lsp.diagnostic_scrollbar_sign instead", vim.lsp.log_levels.WARN) end if _NgConfigValues.lsp.diagnostic_scrollbar_sign then diff --git a/lua/navigator/dochighlight.lua b/lua/navigator/dochighlight.lua index 67d886a..2e43f68 100644 --- a/lua/navigator/dochighlight.lua +++ b/lua/navigator/dochighlight.lua @@ -233,7 +233,7 @@ local function documentHighlight() vim.lsp.handlers['textDocument/documentHighlight'] = mk_handler(function(err, result, ctx) local bufnr = ctx.bufnr or api.nvim_get_current_buf() if err then - print(err) + vim.notify(err, vim.lsp.log_levels.ERROR) return end if not result or not result[1] or not result[1]['range'] then diff --git a/lua/navigator/foldlsp.lua b/lua/navigator/foldlsp.lua index 544204c..c85d612 100644 --- a/lua/navigator/foldlsp.lua +++ b/lua/navigator/foldlsp.lua @@ -93,7 +93,7 @@ M.fold_handler = mk_handler(function(err, result, ctx, config) -- params: err, method, result, client_id, bufnr -- XXX: handle err? if err or result == nil or #result == 0 then - print(err, ctx.method, ctx.client_id) + vim.notify(err, ctx.method, ctx.client_id, vim.lsp.log_levels.WARN) return end M.debug_folds() diff --git a/lua/navigator/foldts.lua b/lua/navigator/foldts.lua index 4c89d8f..f1d0e9d 100644 --- a/lua/navigator/foldts.lua +++ b/lua/navigator/foldts.lua @@ -32,7 +32,7 @@ vim.opt.viewoptions:remove("options") function M.setup_fold() if not parsers.has_parser() then - print("treesitter folding not enabled for current file") + vim.notify("treesitter folding not enabled for current file", vim.lsp.log_levels.WARN) return end log("setup treesitter folding") diff --git a/lua/navigator/hierarchy.lua b/lua/navigator/hierarchy.lua index a0b8864..d71532a 100644 --- a/lua/navigator/hierarchy.lua +++ b/lua/navigator/hierarchy.lua @@ -11,14 +11,14 @@ local cwd = vim.loop.cwd() local M = {} local function call_hierarchy_handler(direction, err, result, ctx, cfg, error_message) if not result then - print("No call hierarchy items found") + vim.notify ("No call hierarchy items found", vim.lsp.log_levels.WARN) return end trace('call_hierarchy', result) assert(#vim.lsp.buf_get_clients() > 0, "Must have a client running to use lsp_tags") if err ~= nil then log("dir", direction, "result", result, "err", err, ctx) - print("ERROR: " .. error_message) + vim.notify("ERROR: " .. error_message, vim.lsp.log_levels.WARN) return end diff --git a/lua/navigator/implementation.lua b/lua/navigator/implementation.lua index bde2283..7fbb8fb 100644 --- a/lua/navigator/implementation.lua +++ b/lua/navigator/implementation.lua @@ -10,7 +10,7 @@ local log = util.log -- dataformat should be same as reference local function location_handler(err, locations, ctx, cfg, msg) if err ~= nil then - print("ERROR: " .. tostring(err) .. " " .. msg) + vim.notify("ERROR: " .. tostring(err) .. " " .. msg, vim.lsp.log_levels.WARN) return end return locations_to_items(locations) diff --git a/lua/navigator/lspclient/clients.lua b/lua/navigator/lspclient/clients.lua index 2fd51a9..1f00ba6 100644 --- a/lua/navigator/lspclient/clients.lua +++ b/lua/navigator/lspclient/clients.lua @@ -18,7 +18,7 @@ local has_lsp, lspconfig = pcall(require, 'lspconfig') if not has_lsp then return { setup = function() - print('loading lsp config failed LSP may not working correctly') + vim.notify('loading lsp config failed LSP may not working correctly', vim.lsp.log_levels.WARN) end, } end @@ -457,14 +457,14 @@ local function lsp_startup(ft, retry, user_lsp_opts) local default_config = {} log(lspclient) if lspconfig[lspclient] == nil then - print('lspclient', lspclient, 'no longer support by lspconfig, please submit an issue') + vim.notify('lspclient', lspclient, 'no longer support by lspconfig, please submit an issue', vim.lsp.log_levels.WARN) goto continue end if lspconfig[lspclient].document_config and lspconfig[lspclient].document_config.default_config then default_config = lspconfig[lspclient].document_config.default_config else - print('missing document config for client: ', lspclient) + vim.notify('missing document config for client: ', lspclient, vim.lsp.log_levels.WARN) goto continue end @@ -525,7 +525,7 @@ local function lsp_startup(ft, retry, user_lsp_opts) end cfg.on_init = function(client) if client and client.config and client.config.settings then - client.notify('workspace/didChangeConfiguration', { settings = client.config.settings }) + client.notify('workspace/didChangeConfiguration', { settings = client.config.settings }, vim.lsp.log_levels.WARN) end end end diff --git a/lua/navigator/lspclient/mapping.lua b/lua/navigator/lspclient/mapping.lua index 087a38b..6476483 100644 --- a/lua/navigator/lspclient/mapping.lua +++ b/lua/navigator/lspclient/mapping.lua @@ -45,7 +45,7 @@ local key_maps = { { key = 'wr', func = 'remove_workspace_folder()' }, { key = 'ff', func = 'formatting()', mode = 'n' }, { key = 'ff', func = 'range_formatting()', mode = 'v' }, - { key = 'wl', func = 'print(vim.inspect(vim.lsp.buf.list_workspace_folders()))' }, + { key = 'wl', func = 'vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders()))' }, { key = 'la', mode = 'n', func = "require('navigator.codelens').run_action()" }, } @@ -221,12 +221,12 @@ M.toggle_lspformat = function(on) end if _NgConfigValues.lsp.format_on_save then if on == nil then - print('format on save true') + vim.notify('format on save true', vim.lsp.log_levels.INFO) end vim.cmd([[set eventignore-=BufWritePre]]) else if on == nil then - print('format on save false') + vim.notify('format on save false', vim.lsp.log_levels.INFO) end vim.cmd([[set eventignore+=BufWritePre]]) end diff --git a/lua/navigator/lspwrapper.lua b/lua/navigator/lspwrapper.lua index 3dd78a1..dd16e6c 100644 --- a/lua/navigator/lspwrapper.lua +++ b/lua/navigator/lspwrapper.lua @@ -314,7 +314,7 @@ end function M.locations_to_items(locations, max_items) max_items = max_items or 100000 -- if not locations or vim.tbl_isempty(locations) then - print('list not avalible') + vim.notify('list not avalible', vim.lsp.log_levels.WARN) return end local width = 4 @@ -420,7 +420,7 @@ end function M.symbol_to_items(locations) if not locations or vim.tbl_isempty(locations) then - print('list not avalible') + vim.notify('list not avalible', vim.lsp.log_levels.WARN) return end diff --git a/lua/navigator/reference.lua b/lua/navigator/reference.lua index 9f17d08..18cf215 100644 --- a/lua/navigator/reference.lua +++ b/lua/navigator/reference.lua @@ -20,18 +20,18 @@ local ref_view = function(err, locations, ctx, cfg) -- log("num", num) -- log("bfnr", bufnr) if err ~= nil then - print('lsp ref callback error', err, ctx, vim.inspect(locations)) + vim.notify('lsp ref callback error', err, ctx, vim.inspect(locations), vim.lsp.log_levels.WARN) log('ref callback error, lsp may not ready', err, ctx, vim.inspect(locations)) return end if type(locations) ~= 'table' then log(locations) log('ctx', ctx) - print('incorrect setup', locations) + vim.notify('incorrect setup', locations, vim.lsp.log_levels.WARN) return end if locations == nil or vim.tbl_isempty(locations) then - print('References not found') + vim.notify('References not found', vim.lsp.log_levels.WARN) return end @@ -58,7 +58,7 @@ local ref_view = function(err, locations, ctx, cfg) local listview = gui.new_list_view(opts) if listview == nil then - print('failed to create preview windows') + vim.notify('failed to create preview windows', vim.lsp.log_levels.WARN) return end -- trace("update items", listview.ctrl.class) diff --git a/lua/navigator/render.lua b/lua/navigator/render.lua index c47ad6f..de66bc3 100644 --- a/lua/navigator/render.lua +++ b/lua/navigator/render.lua @@ -52,7 +52,7 @@ end function M.prepare_for_render(items, opts) opts = opts or {} if items == nil or #items < 1 then - print("no item found or empty fields") + vim.notify("no item found or empty fields", vim.lsp.log_levels.INFO) return end local item = clone(items[1]) diff --git a/lua/navigator/signature.lua b/lua/navigator/signature.lua index 1a2c138..3a6e1a3 100644 --- a/lua/navigator/signature.lua +++ b/lua/navigator/signature.lua @@ -52,7 +52,7 @@ local signature_handler = mk_handler(function(err, result, ctx, config) log("config nil") end if err then - print("signature help error: ", err, vim.inspect(result), ctx, config) + vim.notify("signature help error: ", err, vim.inspect(result), ctx, config, vim.lsp.log_levels.WARN) end config = config or {} if config.border == nil then diff --git a/lua/navigator/symbols.lua b/lua/navigator/symbols.lua index 0cb6b90..4f52e4b 100644 --- a/lua/navigator/symbols.lua +++ b/lua/navigator/symbols.lua @@ -30,7 +30,7 @@ local symbols_to_items = lsphelper.symbols_to_items -- if #lines > 0 then -- gui.new_list_view({data = lines}) -- else --- print("symbols not found") +-- vim.notify("symbols not found") -- end -- end @@ -77,12 +77,12 @@ end M.document_symbol_handler = mk_handler(function(err, result, ctx) if err then - print('failed to get document symbol', ctx) + vim.notify('failed to get document symbol', ctx, vim.lsp.log_levels.WARN) end local bufnr = ctx.bufnr or 0 if not result or vim.tbl_isempty(result) then - print('symbol not found for buf', ctx) + vim.notify('symbol not found for buf', ctx, vim.lsp.log_levels.WARN) return end -- log(result) @@ -134,10 +134,10 @@ end) M.workspace_symbol_handler = mk_handler(function(err, result, ctx, cfg) if err then - print('failed to get workspace symbol', ctx) + vim.notify('failed to get workspace symbol', ctx, vim.lsp.log_levels.WARN) end if not result or vim.tbl_isempty(result) then - print('symbol not found for buf', ctx) + vim.notify('symbol not found for buf', ctx, vim.lsp.log_levels.WARN) return end log(result[1]) @@ -161,7 +161,7 @@ M.workspace_symbol_handler = mk_handler(function(err, result, ctx, cfg) -- gui.new_list_view({items = items, prompt = true, ft = ft, rowdata = true, api = " "}) -- if locations == nil or vim.tbl_isempty(locations) then - -- print "References not found" + -- vim.notify "References not found" -- return -- end -- local items = locations_to_items(locations) diff --git a/lua/navigator/treesitter.lua b/lua/navigator/treesitter.lua index 4d2914b..0a5e0de 100644 --- a/lua/navigator/treesitter.lua +++ b/lua/navigator/treesitter.lua @@ -292,11 +292,11 @@ local function get_all_nodes(bufnr, filter, summary) trace(bufnr, filter, summary) if not bufnr then - print("get_all_node invalide bufnr") + vim.notify("get_all_node invalide bufnr", vim.lsp.log_levels.WARN) end summary = summary or false if not parsers.has_parser() then - print("ts not loaded") + vim.notify("ts not loaded", vim.lsp.log_levels.WARN) end local path_sep = require"navigator.util".path_sep() diff --git a/lua/navigator/util.lua b/lua/navigator/util.lua index 18a7c98..8f068b4 100644 --- a/lua/navigator/util.lua +++ b/lua/navigator/util.lua @@ -211,7 +211,7 @@ function M.getArgs(inputstr) end function M.p(t) - print(vim.inspect(t)) + vim.notify(vim.inspect(t), vim.log.levels.INFO) end function M.printError(msg) diff --git a/lua/navigator/workspace.lua b/lua/navigator/workspace.lua new file mode 100644 index 0000000..55615e3 --- /dev/null +++ b/lua/navigator/workspace.lua @@ -0,0 +1,49 @@ +-- https://github.com/lukas-reineke/dotfiles/blob/master/vim/lua/lsp/rename.lua +local M = {} +local util = require('navigator.util') +-- local rename_prompt = 'Rename -> ' + +M.add_workspace_folder = function() + util.log(vim.ui.input) + local input = require('guihua.floating').input + input({ prompt = 'Workspace To Add: ', default = vim.fn.expand('%:p:h') }, function(inputs) + util.log(inputs) + vim.lsp.buf.add_workspace_folder(inputs) + end) +end + +M.remove_workspace_folder = function() + local select = require('guihua.gui').select + local folders = vim.lsp.buf.list_workspace_folders() + + if #folders > 1 then + select(folders, { prompt = 'select workspace to delete' }, function(workspace) + util.log(workspace) + vim.lsp.buf.remove_workspace_folder(workspace) + end) + end +end + +M.workspace_symbol = function() + local input = vim.ui.input + + vim.ui.input = require('guihua.floating').input + vim.lsp.buf.workspace_symbol() + vim.defer_fn(function() + vim.ui.input = input + end, 1000) +end + +M.list_workspace_folders = function() + local folders = vim.lsp.buf.list_workspace_folders() + if #folders > 0 then + return require('navigator.gui').new_list_view({ + items = folders, + border = 'single', + rawdata = true, + on_move = function(...) end, + }) + end +end + +return M