completion.lua 2.7 KB

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