1
Fork 0
satellite/dotfiles/neovim/lua/my/plugins/comment.lua

27 lines
685 B
Lua
Raw Normal View History

local A = require("my.helpers.augroup")
2022-02-07 11:47:03 +01:00
local M = {}
2022-07-19 20:19:36 +02:00
local extraCommentStrings = { lean = "/- %s -/", bkf = "-- %s" }
2022-02-07 11:47:03 +01:00
-- Update comments for certain languages
2022-07-19 20:19:36 +02:00
function M.setCommentString(extension, commentString)
A.augroup('set-commentstring-' .. extension, function()
local action =
':lua vim.api.nvim_buf_set_option(0, "commentstring", "' ..
commentString .. '")'
2022-07-19 20:19:36 +02:00
A.autocmd('BufEnter', '*.' .. extension, action)
A.autocmd('BufFilePost', '*.' .. extension, action)
end)
2022-02-07 11:47:03 +01:00
end
function M.setup()
2022-07-19 20:19:36 +02:00
require('nvim_comment').setup()
2022-02-07 11:47:03 +01:00
2022-07-19 20:19:36 +02:00
for lang, commentString in pairs(extraCommentStrings) do
M.setCommentString(lang, commentString)
end
2022-02-07 11:47:03 +01:00
end
return M