completion.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. local M = {
  2. "saghen/blink.cmp",
  3. dependencies = { "L3MON4D3/LuaSnip", version = "v2.*" },
  4. version = "v1.*",
  5. }
  6. M.config = function()
  7. require("blink.cmp").setup({
  8. keymap = {
  9. ["<C-space>"] = {
  10. "show",
  11. "show_documentation",
  12. "hide_documentation",
  13. },
  14. ["<C-d>"] = { "hide", "fallback" },
  15. ["<C-c>"] = { "hide", "fallback" },
  16. ["<CR>"] = { "accept", "fallback" },
  17. ["<C-k>"] = { "select_prev", "fallback" },
  18. ["<C-j>"] = { "select_next", "fallback" },
  19. ["<Tab>"] = { "fallback" },
  20. },
  21. appearance = {
  22. use_nvim_cmp_as_default = true,
  23. nerd_font_variant = "mono",
  24. },
  25. snippets = { preset = "luasnip" },
  26. sources = {
  27. default = { "lsp", "path", "snippets", "buffer", "dadbod" },
  28. providers = {
  29. dadbod = { name = "Dadbod", module = "vim_dadbod_completion.blink" },
  30. },
  31. },
  32. signature = {
  33. enabled = true,
  34. window = {
  35. border = "single",
  36. },
  37. },
  38. completion = {
  39. list = {
  40. selection = {
  41. auto_insert = true,
  42. preselect = false,
  43. },
  44. },
  45. menu = {
  46. border = "single",
  47. draw = {
  48. components = {
  49. kind_icon = {
  50. ellipsis = false,
  51. text = function(ctx)
  52. local kind_icon, _, _ = require("mini.icons").get("lsp", ctx.kind)
  53. return kind_icon
  54. end,
  55. highlight = function(ctx)
  56. local _, hl, _ = require("mini.icons").get("lsp", ctx.kind)
  57. return hl
  58. end,
  59. },
  60. },
  61. },
  62. auto_show = function(ctx)
  63. return ctx.mode ~= "default"
  64. end,
  65. },
  66. },
  67. fuzzy = {
  68. -- Frecency tracks the most recently/frequently used items and boosts the score of the item
  69. use_frecency = true,
  70. -- Proximity bonus boosts the score of items matching nearby words
  71. use_proximity = true,
  72. -- Controls which sorts to use and in which order, falling back to the next sort if the first one returns nil
  73. -- You may pass a function instead of a string to customize the sorting
  74. sorts = { "score", "sort_text" },
  75. },
  76. })
  77. end
  78. return M