diff --git a/dotfiles/neovim/lua/my/plugins/comment.lua b/dotfiles/neovim/lua/my/plugins/comment.lua index 48afb2e..a9a4814 100644 --- a/dotfiles/neovim/lua/my/plugins/comment.lua +++ b/dotfiles/neovim/lua/my/plugins/comment.lua @@ -2,15 +2,17 @@ local M = {} -- Update comments for certain languages local function setCommentString(extension, commentString) - vim.cmd('autocmd BufEnter '.. extension .. ' :lua vim.api.nvim_buf_set_option(0, "commentstring", "' .. commentString .. '")') - vim.cmd('autocmd BufFilePost '.. extension .. ' :lua vim.api.nvim_buf_set_option(0, "commentstring", "' .. commentString ..'")') + vim.cmd('augroup set-commentstring-' .. extension) + vim.cmd('autocmd!') + vim.cmd('autocmd BufEnter *.' .. extension .. ' :lua vim.api.nvim_buf_set_option(0, "commentstring", "' .. commentString .. '")') + vim.cmd('autocmd BufFilePost *.' .. extension .. ' :lua vim.api.nvim_buf_set_option(0, "commentstring", "' .. commentString .. '")') + vim.cmd('augroup END') end function M.setup() require('nvim_comment').setup() - setCommentString(".nix", "# %s") + setCommentString("nix", "# %s") end - return M