init.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. -- vim.api.nvim_set_keymap("v", "<leader>/", "<Plug>kommentary_visual_default", {})
  2. -- require('kommentary.config').configure_language("default", {
  3. -- prefer_single_line_comments = true,
  4. -- })
  5. -- require('kommentary.config').configure_language("python", {
  6. -- prefer_single_line_comments = true,
  7. -- })
  8. -- require('kommentary.config').configure_language("javascriptreact", {
  9. -- prefer_multi_line_comments = true,
  10. -- -- single_line_comment_string = "{/*\\ %s\\ */}",
  11. -- multi_line_comment_strings = {"{/*", "*/}"},
  12. -- })
  13. --[[ This is our custom function for toggling comments with a custom commentstring,
  14. it's based on the default toggle_comment, but before calling the function for
  15. toggling ranges, it sets the commenstring to something else. After it is done,
  16. it sets it back to what it was before. ]]
  17. -- function toggle_comment_custom_commentstring(...)
  18. -- local args = {...}
  19. -- -- Save the current value of commentstring so we can restore it later
  20. -- local commentstring = vim.bo.commentstring
  21. -- -- Set the commentstring for the current buffer to something new
  22. -- vim.bo.commentstring = "{/*%s*/}"
  23. -- -- print(args[1])
  24. -- -- print(args[2])
  25. -- -- print(vim.inspect(args[1]))
  26. -- print(vim.inspect(args))
  27. -- --[[ Call the function for toggling comments, which will resolve the config
  28. -- to the new commentstring and proceed with that. ]]
  29. -- require('kommentary.kommentary').toggle_comment_range(args[1], args[2],
  30. -- require('kommentary.config').get_modes().normal)
  31. -- -- Restore the original value of commentstring
  32. -- vim.api.nvim_buf_set_option(0, "commentstring", commentstring)
  33. -- end
  34. -- -- vim.bo.commentstring = "{/*%s*/}"
  35. -- -- Set the extra mapping for toggling a single line in normal mode
  36. -- vim.api.nvim_set_keymap('n', '<leader>/',
  37. -- '<cmd>lua require("kommentary");kommentary.go(' .. require('kommentary.config').context.line .. ', '
  38. -- .. "'toggle_comment_custom_commentstring'" .. ')<cr>',
  39. -- { noremap = true, silent = true })
  40. -- -- -- Set the extra mapping for toggling a range with a motion
  41. -- -- vim.api.nvim_set_keymap('n', '<leader>/',
  42. -- -- 'v:lua.kommentary.go(' .. require('kommentary.config').context.init .. ', ' ..
  43. -- -- "'toggle_comment_custom_commentstring'" .. ')',
  44. -- -- { noremap = true, expr = true })
  45. -- -- -- Set the extra mapping for toggling a range with a visual selection
  46. -- -- vim.api.nvim_set_keymap('v', 'gC',
  47. -- -- '<cmd>lua require("kommentary");kommentary.go(' .. require('kommentary.config').context.visual .. ', '
  48. -- -- .. "'toggle_comment_custom_commentstring'" .. ')<cr>',
  49. -- -- { noremap = true, silent = true })
  50. require('nvim_comment').setup()
  51. --vim.api.nvim_buf_set_option(0, "commentstring", "{/*%s*/}")