From 611e8c30751e09b69813f63c08cdd8ee787ca247 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Mon, 7 Feb 2022 12:52:21 +0200 Subject: [PATCH] feat: fixed .nix commentstring --- dotfiles/neovim/lua/my/plugins/comment.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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