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. },
  20. appearance = {
  21. use_nvim_cmp_as_default = true,
  22. nerd_font_variant = "mono",
  23. },
  24. snippets = { preset = "luasnip" },
  25. sources = {
  26. default = { "lsp", "path", "snippets", "buffer", "dadbod" },
  27. providers = {
  28. dadbod = { name = "Dadbod", module = "vim_dadbod_completion.blink" },
  29. },
  30. },
  31. signature = {
  32. enabled = true,
  33. window = {
  34. border = "single",
  35. },
  36. },
  37. completion = {
  38. list = {
  39. selection = {
  40. auto_insert = true,
  41. preselect = false,
  42. },
  43. },
  44. menu = {
  45. border = "single",
  46. draw = {
  47. components = {
  48. kind_icon = {
  49. ellipsis = false,
  50. text = function(ctx)
  51. local kind_icon, _, _ = require("mini.icons").get("lsp", ctx.kind)
  52. return kind_icon
  53. end,
  54. highlight = function(ctx)
  55. local _, hl, _ = require("mini.icons").get("lsp", ctx.kind)
  56. return hl
  57. end,
  58. },
  59. },
  60. },
  61. auto_show = function(ctx)
  62. return ctx.mode ~= "default"
  63. end,
  64. },
  65. },
  66. fuzzy = {
  67. -- Frecency tracks the most recently/frequently used items and boosts the score of the item
  68. use_frecency = true,
  69. -- Proximity bonus boosts the score of items matching nearby words
  70. use_proximity = true,
  71. -- Controls which sorts to use and in which order, falling back to the next sort if the first one returns nil
  72. -- You may pass a function instead of a string to customize the sorting
  73. sorts = { "score", "sort_text" },
  74. },
  75. })
  76. end
  77. return M