Guest User

blink config

a guest
Jul 6th, 2025
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.58 KB | None | 0 0
  1.  
  2. ---@class LazyPlugin
  3. return {
  4. "saghen/blink.cmp",
  5. version = "1.*",
  6. event = { "InsertEnter", "CmdlineEnter" },
  7. dependencies = {
  8. "rafamadriz/friendly-snippets",
  9. {
  10. "L3MON4D3/LuaSnip",
  11. version = "v2.*",
  12. config = function()
  13. require("luasnip.loaders.from_vscode").lazy_load()
  14. end,
  15. },
  16. "moyiz/blink-emoji.nvim",
  17. "MahanRahmati/blink-nerdfont.nvim",
  18. "Kaiser-Yang/blink-cmp-git",
  19. "Kaiser-Yang/blink-cmp-dictionary",
  20. "disrupted/blink-cmp-conventional-commits",
  21. "alexandre-abrioux/blink-cmp-npm.nvim",
  22. "nvim-tree/nvim-web-devicons",
  23. "onsails/lspkind.nvim",
  24. "xzbdmw/colorful-menu.nvim",
  25. "folke/lazydev.nvim",
  26. },
  27. ---@module 'blink.cmp'
  28. ---@type blink.cmp.Config
  29. opts = {
  30.  
  31. snippets = { preset = "luasnip" },
  32.  
  33. keymap = {
  34.  
  35. preset = "default",
  36.  
  37. ["<Tab>"] = {
  38. function(cmp)
  39. local has_words_before = function()
  40. local col = vim.api.nvim_win_get_cursor(0)[2]
  41. if col == 0 then
  42. return false
  43. end
  44. return vim.api.nvim_get_current_line():sub(col, col):match("%s") == nil
  45. end
  46. if has_words_before() then
  47. return cmp.select_next()
  48. end
  49. end,
  50. "snippet_forward",
  51. "fallback",
  52. },
  53.  
  54. ["<S-Tab>"] = { "insert_prev", "snippet_backward", "fallback" },
  55. ["<CR>"] = { "select_and_accept", "fallback" },
  56. },
  57.  
  58. appearance = {
  59. nerd_font_variant = "mono",
  60. },
  61.  
  62. completion = {
  63.  
  64. accept = {
  65. auto_brackets = {
  66. enabled = true,
  67. },
  68. },
  69.  
  70. list = {
  71. selection = {
  72. preselect = true,
  73. auto_insert = false,
  74. },
  75. },
  76.  
  77. menu = {
  78. border = "rounded",
  79. draw = {
  80. kind_icon = {
  81. text = function(ctx)
  82. local icon = ctx.kind_icon
  83.  
  84. if vim.tbl_contains({ "Path" }, ctx.source_name) then
  85. local dev_icon, _ = require("nvim-web-devicons").get_icon(ctx.label)
  86. if dev_icon then
  87. icon = dev_icon
  88. end
  89. elseif ctx.item.source_name == "LSP" then
  90. local color_item =
  91. require("nvim-highlight-colors").format(ctx.item.documentation, { kind = ctx.kind })
  92. if color_item and color_item.abbr ~= "" then
  93. icon = color_item.abbr
  94. else
  95. -- Fallback to lspkind if no color item
  96. local lspkind = require("lspkind")
  97. icon = lspkind.symbolic(ctx.kind, { mode = "symbol" })
  98. end
  99. else
  100. -- For other sources, use lspkind
  101. local lspkind = require("lspkind")
  102. icon = lspkind.symbolic(ctx.kind, { mode = "symbol" })
  103. end
  104.  
  105. return icon .. ctx.icon_gap
  106. end,
  107.  
  108. highlight = function(ctx)
  109. local hl = ctx.kind_hl
  110.  
  111. if vim.tbl_contains({ "Path" }, ctx.source_name) then
  112. local dev_icon, dev_hl = require("nvim-web-devicons").get_icon(ctx.label)
  113. if dev_icon and dev_hl then
  114. hl = dev_hl
  115. end
  116. elseif ctx.item.source_name == "LSP" then
  117. local color_item =
  118. require("nvim-highlight-colors").format(ctx.item.documentation, { kind = ctx.kind })
  119. if color_item and color_item.abbr_hl_group then
  120. hl = color_item.abbr_hl_group
  121. else
  122. -- Fallback to default kind highlight
  123. hl = "BlinkCmpKind" .. ctx.kind
  124. end
  125. else
  126. -- Default highlight for other sources
  127. hl = "BlinkCmpKind" .. ctx.kind
  128. end
  129.  
  130. return hl
  131. end,
  132. },
  133. label = {
  134. text = function(ctx)
  135. return require("colorful-menu").blink_components_text(ctx)
  136. end,
  137. highlight = function(ctx)
  138. return require("colorful-menu").blink_components_highlight(ctx)
  139. end,
  140. },
  141. },
  142. columns = {
  143. { "label", gap = 1 },
  144. { "kind_icon", "kind", gap = 1 },
  145. },
  146. },
  147. },
  148.  
  149. documentation = {
  150. auto_show = true,
  151. auto_show_delay_ms = 500,
  152. window = { border = "rounded" },
  153. },
  154.  
  155. ghost_text = {
  156. enabled = true,
  157. -- show_without_selection = true,
  158. },
  159. },
  160.  
  161. signature = {
  162. enabled = true,
  163. -- trigger = { show_on_insert = false },
  164. -- trigger = { show_on_insert = true },
  165. window = { border = "rounded" },
  166. },
  167. sources = {
  168.  
  169. default = { "lsp", "path", "snippets", "buffer", "dictionary" },
  170.  
  171. per_filetype = {
  172. sql = { "snippets", "dadbod", "buffer" },
  173. gitcommit = { "buffer", "emoji", "nerdfont", "git", "conventional_commits" },
  174. markdown = { "buffer", "emoji", "nerdfont", "git", "conventional_commits" },
  175. octo = { "buffer", "emoji", "nerdfont", "git", "conventional_commits" },
  176. json = { "npm", inherit_defaults = true },
  177. lua = { inherit_defaults = true, "lazydev" },
  178. },
  179.  
  180. providers = {
  181. path = {
  182. opts = {
  183. get_cwd = function(_)
  184. return vim.fn.getcwd()
  185. end,
  186. },
  187. },
  188.  
  189. lazydev = {
  190. name = "LazyDev",
  191. module = "lazydev.integrations.blink",
  192. score_offset = 100,
  193. },
  194.  
  195. dadbod = {
  196. name = "Dadbod",
  197. module = "vim_dadbod_completion.blink",
  198. },
  199.  
  200. emoji = {
  201. module = "blink-emoji",
  202. name = "Emoji",
  203. score_offset = 15, -- Tune by preference
  204. opts = { insert = true }, -- Insert emoji (default) or complete its name
  205. },
  206.  
  207. git = {
  208. module = "blink-cmp-git",
  209. name = "Git",
  210. opts = {}, -- options for the blink-cmp-git
  211. },
  212.  
  213. conventional_commits = {
  214. name = "Conventional Commits",
  215. module = "blink-cmp-conventional-commits",
  216. opts = {}, -- none so far
  217. },
  218.  
  219. dictionary = {
  220. module = "blink-cmp-dictionary",
  221. name = "Dict",
  222. min_keyword_length = 4,
  223. opts = {
  224. dictionary_directories = {
  225. vim.fn.stdpath("config") .. "/dict",
  226. },
  227. },
  228. },
  229.  
  230. nerdfont = {
  231. module = "blink-nerdfont",
  232. name = "Nerd Fonts",
  233. score_offset = 15, -- Tune by preference
  234. opts = { insert = true }, -- Insert nerdfont icon (default) or complete its name
  235. },
  236.  
  237. npm = {
  238. name = "npm",
  239. module = "blink-cmp-npm",
  240. async = true,
  241. -- optional - make blink-cmp-npm completions top priority (see `:h blink.cmp`)
  242. score_offset = 100,
  243. -- optional - blink-cmp-npm config
  244. ---@module "blink-cmp-npm"
  245. ---@class blink-cmp-npm.Options
  246. opts = {
  247. ignore = {},
  248. only_semantic_versions = false,
  249. only_latest_version = false,
  250. },
  251. },
  252. },
  253. },
  254.  
  255. fuzzy = { use_frecency = true, implementation = "prefer_rust" },
  256. },
  257.  
  258. opts_extend = { "sources.default" },
  259. }
Advertisement
Add Comment
Please, Sign In to add comment