Repository navigation
feat: virtual text support #28
Description
Activity
require("nvim-dap-virtual-text").setup({ -- This just tries to mitigate the chance that I leak tokens here. Probably won't stop it from happening... display_callback = function(variable) local name = string.lower(variable.name) local value = string.lower(variable.value) if name:match("Secret") or name:match("api") or value:match("secret") or value:match("api") then return "*****" end if #variable.value > 15 then return " " .. string.sub(variable.value, 1, 15) .. "... " end return " " .. variable.value end, })
might be usefull (copied from https://www.youtube.com/watch?v=lyNfnI-B640)
Personally I think that the best way to handle this is to export a function from
cloak.nvimwhich does variable masking. This would require a plugin refactor, however I think that it very important. The core principle of this plugin is to be minimal and flexible approach. Here is an example of implementation from my plugin which also does sensitive value masking:@sand4rt Regarding your question, here is a crude example with my plugin and how this implementation could look like:
local ok, ecolog_utils = pcall(require, "ecolog.shelter.utils") if not ok then require("nvim-dap-virtual-text").setup({ display_callback = function(variable) -- Your original masking logic here end, }) return end require("nvim-dap-virtual-text").setup({ display_callback = function(variable) local settings = { key = variable.name, source = "dap", patterns = { [".*secret.*"] = "full", [".*token.*"] = "full", [".*password.*"] = "full", [".*api.*"] = "partial", }, } local masked = ecolog_utils.determine_masked_value(variable.value, settings) if #masked > 15 then return " " .. string.sub(masked, 1, 15) .. "... " end return " " .. masked end, })
This would require installing ecolog.nvim as a dependency
require("ecolog").setup({ shelter = { patterns = { [".*secret.*"] = "full", [".*token.*"] = "full", [".*password.*"] = "full", [".*api.*"] = "partial", }, sources = { ["dap"] = "none" -- Default behavior for DAP variables }, partial_mode = { show_start = 3, show_end = 3, min_mask = 3, }, mask_char = "*", } })
@philosofonusus Thanks for your reply! I believe this was mentioned earlier, but just a friendly reminder to be mindful of promoting your plugin in the issue section of a similar plugin. It wouldn’t be ideal if others did the same in your issue section, right?
Why not collaborate and merge some of the proposals into Clock instead of creating an new plugin?
Sorry I don't 100% understand, you want cloak.nvim to cloak the virtual text created by other plugins?
Sorry I don't 100% understand, you want cloak.nvim to cloak the virtual text created by other plugins?
I just want to avoid leaking my env variables, that's all ;) But yeah, the text is created by dap / noice. I think its reasanable since Cloak already has telescope itegration, right?
Alright, thanks, just wanted to make sure I understood!
Reacted by Sander and Dmytro Pletenskyi@philosofonusus Thanks for your reply! I believe this was mentioned earlier, but just a friendly reminder to be mindful of promoting your plugin in the issue section of a similar plugin. It wouldn’t be ideal if others did the same in your issue section, right?
Why not collaborate and merge some of the proposals into Clock instead of creating an new plugin?
You can feel free to share your feedback, be it an issue or enhancement. The main idea of OSS is to contribute and collaborate.
My contribution is that I provide a feedback, help you receive an immediate solution for your question. While proposing exact place in my code, which helps in making a pull request. This is my contribution to
cloak.nvimas an opensource project.Reacted by Sander
Will there be support for virtual text, like in nvim-dap-virtual-text for debugging, or in noice.nvim for search results?