completion.lua 2.4 KB

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