54 lines
1.8 KiB
Lua
Executable File
54 lines
1.8 KiB
Lua
Executable File
return {
|
|
"LudoPinelli/comment-box.nvim",
|
|
config = function()
|
|
-- add custom commentstring to plugin source, since configuration is not yet supported
|
|
local function insertlang(lang, commentstring)
|
|
local filename = os.getenv("HOME")
|
|
.. "/.local/share/nvim/lazy/comment-box.nvim/lua/comment-box/commentstrings.lua"
|
|
local file = io.open(filename, "r")
|
|
if not file then
|
|
return
|
|
end
|
|
|
|
local content = file:read("a")
|
|
if string.match(content, lang) then
|
|
return
|
|
end
|
|
|
|
local lines = {}
|
|
for line in content:gmatch("[^\r\n]+") do
|
|
table.insert(lines, line)
|
|
end
|
|
file:close()
|
|
|
|
table.insert(lines, 24, " " .. lang .. ' = { "' .. commentstring .. '", "" },')
|
|
|
|
file = io.open(filename, "w")
|
|
if not file then
|
|
return
|
|
end
|
|
|
|
file:write(table.concat(lines, "\n"))
|
|
|
|
file:close()
|
|
end
|
|
|
|
insertlang("hyprlang", "#%s")
|
|
|
|
require("comment-box").setup({
|
|
comment_style = "line",
|
|
doc_width = 70,
|
|
box_width = 50,
|
|
line_width = 70,
|
|
})
|
|
end,
|
|
keys = {
|
|
{ "<leader>cb", ":CBccbox<CR>", mode = { "n", "v" }, desc = "Comment text box" },
|
|
{ "<leader>cl", ":CBllline<CR>", mode = { "n", "v" }, desc = "Comment text line" },
|
|
{ "<leader>ce", ":CBline<CR>", mode = { "n", "v" }, desc = "Comment line" },
|
|
{ "<leader>ch", ":CBlcbox18<CR>", mode = { "n", "v" }, desc = "Comment highlight" },
|
|
{ "<leader>cd", ":CBd<CR>", mode = { "n", "v" }, desc = "Delete comment box" },
|
|
{ "<leader>cy", ":CBy<CR>", mode = { "n", "v" }, desc = "Yank comment box content" }
|
|
},
|
|
}
|