config.lua 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. local fn = vim.fn
  2. -- nvim-cmp. completions
  3. local cmp = require 'cmp'
  4. local types = require('cmp.types')
  5. cmp.setup({
  6. snippet = {
  7. -- REQUIRED - you must specify a snippet engine
  8. expand = function(args)
  9. fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
  10. -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
  11. -- require('snippy').expand_snippet(args.body) -- For `snippy` users.
  12. -- fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
  13. end,
  14. },
  15. window = {
  16. -- completion = cmp.config.window.bordered(),
  17. -- documentation = cmp.config.window.bordered(),
  18. },
  19. mapping = cmp.mapping.preset.insert({
  20. ['<C-b>'] = cmp.mapping.scroll_docs(-4),
  21. ['<C-f>'] = cmp.mapping.scroll_docs(4),
  22. ['<C-Space>'] = cmp.mapping.complete(),
  23. ['<C-e>'] = cmp.mapping.abort(),
  24. ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
  25. ['<C-j>'] = {
  26. i = cmp.mapping.select_next_item({ behavior = types.cmp.SelectBehavior.Insert }),
  27. },
  28. ['<C-k>'] = {
  29. i = cmp.mapping.select_prev_item({ behavior = types.cmp.SelectBehavior.Insert }),
  30. },
  31. }),
  32. sources = cmp.config.sources({
  33. { name = 'nvim_lsp' },
  34. { name = 'vsnip' }, -- For vsnip users.
  35. -- { name = 'luasnip' }, -- For luasnip users.
  36. -- { name = 'ultisnips' }, -- For ultisnips users.
  37. -- { name = 'snippy' }, -- For snippy users.
  38. }, {
  39. { name = 'buffer' },
  40. })
  41. })
  42. -- Set configuration for specific filetype.
  43. cmp.setup.filetype('gitcommit', {
  44. sources = cmp.config.sources({
  45. { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
  46. }, {
  47. { name = 'buffer' },
  48. })
  49. })
  50. -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
  51. cmp.setup.cmdline('/', {
  52. mapping = cmp.mapping.preset.cmdline(),
  53. sources = {
  54. { name = 'buffer' }
  55. }
  56. })
  57. -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
  58. cmp.setup.cmdline(':', {
  59. mapping = cmp.mapping.preset.cmdline(),
  60. sources = cmp.config.sources({
  61. { name = 'path' }
  62. }, {
  63. { name = 'cmdline' }
  64. })
  65. })
  66. require('nvim-lightbulb').setup({
  67. autocmd = {
  68. enabled = true
  69. }
  70. })