diff --git a/README.md b/README.md index 8b7653b..0253c3a 100644 --- a/README.md +++ b/README.md @@ -450,14 +450,6 @@ enable_icons = true, -- the database. required_keys = { "papis_id", "ref" }, }, - --- Configuration of logging. -log = { - - -- What levels to log. Debug mode is more conveniently - -- enabled in `enable_modules`. - level = "info", -}, ``` In order to use the cmp source, you need to add it to the sources loaded by cmp. diff --git a/lua/papis/at-cursor/init.lua b/lua/papis/at-cursor/init.lua index 23b4dfb..61bda21 100644 --- a/lua/papis/at-cursor/init.lua +++ b/lua/papis/at-cursor/init.lua @@ -64,7 +64,7 @@ local function if_ref_valid_run_fun(fun, self, type) fun(papis_id, type) end else - log.info(string.format("No entry in database corresponds to '%s'", ref)) + vim.notify(string.format("No entry in database corresponds to '%s'", ref), vim.log.levels.WARN) end end diff --git a/lua/papis/completion/init.lua b/lua/papis/completion/init.lua index 66d6b05..4ab1d6e 100644 --- a/lua/papis/completion/init.lua +++ b/lua/papis/completion/init.lua @@ -9,7 +9,8 @@ local log = require("papis.log") local has_cmp, cmp = pcall(require, "cmp") if not has_cmp then - log.warn("The plugin nvim-cmp wasn't found but the respective papis.nvim module is configured to be loaded.") + vim.notify("The plugin nvim-cmp wasn't found but the respective papis.nvim module is configured to be loaded.", + vim.log.levels.ERROR) return nil end diff --git a/lua/papis/config.lua b/lua/papis/config.lua index 16a2fcf..1b2f281 100644 --- a/lua/papis/config.lua +++ b/lua/papis/config.lua @@ -146,9 +146,6 @@ local default_config = { tag_format = nil, required_keys = { "papis_id", "ref" }, }, - log = { - level = "info", -- off turns it off - }, } local M = vim.deepcopy(default_config) diff --git a/lua/papis/fs-watcher.lua b/lua/papis/fs-watcher.lua index b0d0d2a..db74490 100644 --- a/lua/papis/fs-watcher.lua +++ b/lua/papis/fs-watcher.lua @@ -138,7 +138,7 @@ local function init_fs_watcher(dir_to_watch, is_library_root) -- disable watcher unwatch_cb() -- note, print still occurs even though we unwatched *future* events - log.warn(string.format("An error occured: %s", error)) + vim.notify(string.format("An error occured: %s", error), vim.log.levels.ERROR) end) end diff --git a/lua/papis/init.lua b/lua/papis/init.lua index 98ba8ef..7c0ca6d 100644 --- a/lua/papis/init.lua +++ b/lua/papis/init.lua @@ -30,8 +30,9 @@ local function are_dependencies_available() local dependencies = { "papis", config.yq_bin } for _, dependency in ipairs(dependencies) do if vim.fn.executable(dependency) == 0 then - log.error( - string.format("The executable '%s' could not be found. Please install it to use papis.nvim", dependency) + vim.notify( + string.format("The executable '%s' could not be found. Please install it to use papis.nvim", dependency), + vim.log.levels.ERROR ) return false end @@ -62,7 +63,7 @@ function M.start() -- set up db local db = require("papis.sqlite-wrapper") if not db then - log.warn("Requiring `sqlite-wrapper.lua` failed. Aborting...") + vim.notify("Requiring `sqlite-wrapper.lua` failed. Aborting...", vim.log.levels.ERROR) return nil end db:init() @@ -75,7 +76,7 @@ function M.start() -- require what's necessary within `M.start()` instead of globally to allow lazy-loading local data = require("papis.data") if not data then - log.warn("Requiring `data.lua` failed. Aborting...") + vim.notify("Requiring `data.lua` failed. Aborting...", vim.log.levels.ERROR) return nil end diff --git a/lua/papis/log.lua b/lua/papis/log.lua index 992e713..523f4c6 100644 --- a/lua/papis/log.lua +++ b/lua/papis/log.lua @@ -30,7 +30,7 @@ local default_config = { plugin = "papis.nvim", - use_console = true, + use_console = false, highlights = true, diff --git a/lua/papis/papis-storage.lua b/lua/papis/papis-storage.lua index 2922542..b95b399 100644 --- a/lua/papis/papis-storage.lua +++ b/lua/papis/papis-storage.lua @@ -68,12 +68,13 @@ local function is_valid_entry(entry, path) if entry[key] then is_valid = true else - log.info(string.format("The entry at '%s' is missing the key '%s' and will not be added.", path, key)) + vim.notify(string.format("The entry at '%s' is missing the key '%s' and will not be added.", path, key), + vim.log.levels.WARN) break end end else - log.info(string.format("The entry at '%s' is faulty and will not be added.", path)) + vim.notify(string.format("The entry at '%s' is faulty and will not be added.", path), vim.log.levels.WARN) end return is_valid end @@ -199,7 +200,8 @@ function M.get_data_full(metadata) if type(entry[key]) == "table" then data[key] = entry[key] else - log.warn("Wanted to add `" .. key .. "` of `" .. entry.ref .. "` but the value is not of type `table`") + vim.notify("Wanted to add `" .. key .. "` of `" .. entry.ref .. "` but the value is not of type `table`", + vim.log.levels.WARN) data[key] = {} end end diff --git a/lua/papis/search/init.lua b/lua/papis/search/init.lua index d1b6e45..942a084 100644 --- a/lua/papis/search/init.lua +++ b/lua/papis/search/init.lua @@ -7,7 +7,8 @@ local log = require("papis.log") local has_telescope, telescope = pcall(require, "telescope") if not has_telescope then - log.error("The plugin telescope.nvim wasn't found but the search module is enabled and requires it.") + vim.notify("The plugin telescope.nvim wasn't found but the search module is enabled and requires it.", + vim.log.levels.ERROR) return nil end local entry_display = require("telescope.pickers.entry_display") diff --git a/lua/papis/sqlite-wrapper.lua b/lua/papis/sqlite-wrapper.lua index 643e384..467b852 100644 --- a/lua/papis/sqlite-wrapper.lua +++ b/lua/papis/sqlite-wrapper.lua @@ -5,11 +5,10 @@ -- Wrapper around sqlite.lua setting up the main database and associated methods. -- -local log = require("papis.log") - local has_sqlite, sqlite = pcall(require, "sqlite") if not has_sqlite then - log.error("The dependency 'sqlite.nvim' is missing. Ensure that it is installed to run papis.nvim") + vim.notify("The dependency 'sqlite.nvim' is missing. Ensure that it is installed to run papis.nvim", + vim.log.levels.ERROR) return nil end local sqlite_utils = require "sqlite.utils" diff --git a/lua/papis/utils.lua b/lua/papis/utils.lua index 01581cc..95dbe23 100644 --- a/lua/papis/utils.lua +++ b/lua/papis/utils.lua @@ -109,9 +109,9 @@ function M:do_open_attached_files(papis_id) lookup_tbl[filename] = entry.files[k] end if vim.tbl_isempty(filenames) then - log.info("This item has no attached files.") + vim.notify("This item has no attached files.", vim.log.levels.WARN) elseif #filenames == 1 then - log.info("Opening file '" .. filenames[1] .. "' ") + vim.notify("Opening file '" .. filenames[1] .. "' ", vim.log.levels.INFO) local path = lookup_tbl[filenames[1]] self:do_open_file_external(path) else @@ -119,7 +119,7 @@ function M:do_open_attached_files(papis_id) prompt = "Select attachment to open:", }, function(choice) if choice then - log.info("Opening file '" .. choice .. "' ") + vim.notify("Opening file '" .. choice .. "' ", vim.log.levels.INFO) local path = lookup_tbl[choice] self:do_open_file_external(path) end @@ -133,7 +133,7 @@ end function M:do_open_text_file(papis_id, type) local db = require("papis.sqlite-wrapper") if not db then - log.warn("Sqlite-wrapper has not been initialised properly. Aborting...") + vim.notify("Sqlite-wrapper has not been initialised properly. Aborting...", vim.log.levels.ERROR) return nil end log.debug("Opening a text file")