completion.lua 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. return {
  2. {
  3. "saghen/blink.cmp",
  4. dependencies = {
  5. "L3MON4D3/LuaSnip",
  6. "rafamadriz/friendly-snippets",
  7. },
  8. version = "*",
  9. config = function()
  10. require("blink.cmp").setup({
  11. snippets = { preset = "luasnip" },
  12. signature = { enabled = true },
  13. appearance = {
  14. use_nvim_cmp_as_default = false,
  15. nerd_font_variant = "normal",
  16. },
  17. sources = {
  18. default = { "lsp", "path", "snippets", "buffer" },
  19. providers = {
  20. cmdline = {
  21. min_keyword_length = 2,
  22. },
  23. },
  24. },
  25. keymap = {
  26. ["<C-space>"] = {
  27. "show",
  28. "show_documentation",
  29. "hide_documentation",
  30. },
  31. ["<C-d>"] = { "hide", "fallback" },
  32. ["<C-c>"] = { "hide", "fallback" },
  33. ["<CR>"] = { "accept", "fallback" },
  34. ["<C-k>"] = { "select_prev", "fallback" },
  35. ["<C-j>"] = { "select_next", "fallback" },
  36. },
  37. cmdline = {
  38. enabled = true,
  39. completion = { menu = { auto_show = true } },
  40. },
  41. completion = {
  42. list = {
  43. selection = {
  44. auto_insert = true,
  45. preselect = false,
  46. },
  47. },
  48. menu = {
  49. border = "rounded",
  50. scrolloff = 1,
  51. scrollbar = true,
  52. draw = {
  53. columns = {
  54. { "kind_icon" },
  55. { "label", "label_description", gap = 1 },
  56. { "kind" },
  57. { "source_name" },
  58. },
  59. },
  60. },
  61. documentation = {
  62. auto_show = true,
  63. auto_show_delay_ms = 200,
  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. require("luasnip.loaders.from_vscode").lazy_load()
  77. end,
  78. },
  79. }