Add warning messages if the user setup maybe deprecated or incorrect

pull/117/head
ray-x 3 years ago
parent 3d6b24f919
commit 9aec552ac1

@ -4,10 +4,6 @@ local function warn(msg)
vim.api.nvim_echo({{"WRN: " .. msg, "WarningMsg"}}, true, {})
end
local function error(msg)
vim.api.nvim_echo({{"ERR: " .. msg, "ErrorMsg"}}, true, {})
end
local function info(msg)
vim.api.nvim_echo({{"Info: " .. msg}}, true, {})
end
@ -139,11 +135,16 @@ local extend_config = function(opts)
end
for key, value in pairs(opts) do
if _NgConfigValues[key] == nil then
warn(string.format("[] Key %s not valid", key))
_NgConfigValues[key] = {}
warn(string.format("[] Deprecated? Key %s is not in default setup, it could be incorrect to set to %s", key,
vim.inspect(value)))
_NgConfigValues[key] = value
-- return
end
else
if type(_NgConfigValues[key]) == "table" then
if type(value) ~= "table" then
info(string.format("[] Reset type: Key %s setup value %s type %s , from %s", key, vim.inspect(value),
type(value), vim.inspect(_NgConfigValues[key])))
end
for k, v in pairs(value) do
if type(k) == "number" then
-- replace all item in array
@ -180,6 +181,7 @@ local extend_config = function(opts)
_NgConfigValues[key] = value
end
end
end
if _NgConfigValues.sumneko_root_path or _NgConfigValues.sumneko_binary then
vim.notify("Please put sumneko setup in lsp['sumneko_lua']", vim.log.levels.WARN)
end

@ -55,7 +55,7 @@ describe("should run lsp reference", function()
-- require'lspconfig'.gopls.setup {}
require'navigator'.setup({
debug = true, -- log output, set to true and log path: ~/.local/share/nvim/gh.log
code_action_icon = "A ",
icons = {code_action_icon = "A "},
width = 0.75, -- max width ratio (number of cols for the floating window) / (window width)
height = 0.3, -- max list window height, 0.3 by default
preview_height = 0.35, -- max height of preview windows
@ -97,7 +97,7 @@ describe("should run lsp reference", function()
vim.bo.filetype = "go"
require'navigator'.setup({
debug = true, -- log output, set to true and log path: ~/.local/share/nvim/gh.log
code_action_icon = "A ",
icons = {code_action_icon = "A "},
width = 0.75, -- max width ratio (number of cols for the floating window) / (window width)
height = 0.3, -- max list window height, 0.3 by default
preview_height = 0.35, -- max height of preview windows
@ -133,9 +133,7 @@ describe("should run lsp reference", function()
}, {})
else
win, items, width = require('navigator.reference').reference_handler(nil,
"textDocument/references",
result, 1, 1)
win, items, width = require('navigator.reference').reference_handler(nil, "textDocument/references", result, 1, 1)
end
@ -165,7 +163,7 @@ describe("should run lsp reference", function()
vim.bo.filetype = "go"
require'navigator'.setup({
debug = true, -- log output, set to true and log path: ~/.local/share/nvim/gh.log
code_action_icon = "A ",
icons = {code_action_icon = "A "},
width = 0.75, -- max width ratio (number of cols for the floating window) / (window width)
height = 0.3, -- max list window height, 0.3 by default
preview_height = 0.35, -- max height of preview windows
@ -201,9 +199,7 @@ describe("should run lsp reference", function()
}, {truncate = 2})
else
win, items, width = require('navigator.reference').reference_handler(nil,
"textDocument/references",
result, 1, 1)
win, items, width = require('navigator.reference').reference_handler(nil, "textDocument/references", result, 1, 1)
end

Loading…
Cancel
Save