diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 525e116..496a6a2 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -182,12 +182,17 @@ return { { "JoosepAlviste/nvim-ts-context-commentstring", lazy = true, - event = "InsertEnter", + event = "BufWinEnter", dependencies = "nvim-treesitter/nvim-treesitter", + config = function() + require("ts_context_commentstring").setup({ + enable_autocmd = false, + }) + end, }, { "numToStr/Comment.nvim", - event = "InsertEnter", + event = "BufWinEnter", config = function() require("user.comment") end, @@ -248,7 +253,7 @@ return { -- for auto close tag { "windwp/nvim-ts-autotag", - event = "InsertEnter", + event = "BufWinEnter", dependencies = "nvim-treesitter/nvim-treesitter", config = function() require("nvim-ts-autotag").setup() diff --git a/lua/user/comment.lua b/lua/user/comment.lua index be171e7..a83296e 100644 --- a/lua/user/comment.lua +++ b/lua/user/comment.lua @@ -4,29 +4,30 @@ if not status_ok then end comment.setup({ - pre_hook = function(ctx) - local U = require("Comment.utils") - -- - -- local status_utils_ok, utils = pcall(require, "ts_context_commentstring.utils") - -- if not status_utils_ok then - -- return - -- end + pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook(), + -- pre_hook = function(ctx) + -- local U = require("Comment.utils") + -- + -- local status_utils_ok, utils = pcall(require, "ts_context_commentstring.utils") + -- if not status_utils_ok then + -- return + -- end - -- local location = nil - -- if ctx.ctype == U.ctype.block then - -- location = utils.get_cursor_location() - -- elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then - -- location = utils.get_visual_start_location() - -- end + -- local location = nil + -- if ctx.ctype == U.ctype.block then + -- location = utils.get_cursor_location() + -- elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then + -- location = utils.get_visual_start_location() + -- end - -- local status_internals_ok, internals = pcall(require, "ts_context_commentstring.internals") - -- if not status_internals_ok then - -- return - -- end + -- local status_internals_ok, internals = pcall(require, "ts_context_commentstring.internals") + -- if not status_internals_ok then + -- return + -- end - -- return internals.calculate_commentstring({ - -- key = ctx.ctype == U.ctype.line and "__default" or "__multiline", - -- location = location, - -- }) - end, + -- return internals.calculate_commentstring({ + -- key = ctx.ctype == U.ctype.line and "__default" or "__multiline", + -- location = location, + -- }) + -- end, })