Skip to content

Commit

Permalink
Adding tracker per bufferpane for comment plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Neko-Box-Coder committed Aug 14, 2024
1 parent 589452d commit d8313d9
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions runtime/plugins/comment/comment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,30 @@ ft["zig"] = "// %s"
ft["zscript"] = "// %s"
ft["zsh"] = "# %s"

function updateCommentType(buf)
if buf.Settings["commenttype"] == nil then
if ft[buf.Settings["filetype"]] ~= nil then
buf.Settings["commenttype"] = ft[buf.Settings["filetype"]]
function updateCommentType(bp)
-- This is the first time doing comment in this bp
if bp.Settings["commentfiletype"] == nil then
-- If commenttype is not registered, use the comment table we have
if bp.Settings["commenttype"] == nil then
if ft[bp.Settings["filetype"]] ~= nil then
bp.Settings["commenttype"] = ft[bp.Settings["filetype"]]
else
bp.Settings["commenttype"] = "# %s"
end
-- Otherwise if the commenttype is registered, that means this is coming from the settings,
-- or set manually by the user. We should update our comment table
else
ft[bp.Settings["filetype"]] = bp.Settings["commenttype"]
end
-- Watch for any filetype change
bp.Settings["commentfiletype"] = bp.Settings["filetype"]

-- Otherwise, check if the filetype has changed manually. If so, use the comment table
elseif bp.Settings["commentfiletype"] ~= bp.Settings["filetype"] then
if ft[bp.Settings["filetype"]] ~= nil then
bp.Settings["commenttype"] = ft[bp.Settings["filetype"]]
else
buf.Settings["commenttype"] = "# %s"
bp.Settings["commenttype"] = "# %s"
end
end
end
Expand Down

0 comments on commit d8313d9

Please sign in to comment.