lspkind.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. local status, lspkind = pcall(require, "lspkind")
  2. if not status then
  3. return
  4. end
  5. lspkind.init({
  6. -- default: true
  7. -- with_text = true,
  8. -- defines how annotations are shown
  9. -- default: symbol
  10. -- options: 'text', 'text_symbol', 'symbol_text', 'symbol'
  11. mode = "symbol_text",
  12. -- default symbol map
  13. -- can be either 'default' (requires nerd-fonts font) or
  14. -- 'codicons' for codicon preset (requires vscode-codicons font)
  15. --
  16. -- default: 'default'
  17. preset = "codicons",
  18. -- override preset symbols
  19. --
  20. -- default: {}
  21. symbol_map = {
  22. Text = "",
  23. Method = "",
  24. Function = "",
  25. Constructor = "",
  26. Field = "ﰠ",
  27. Variable = "",
  28. Class = "ﴯ",
  29. Interface = "",
  30. Module = "",
  31. Property = "ﰠ",
  32. Unit = "塞",
  33. Value = "",
  34. Enum = "",
  35. Keyword = "",
  36. Snippet = "",
  37. Color = "",
  38. File = "",
  39. Reference = "",
  40. Folder = "",
  41. EnumMember = "",
  42. Constant = "",
  43. Struct = "פּ",
  44. Event = "",
  45. Operator = "",
  46. TypeParameter = "",
  47. },
  48. })
  49. local M = {}
  50. -- 为 cmp.lua 提供参数格式
  51. M.formatting = {
  52. format = lspkind.cmp_format({
  53. mode = "symbol_text",
  54. -- mode = 'symbol', -- show only symbol annotations
  55. maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
  56. -- The function below will be called before any actual modifications from lspkind
  57. -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
  58. before = function(entry, vim_item)
  59. -- Source 显示提示来源
  60. vim_item.menu = "[" .. string.upper(entry.source.name) .. "]"
  61. return vim_item
  62. end,
  63. }),
  64. }
  65. return M