Add coc basic config, not fully working yet
This commit is contained in:
61
nvim-coc/lua/plugins/utility/comment-box.lua
Executable file
61
nvim-coc/lua/plugins/utility/comment-box.lua
Executable file
@@ -0,0 +1,61 @@
|
||||
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,
|
||||
})
|
||||
|
||||
local opts = { silent = true }
|
||||
|
||||
opts.desc = "comment text box"
|
||||
vim.keymap.set({"n", "v"}, "<leader>cb", ":CBccbox<CR>", opts)
|
||||
opts.desc = "comment text line"
|
||||
vim.keymap.set({"n", "v"}, "<leader>cl", ":CBllline<CR>", opts)
|
||||
opts.desc = "comment line"
|
||||
vim.keymap.set({"n", "v"}, "<leader>ce", ":CBline<CR>", opts)
|
||||
opts.desc = "comment highlight"
|
||||
vim.keymap.set({"n", "v"}, "<leader>ch", ":CBlcbox18<CR>", opts)
|
||||
|
||||
opts.desc = "delete comment box"
|
||||
vim.keymap.set({"n", "v"}, "<leader>cd", ":CBd<CR>", opts)
|
||||
opts.desc = "yank comment box contents"
|
||||
vim.keymap.set({"n", "v"}, "<leader>cy", ":CBy<CR>", opts)
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user