comments.lua 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. local M = {
  2. {
  3. "numToStr/Comment.nvim",
  4. dependencies = {
  5. "JoosepAlviste/nvim-ts-context-commentstring",
  6. event = "VeryLazy",
  7. },
  8. config = function()
  9. vim.g.skip_ts_context_commentstring_module = true
  10. require("ts_context_commentstring").setup({
  11. enable_autocmd = false,
  12. })
  13. local function pre_hook(ctx)
  14. local U = require("Comment.utils")
  15. -- Check filetype
  16. local ft = vim.bo.filetype
  17. if ft == "c" or ft == "cpp" then
  18. if ctx.ctype == U.ctype.linewise then
  19. return "// %s"
  20. elseif ctx.ctype == U.ctype.blockwise then
  21. return "/* %s */"
  22. end
  23. end
  24. return require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook()(ctx)
  25. end
  26. require("Comment").setup({
  27. pre_hook = pre_hook,
  28. opleader = {
  29. line = "gc",
  30. block = "gC",
  31. },
  32. mappings = {
  33. basic = true,
  34. },
  35. })
  36. end,
  37. },
  38. {
  39. "folke/todo-comments.nvim",
  40. config = function()
  41. require("todo-comments").setup({
  42. keywords = {
  43. BAD = { icon = "󰇷 ", color = "error" },
  44. FUCK = { icon = "󰇷 ", color = "error" },
  45. SHITTY = { icon = "󰇷 ", color = "error" },
  46. },
  47. })
  48. end,
  49. },
  50. }
  51. return M