Skip to content

Commit a5d62ad

Browse files
authored
feat: add verbose option (#116)
1 parent ae47768 commit a5d62ad

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

lua/img-clip/config.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ local defaults = {
1717
use_absolute_path = false, ---@type boolean
1818
relative_to_current_file = false, ---@type boolean
1919

20+
-- show warning messages
21+
verbose = true, ---@type boolean | fun(): boolean
22+
2023
-- template options
2124
template = "$FILE_PATH", ---@type string
2225
url_encode_path = false, ---@type boolean

lua/img-clip/util.lua

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,15 @@ M.has = function(feature)
5757
end
5858

5959
---@param msg string
60-
---@param verbose boolean?
61-
M.warn = function(msg, verbose)
62-
if M.verbose or verbose then
60+
M.warn = function(msg)
61+
if config.get_opt("verbose") then
6362
vim.notify(msg, vim.log.levels.WARN, { title = "img-clip" })
6463
end
6564
end
6665

6766
---@param msg string
68-
---@param verbose boolean?
69-
M.error = function(msg, verbose)
70-
if M.verbose or verbose then
67+
M.error = function(msg)
68+
if config.get_opt("verbose") then
7169
vim.notify(msg, vim.log.levels.ERROR, { title = "img-clip" })
7270
end
7371
end

tests/config_spec.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe("config", function()
1313
assert.equals("assets", config.get_opt("dir_path"))
1414
assert.equals("%Y-%m-%d-%H-%M-%S", config.get_opt("file_name"))
1515
assert.equals("png", config.get_opt("extension"))
16+
assert.is_true(config.get_opt("verbose"))
1617
assert.is_false(config.get_opt("url_encode_path"))
1718
assert.is_false(config.get_opt("use_absolute_path"))
1819
assert.is_false(config.get_opt("relative_to_current_file"))

vimdoc.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ The plugin is highly configurable. Please refer to the default configuration bel
9292
use_absolute_path = false, ---@type boolean | fun(): boolean
9393
relative_to_current_file = false, ---@type boolean | fun(): boolean
9494

95+
-- logging options
96+
verbose = true, ---@type boolean | fun(): boolean
97+
9598
-- template options
9699
template = "$FILE_PATH", ---@type string | fun(context: table): string
97100
url_encode_path = false, ---@type boolean | fun(): boolean

0 commit comments

Comments
 (0)