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.

90 lines
3.0 KiB

4 months ago
6 months ago
  1. return {
  2. "hrsh7th/nvim-cmp",
  3. event = "InsertEnter",
  4. dependencies = {
  5. -- Snippet Engine & its associated nvim-cmp source
  6. {
  7. "L3MON4D3/LuaSnip",
  8. build = (function()
  9. if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then
  10. return
  11. end
  12. return "make install_jsregexp"
  13. end)(),
  14. dependencies = {
  15. {
  16. "rafamadriz/friendly-snippets",
  17. config = function()
  18. require("luasnip.loaders.from_vscode").lazy_load()
  19. end,
  20. },
  21. },
  22. },
  23. "saadparwaiz1/cmp_luasnip",
  24. "onsails/lspkind.nvim",
  25. "kristijanhusak/vim-dadbod-completion",
  26. "hrsh7th/cmp-nvim-lsp",
  27. "hrsh7th/cmp-buffer",
  28. "hrsh7th/cmp-path",
  29. "hrsh7th/cmp-nvim-lsp-signature-help",
  30. },
  31. config = function()
  32. local cmp = require("cmp")
  33. local luasnip = require("luasnip")
  34. local lspkind = require("lspkind")
  35. luasnip.config.setup({})
  36. cmp.setup({
  37. snippet = {
  38. expand = function(args)
  39. luasnip.lsp_expand(args.body)
  40. end,
  41. },
  42. completion = {
  43. completeopt = "menu,menuone,noinsert",
  44. },
  45. mapping = cmp.mapping.preset.insert({
  46. ["<C-n>"] = cmp.mapping.select_next_item(),
  47. ["<C-p>"] = cmp.mapping.select_prev_item(),
  48. ["<C-b>"] = cmp.mapping.scroll_docs(-4),
  49. ["<C-f>"] = cmp.mapping.scroll_docs(4),
  50. ["<C-y>"] = cmp.mapping.confirm({ select = true }),
  51. ["<C-Space>"] = cmp.mapping.complete({}),
  52. ["<C-l>"] = cmp.mapping(function()
  53. if luasnip.expand_or_locally_jumpable() then
  54. luasnip.expand_or_jump()
  55. end
  56. end, { "i", "s" }),
  57. ["<C-h>"] = cmp.mapping(function()
  58. if luasnip.locally_jumpable(-1) then
  59. luasnip.jump(-1)
  60. end
  61. end, { "i", "s" }),
  62. }),
  63. sources = {
  64. { name = "nvim_lsp" },
  65. { name = "luasnip" },
  66. { name = "buffer" },
  67. { name = "path" },
  68. { name = "vim-dadbod-completion" },
  69. },
  70. formatting = {
  71. expandable_indicator = true,
  72. fields = { "abbr", "kind", "menu" },
  73. format = lspkind.cmp_format({
  74. mode = "symbol_text",
  75. menu = {
  76. nvim_lua = "[API]",
  77. nvim_lsp = "[LSP]",
  78. luasnip = "[SNIP]",
  79. vim_dadbod_completion = "[DBUI]",
  80. path = "[PATH]",
  81. buffer = "[BUFF]",
  82. },
  83. }),
  84. },
  85. })
  86. end,
  87. }