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.

102 lines
2.6 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. "kristijanhusak/vim-dadbod-completion",
  25. "hrsh7th/cmp-nvim-lsp",
  26. "hrsh7th/cmp-buffer",
  27. "hrsh7th/cmp-path",
  28. "hrsh7th/cmp-nvim-lsp-signature-help",
  29. "Snikimonkd/cmp-go-pkgs",
  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. { name = "go_pkgs" },
  70. },
  71. matching = {
  72. disallow_fullfuzzy_matching = false,
  73. disallow_partial_fuzzy_matching = false,
  74. disallow_fuzzy_matching = false,
  75. disallow_partial_matching = false,
  76. disallow_symbol_nonprefix_matching = false,
  77. disallow_prefix_unmatching = false,
  78. },
  79. formatting = {
  80. expandable_indicator = true,
  81. fields = { "abbr", "kind", "menu" },
  82. format = lspkind.cmp_format({
  83. with_text = true,
  84. mode = "symbol_text",
  85. menu = {
  86. nvim_lua = "[API]",
  87. nvim_lsp = "[LSP]",
  88. luasnip = "[SNIP]",
  89. vim_dadbod_completion = "[DBUI]",
  90. path = "[PATH]",
  91. buffer = "[BUFF]",
  92. go_pkgs = "[PKGS]",
  93. },
  94. }),
  95. },
  96. })
  97. end,
  98. }