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.

99 lines
2.5 KiB

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