mappings.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. local default_opts = require('utils.mappings_utils').default_opts
  2. vim.g.mapleader = ' '
  3. -- treat long lines as multiple lines
  4. ncvim.add_mappings {
  5. {
  6. mode = '',
  7. key_string = 'j',
  8. command = 'gj',
  9. options = { noremap = false },
  10. },
  11. {
  12. mode = '',
  13. key_string = 'k',
  14. command = 'gk',
  15. options = { noremap = false },
  16. },
  17. -- various UX shortcuts
  18. -- terminal
  19. {
  20. mode = 'n',
  21. key_string = '<leader><C-t>',
  22. command = ':split<CR><C-w>j:term<CR>',
  23. options = default_opts,
  24. },
  25. -- exit i mode in terminal
  26. {
  27. mode = 't',
  28. key_string = '<C-o>',
  29. command = '<C-\\><C-n>',
  30. options = { noremap = false },
  31. },
  32. -- " clear search highlights
  33. {
  34. mode = 'n',
  35. key_string = '<leader>/',
  36. command = ':noh<CR>',
  37. options = default_opts,
  38. },
  39. -- " source %
  40. {
  41. mode = 'n',
  42. key_string = '<leader><C-s>',
  43. command = ':source %<CR>',
  44. options = default_opts,
  45. },
  46. -- " reload current file
  47. {
  48. mode = 'n',
  49. key_string = '<leader><C-r>',
  50. command = ':edit!<CR>',
  51. options = default_opts,
  52. },
  53. -- " open current file in new tab (e.g. for copy mode)
  54. {
  55. mode = 'n',
  56. key_string = '<leader>tt',
  57. command = ':tabe %<CR>',
  58. options = default_opts,
  59. },
  60. -- " switch between relative and absolute line numbers
  61. {
  62. mode = 'n',
  63. key_string = '<C-n><C-n>',
  64. command = ':set relativenumber!<CR>',
  65. options = default_opts,
  66. },
  67. }