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.

91 lines
3.1 KiB

2 months ago
3 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. -- See `:help cmp`
  33. local cmp = require("cmp")
  34. local luasnip = require("luasnip")
  35. local lspkind = require("lspkind")
  36. luasnip.config.setup({})
  37. cmp.setup({
  38. snippet = {
  39. expand = function(args)
  40. luasnip.lsp_expand(args.body)
  41. end,
  42. },
  43. completion = {
  44. completeopt = "menu,menuone,noinsert",
  45. },
  46. mapping = cmp.mapping.preset.insert({
  47. ["<C-n>"] = cmp.mapping.select_next_item(),
  48. ["<C-p>"] = cmp.mapping.select_prev_item(),
  49. ["<C-b>"] = cmp.mapping.scroll_docs(-4),
  50. ["<C-f>"] = cmp.mapping.scroll_docs(4),
  51. ["<C-y>"] = cmp.mapping.confirm({ select = true }),
  52. ["<C-Space>"] = cmp.mapping.complete({}),
  53. ["<C-l>"] = cmp.mapping(function()
  54. if luasnip.expand_or_locally_jumpable() then
  55. luasnip.expand_or_jump()
  56. end
  57. end, { "i", "s" }),
  58. ["<C-h>"] = cmp.mapping(function()
  59. if luasnip.locally_jumpable(-1) then
  60. luasnip.jump(-1)
  61. end
  62. end, { "i", "s" }),
  63. }),
  64. sources = {
  65. { name = "nvim_lsp" },
  66. { name = "luasnip" },
  67. { name = "buffer" },
  68. { name = "path" },
  69. { name = "vim-dadbod-completion" },
  70. },
  71. formatting = {
  72. expandable_indicator = true,
  73. fields = { "abbr", "kind", "menu" },
  74. format = lspkind.cmp_format({
  75. mode = "symbol_text",
  76. menu = {
  77. nvim_lua = "[API]",
  78. nvim_lsp = "[LSP]",
  79. luasnip = "[SNIP]",
  80. vim_dadbod_completion = "[DBUI]",
  81. path = "[PATH]",
  82. buffer = "[BUFF]",
  83. },
  84. }),
  85. },
  86. })
  87. end,
  88. }