Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.9 KiB

  1. return function()
  2. local cmp = require'cmp'
  3. local lspkind = require('lspkind')
  4. cmp.setup({
  5. snippet = {
  6. expand = function(args)
  7. require('snippy').expand_snippet(args.body) -- For `snippy` users.
  8. end,
  9. },
  10. window = {
  11. completion = cmp.config.window.bordered(),
  12. documentation = cmp.config.window.bordered(),
  13. },
  14. mapping = cmp.mapping.preset.insert({
  15. ['<C-b>'] = cmp.mapping.scroll_docs(-4),
  16. ['<C-f>'] = cmp.mapping.scroll_docs(4),
  17. ['<C-Space>'] = cmp.mapping.complete(),
  18. ['<C-e>'] = cmp.mapping.abort(),
  19. ["<Tab>"] = cmp.mapping(function(fallback)
  20. if cmp.visible() then
  21. local entry = cmp.get_selected_entry()
  22. if not entry then
  23. cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
  24. else
  25. cmp.confirm()
  26. end
  27. else
  28. fallback()
  29. end
  30. end, {"i","s","c",}),
  31. }),
  32. sources = cmp.config.sources({
  33. { name = 'nvim_lsp' },
  34. { name = 'snippy' },
  35. { name = 'vimtex', }
  36. }, {
  37. { name = 'buffer' },
  38. { name = 'path' },
  39. }),
  40. formatting = {
  41. format = lspkind.cmp_format({
  42. mode = 'symbol_text',
  43. preset = 'codicons',
  44. maxwidth = 50,
  45. ellipsis_char = '...',
  46. before = function (entry, vim_item)
  47. return vim_item
  48. end
  49. })
  50. }
  51. })
  52. cmp.setup.filetype('gitcommit', {
  53. sources = cmp.config.sources({
  54. { name = 'git' },
  55. }, {
  56. { name = 'buffer' },
  57. })
  58. })
  59. cmp.setup.cmdline({ '/', '?' }, {
  60. mapping = cmp.mapping.preset.cmdline(),
  61. view = {
  62. entries = {name = 'wildmenu', separator = '|' }
  63. },
  64. sources = {
  65. { name = 'buffer' },
  66. { name = 'path' }
  67. }
  68. })
  69. cmp.setup.cmdline(':', {
  70. mapping = cmp.mapping.preset.cmdline(),
  71. sources = cmp.config.sources({
  72. { name = 'path' }
  73. }, {
  74. { name = 'cmdline' }
  75. })
  76. })
  77. end