completion.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. keymap = {
  41. ["<CR>"] = { "accept_and_enter", "fallback" },
  42. },
  43. },
  44. completion = {
  45. list = {
  46. selection = {
  47. auto_insert = true,
  48. preselect = false,
  49. },
  50. },
  51. menu = {
  52. border = "rounded",
  53. scrolloff = 1,
  54. scrollbar = true,
  55. draw = {
  56. columns = {
  57. { "kind_icon" },
  58. { "label", "label_description", gap = 1 },
  59. { "kind" },
  60. { "source_name" },
  61. },
  62. },
  63. },
  64. documentation = {
  65. auto_show = true,
  66. auto_show_delay_ms = 200,
  67. },
  68. },
  69. fuzzy = {
  70. -- Frecency tracks the most recently/frequently used items and boosts the score of the item
  71. use_frecency = true,
  72. -- Proximity bonus boosts the score of items matching nearby words
  73. use_proximity = true,
  74. -- Controls which sorts to use and in which order, falling back to the next sort if the first one returns nil
  75. -- You may pass a function instead of a string to customize the sorting
  76. sorts = { "score", "sort_text" },
  77. },
  78. })
  79. require("luasnip.loaders.from_vscode").lazy_load()
  80. end,
  81. },
  82. }