ui.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. -- 自定义图标
  2. vim.diagnostic.config({
  3. virtual_text = true,
  4. signs = true,
  5. update_in_insert = false,
  6. })
  7. local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
  8. for type, icon in pairs(signs) do
  9. local hl = "DiagnosticSign" .. type
  10. vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
  11. end
  12. -- lspkind
  13. local lspkind = require("lspkind")
  14. lspkind.init({
  15. -- default: true
  16. -- with_text = true,
  17. -- defines how annotations are shown
  18. -- default: symbol
  19. -- options: 'text', 'text_symbol', 'symbol_text', 'symbol'
  20. mode = "symbol_text",
  21. -- default symbol map
  22. -- can be either 'default' (requires nerd-fonts font) or
  23. -- 'codicons' for codicon preset (requires vscode-codicons font)
  24. --
  25. -- default: 'default'
  26. preset = "codicons",
  27. -- override preset symbols
  28. --
  29. -- default: {}
  30. symbol_map = {
  31. Text = "",
  32. Method = "",
  33. Function = "",
  34. Constructor = "",
  35. Field = "ﰠ",
  36. Variable = "",
  37. Class = "ﴯ",
  38. Interface = "",
  39. Module = "",
  40. Property = "ﰠ",
  41. Unit = "塞",
  42. Value = "",
  43. Enum = "",
  44. Keyword = "",
  45. Snippet = "",
  46. Color = "",
  47. File = "",
  48. Reference = "",
  49. Folder = "",
  50. EnumMember = "",
  51. Constant = "",
  52. Struct = "פּ",
  53. Event = "",
  54. Operator = "",
  55. TypeParameter = "",
  56. },
  57. })
  58. local lspsaga = require("lspsaga")
  59. lspsaga.setup({ -- defaults ...
  60. debug = false,
  61. use_saga_diagnostic_sign = true,
  62. -- diagnostic sign
  63. error_sign = "",
  64. warn_sign = "",
  65. hint_sign = "",
  66. infor_sign = "",
  67. diagnostic_header_icon = "  ",
  68. -- code action title icon
  69. code_action_icon = " ",
  70. code_action_prompt = {
  71. enable = true,
  72. sign = true,
  73. sign_priority = 40,
  74. virtual_text = true,
  75. },
  76. finder_definition_icon = " ",
  77. finder_reference_icon = " ",
  78. max_preview_lines = 10,
  79. finder_action_keys = {
  80. -- open = "o",
  81. open = "<CR>",
  82. vsplit = "s",
  83. split = "i",
  84. -- quit = "q",
  85. quit = "<ESC>",
  86. scroll_down = "<C-f>",
  87. scroll_up = "<C-b>",
  88. },
  89. code_action_keys = {
  90. -- quit = "q",
  91. quit = "<ESC>",
  92. exec = "<CR>",
  93. },
  94. rename_action_keys = {
  95. -- quit = "<C-c>",
  96. quit = "<ESC>",
  97. exec = "<CR>",
  98. },
  99. definition_preview_icon = " ",
  100. border_style = "single",
  101. rename_prompt_prefix = "➤",
  102. rename_output_qflist = {
  103. enable = false,
  104. auto_open_qflist = false,
  105. },
  106. server_filetype_map = {},
  107. diagnostic_prefix_format = "%d. ",
  108. diagnostic_message_format = "%m %c",
  109. highlight_prefix = false,
  110. })
  111. local M = {}
  112. -- 为 cmp.lua 提供参数格式
  113. M.formatting = {
  114. format = lspkind.cmp_format({
  115. mode = "symbol_text",
  116. --mode = 'symbol', -- show only symbol annotations
  117. maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
  118. -- The function below will be called before any actual modifications from lspkind
  119. -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
  120. before = function(entry, vim_item)
  121. -- Source 显示提示来源
  122. vim_item.menu = "[" .. string.upper(entry.source.name) .. "]"
  123. return vim_item
  124. end,
  125. }),
  126. }
  127. return M