plugins.lua 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. -- add extra filetypes for plenary
  2. require('plenary.filetype').add_table({
  3. extension = {
  4. ['elv'] = [[elvish]]
  5. }
  6. })
  7. -- file/buffer/etc picker
  8. require('telescope').setup({
  9. defaults = {
  10. mappings = {
  11. i = {
  12. ['jj'] = 'close',
  13. },
  14. },
  15. layout_config = {
  16. prompt_position = 'top',
  17. },
  18. sorting_strategy = 'ascending',
  19. -- use filename as preview window title
  20. dynamic_preview_title = true,
  21. preview = {
  22. -- don't preview files larger than 1MB
  23. filesize_limit = 1,
  24. timeout = 500,
  25. },
  26. -- ignore things we're likely not to edit
  27. file_ignore_patterns = {
  28. "%.zip$",
  29. "%.yarn/releases/",
  30. "%.yarn/plugins/"
  31. },
  32. },
  33. pickers = {
  34. buffers = {
  35. sort_lastused = true,
  36. sort_mru = true,
  37. mappings = {
  38. i = {
  39. ['<C-k>'] = 'delete_buffer'
  40. },
  41. },
  42. },
  43. find_files = {
  44. find_command = { "fd", "--type", "f", "--strip-cwd-prefix" }
  45. },
  46. },
  47. })
  48. -- use native sorter for better performance
  49. require('telescope').load_extension('fzf')
  50. -- custom picker to fallback to files if no git
  51. local telescope_builtin = require('telescope.builtin')
  52. _G.project_files = function()
  53. local ok = pcall(telescope_builtin.git_files, { show_untracked = true })
  54. if not ok then telescope_builtin.find_files({}) end
  55. end
  56. -- shows added/removed/changed lines
  57. require('gitsigns').setup()
  58. require('mini.statusline').setup({
  59. content = {
  60. -- copy-pasted from default, we just want to remove the icon
  61. active = function()
  62. local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 })
  63. local git = MiniStatusline.section_git({ trunc_width = 75, icon = '' })
  64. local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75, icon = '' })
  65. local filename = MiniStatusline.section_filename({ trunc_width = 140 })
  66. local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 })
  67. local location = MiniStatusline.section_location({ trunc_width = 75 })
  68. return MiniStatusline.combine_groups({
  69. { hl = mode_hl, strings = { mode } },
  70. { hl = 'MiniStatuslineDevinfo', strings = { git, diagnostics } },
  71. '%<', -- Mark general truncate point
  72. { hl = 'MiniStatuslineFilename', strings = { filename } },
  73. '%=', -- End left alignment
  74. { hl = 'MiniStatuslineFileinfo', strings = { fileinfo } },
  75. { hl = mode_hl, strings = { location } },
  76. })
  77. end
  78. },
  79. })
  80. -- delete buffer while preserving layout
  81. require('mini.bufremove').setup()
  82. -- shows a line indicating the current indentation scope
  83. require('mini.indentscope').setup()
  84. -- comment actions
  85. require('mini.comment').setup()
  86. -- surround actions
  87. require('mini.surround').setup()
  88. local spec_treesitter = require('mini.ai').gen_spec.treesitter
  89. require('mini.ai').setup({
  90. custom_textobjects = {
  91. [','] = spec_treesitter({
  92. a = '@parameter.outer',
  93. i = '@parameter.inner',
  94. }),
  95. },
  96. });
  97. -- align actions
  98. require('mini.align').setup()
  99. -- repeatable f/t
  100. require('mini.jump').setup({
  101. mappings = {
  102. repeat_jump = '',
  103. },
  104. delay = {
  105. highlight = 10000000,
  106. },
  107. })
  108. -- rest client
  109. require('rest-nvim').setup({})
  110. -- Use Treesitter for syntax highlighting
  111. require('nvim-treesitter.configs').setup({
  112. highlight = {
  113. enable = true,
  114. },
  115. incremental_selection = {
  116. enable = true,
  117. keymaps = {
  118. init_selection = "]t",
  119. node_incremental = "]t",
  120. node_decremental = "[t",
  121. },
  122. },
  123. textobjects = {
  124. swap = {
  125. enable = true,
  126. swap_next = {
  127. ['>,'] = '@parameter.inner',
  128. },
  129. swap_previous = {
  130. ['<,'] = '@parameter.inner',
  131. },
  132. },
  133. },
  134. })
  135. local tsj_utils = require('treesj.langs.utils')
  136. -- Treesitter-aware split/join
  137. require('treesj').setup({
  138. use_default_keymaps = false,
  139. })
  140. -- completion
  141. local cmp = require('cmp')
  142. cmp.setup({
  143. snippet = {
  144. expand = function(args)
  145. vim.fn['vsnip#anonymous'](args.body)
  146. end,
  147. },
  148. mapping = cmp.mapping.preset.insert({
  149. ['<C-b>'] = cmp.mapping.scroll_docs(-4),
  150. ['<C-f>'] = cmp.mapping.scroll_docs(4),
  151. ['<C-Space>'] = cmp.mapping.complete(),
  152. ['<C-e>'] = cmp.mapping.abort(),
  153. ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
  154. }),
  155. sources = cmp.config.sources({
  156. { name = "nvim_lsp" },
  157. { name = "vsnip" },
  158. }),
  159. completion = {
  160. autocomplete = false,
  161. },
  162. })
  163. -- typescript-vim compiler options
  164. vim.g.typescript_compiler_options = '--incremental --noEmit'