init.lua 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. local opts = {
  2. tools = { -- rust-tools options
  3. -- automatically set inlay hints (type hints)
  4. -- There is an issue due to which the hints are not applied on the first
  5. -- opened file. For now, write to the file to trigger a reapplication of
  6. -- the hints or just run :RustSetInlayHints.
  7. -- default: true
  8. autoSetHints = true,
  9. -- whether to show hover actions inside the hover window
  10. -- this overrides the default hover handler
  11. -- default: true
  12. hover_with_actions = true,
  13. runnables = {
  14. -- whether to use telescope for selection menu or not
  15. -- default: true
  16. use_telescope = true
  17. -- rest of the opts are forwarded to telescope
  18. },
  19. inlay_hints = {
  20. -- wheter to show parameter hints with the inlay hints or not
  21. -- default: true
  22. show_parameter_hints = true,
  23. -- prefix for parameter hints
  24. -- default: "<-"
  25. parameter_hints_prefix = "<-",
  26. -- prefix for all the other hints (type, chaining)
  27. -- default: "=>"
  28. other_hints_prefix = "=>",
  29. -- whether to align to the lenght of the longest line in the file
  30. max_len_align = false,
  31. -- padding from the left if max_len_align is true
  32. max_len_align_padding = 1,
  33. -- whether to align to the extreme right or not
  34. right_align = false,
  35. -- padding from the right if right_align is true
  36. right_align_padding = 7,
  37. },
  38. hover_actions = {
  39. -- the border that is used for the hover window
  40. -- see vim.api.nvim_open_win()
  41. border = {
  42. {"╭", "FloatBorder"},
  43. {"─", "FloatBorder"},
  44. {"╮", "FloatBorder"},
  45. {"│", "FloatBorder"},
  46. {"╯", "FloatBorder"},
  47. {"─", "FloatBorder"},
  48. {"╰", "FloatBorder"},
  49. {"│", "FloatBorder"}
  50. },
  51. }
  52. },
  53. -- all the opts to send to nvim-lspconfig
  54. -- these override the defaults set by rust-tools.nvim
  55. -- see https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer
  56. server = {
  57. cmd = {DATA_PATH .. "/lspinstall/rust/rust-analyzer"},
  58. on_attach = require'lsp'.common_on_attach
  59. }, -- rust-analyser options
  60. }
  61. require('rust-tools').setup(opts)
  62. vim.api.nvim_exec(
  63. [[
  64. autocmd Filetype rust nnoremap <leader>lm <Cmd>RustExpandMacro<CR>
  65. autocmd Filetype rust nnoremap <leader>lH <Cmd>RustToggleInlayHints<CR>
  66. autocmd Filetype rust nnoremap <leader>le <Cmd>RustRunnables<CR>
  67. autocmd Filetype rust nnoremap <leader>lh <Cmd>RustHoverActions<CR>
  68. ]], true)