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.

89 lines
2.1 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. },
  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 = "vim-dadbod-completion" },
  68. },
  69. formatting = {
  70. expandable_indicator = true,
  71. fields = { "abbr", "kind", "menu" },
  72. format = lspkind.cmp_format({
  73. mode = "symbol_text",
  74. menu = {
  75. nvim_lua = "[API]",
  76. nvim_lsp = "[LSP]",
  77. luasnip = "[SNIP]",
  78. vim_dadbod_completion = "[DBUI]",
  79. path = "[PATH]",
  80. buffer = "[BUFF]",
  81. },
  82. }),
  83. },
  84. })
  85. end,
  86. }