mappings.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. local silent_noremap = { noremap = true, silent = true }
  2. vim.g.mapleader = ' '
  3. -- treat long lines as multiple lines
  4. ncvim.add_mappings {
  5. {
  6. mode = 'n',
  7. key_string = '<leader>jp',
  8. options = { noremap = false },
  9. command = '%!python3 -m json.tool --no-ensure-ascii<CR>',
  10. },
  11. {
  12. mode = '',
  13. key_string = 'j',
  14. command = 'gj',
  15. options = { noremap = false },
  16. },
  17. {
  18. mode = '',
  19. key_string = 'k',
  20. command = 'gk',
  21. options = { noremap = false },
  22. },
  23. -- various UX shortcuts
  24. -- terminal
  25. {
  26. mode = 'n',
  27. key_string = '<leader><C-t>',
  28. command = ':split<CR><C-w>j:term<CR>',
  29. options = silent_noremap,
  30. },
  31. -- exit i mode in terminal
  32. {
  33. mode = 't',
  34. key_string = '<C-o>',
  35. command = '<C-\\><C-n>',
  36. options = { noremap = false },
  37. },
  38. -- " clear search highlights
  39. {
  40. mode = 'n',
  41. key_string = '<leader>/',
  42. command = ':noh<CR>',
  43. options = silent_noremap,
  44. },
  45. -- " source %
  46. {
  47. mode = 'n',
  48. key_string = '<leader><C-s>',
  49. command = ':source %<CR>',
  50. options = silent_noremap,
  51. },
  52. -- " reload current file
  53. {
  54. mode = 'n',
  55. key_string = '<leader><C-r>',
  56. command = ':edit!<CR>',
  57. options = silent_noremap,
  58. },
  59. -- " open current file in new tab (e.g. for copy mode)
  60. {
  61. mode = 'n',
  62. key_string = '<leader>tt',
  63. command = ':tabe %<CR>',
  64. options = silent_noremap,
  65. },
  66. -- " switch between relative and absolute line numbers
  67. {
  68. mode = 'n',
  69. key_string = '<C-n><C-n>',
  70. command = ':set relativenumber!<CR>',
  71. options = silent_noremap,
  72. },
  73. {
  74. mode = 'n',
  75. key_string = 'gd',
  76. command = ncvim.lsp.definitions,
  77. options = silent_noremap,
  78. },
  79. {
  80. mode = 'n',
  81. key_string = 'gsd',
  82. command = '<C-w>v<cmd> lua ncvim.lsp.definitions()<CR>',
  83. options = silent_noremap,
  84. },
  85. {
  86. mode = 'n',
  87. key_string = 'gSd',
  88. command = '<C-w>s<cmd> lua ncvim.lsp.definitions()<CR>',
  89. options = silent_noremap,
  90. },
  91. {
  92. mode = 'n',
  93. key_string = 'gD',
  94. command = ncvim.lsp.declaration,
  95. options = silent_noremap,
  96. },
  97. {
  98. mode = 'n',
  99. key_string = 'gsD',
  100. command = '<C-w>v<cmd> lua ncvim.lsp.declaration()<CR>',
  101. options = silent_noremap,
  102. },
  103. {
  104. mode = 'n',
  105. key_string = '<C-k>',
  106. command = ncvim.lsp.signature_help,
  107. options = silent_noremap,
  108. },
  109. {
  110. mode = 'i',
  111. key_string = '<C-k>',
  112. command = ncvim.lsp.signature_help,
  113. options = silent_noremap,
  114. },
  115. {
  116. mode = 'n',
  117. key_string = 'gi',
  118. command = ncvim.lsp.implementations,
  119. options = silent_noremap,
  120. },
  121. {
  122. mode = 'n',
  123. key_string = 'gsi',
  124. command = '<C-w>v<cmd> lua ncvim.lsp.implementations()<CR>',
  125. options = silent_noremap,
  126. },
  127. {
  128. mode = 'n',
  129. key_string = 'gSi',
  130. command = '<C-w>s<cmd> lua ncvim.lsp.implementations()<CR>',
  131. options = silent_noremap,
  132. },
  133. {
  134. mode = 'n',
  135. key_string = 'gr',
  136. command = ncvim.lsp.references,
  137. options = silent_noremap,
  138. },
  139. {
  140. mode = 'n',
  141. key_string = 'gsr',
  142. command = '<C-w>v<cmd> lua ncvim.lsp.references()<CR>',
  143. options = silent_noremap,
  144. },
  145. {
  146. mode = 'n',
  147. key_string = 'gSr',
  148. command = '<C-w>s<cmd> lua ncvim.lsp.references()<CR>',
  149. options = silent_noremap,
  150. },
  151. }