diff --git a/README.md b/README.md index 8c28cc7..957181e 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,9 @@ require("various-textobjs").setup { icon = "󰠱", -- only used with notification plugins like `nvim-notify` whenObjectNotFound = true, }, + + -- show debugging messages on use of certain text objects + debug = false, } ``` diff --git a/lua/various-textobjs/config.lua b/lua/various-textobjs/config.lua index 04ec326..36671c9 100644 --- a/lua/various-textobjs/config.lua +++ b/lua/various-textobjs/config.lua @@ -42,6 +42,9 @@ local defaultConfig = { icon = "󰠱", -- only used with notification plugins like `nvim-notify` whenObjectNotFound = true, }, + + -- show debugging messages on use of certain text objects + debug = false, } M.config = defaultConfig diff --git a/lua/various-textobjs/textobjs/charwise/core.lua b/lua/various-textobjs/textobjs/charwise/core.lua index 62c35d9..dc0e465 100644 --- a/lua/various-textobjs/textobjs/charwise/core.lua +++ b/lua/various-textobjs/textobjs/charwise/core.lua @@ -90,7 +90,7 @@ end ---@return integer? startCol ---@return integer? endCol function M.selectClosestTextobj(patterns, scope, lookForwLines) - local enableLogging = false -- DEBUG + local enableLogging = require("various-textobjs.config").config.debug local objLogging = {} -- initialized with values to always loose comparisons @@ -111,6 +111,7 @@ function M.selectClosestTextobj(patterns, scope, lookForwLines) cur.distance = cur.startCol - cursorCol cur.endDistance = cursorCol - cur.endCol cur.cursorOnObj = cur.distance <= 0 and cur.endDistance <= 0 + cur.patternName = patternName -- INFO Here, we cannot simply use the absolute value of the distance. -- If the cursor is standing on a big textobj A, and there is a @@ -149,7 +150,11 @@ function M.selectClosestTextobj(patterns, scope, lookForwLines) if enableLogging then local textobj = debug.getinfo(3, "n").name objLogging._closest = closest.patternName - vim.notify(vim.inspect(objLogging), nil, { ft = "lua", title = scope .. " " .. textobj }) + vim.notify( + vim.inspect(objLogging), + vim.log.levels.DEBUG, + { ft = "lua", title = scope .. " " .. textobj } + ) end return closest.row, closest.startCol, closest.endCol end