summaryrefslogtreecommitdiff
path: root/lua/lv-rust-tools/init.lua
diff options
context:
space:
mode:
authorAbouzar Parvan <[email protected]>2021-06-30 02:19:23 +0430
committerGitHub <[email protected]>2021-06-29 17:49:23 -0400
commit758798b6f9beef165cdffdbe4cc396b6d18b8f8b (patch)
treeed1e9c23380c03bde5a1bb09602010e12bf9c221 /lua/lv-rust-tools/init.lua
parentdbad645f9075e54ce1864dba978e61c478b59e64 (diff)
added rust-tools thanks to bob3000 (#544)
* added rust-tools * require_plugin has been removed
Diffstat (limited to 'lua/lv-rust-tools/init.lua')
-rw-r--r--lua/lv-rust-tools/init.lua85
1 files changed, 85 insertions, 0 deletions
diff --git a/lua/lv-rust-tools/init.lua b/lua/lv-rust-tools/init.lua
new file mode 100644
index 00000000..c0443875
--- /dev/null
+++ b/lua/lv-rust-tools/init.lua
@@ -0,0 +1,85 @@
+local opts = {
+ tools = { -- rust-tools options
+ -- automatically set inlay hints (type hints)
+ -- There is an issue due to which the hints are not applied on the first
+ -- opened file. For now, write to the file to trigger a reapplication of
+ -- the hints or just run :RustSetInlayHints.
+ -- default: true
+ autoSetHints = true,
+
+ -- whether to show hover actions inside the hover window
+ -- this overrides the default hover handler
+ -- default: true
+ hover_with_actions = true,
+
+ runnables = {
+ -- whether to use telescope for selection menu or not
+ -- default: true
+ use_telescope = true
+
+ -- rest of the opts are forwarded to telescope
+ },
+
+ inlay_hints = {
+ -- wheter to show parameter hints with the inlay hints or not
+ -- default: true
+ show_parameter_hints = true,
+
+ -- prefix for parameter hints
+ -- default: "<-"
+ parameter_hints_prefix = "<-",
+
+ -- prefix for all the other hints (type, chaining)
+ -- default: "=>"
+ other_hints_prefix = "=>",
+
+ -- whether to align to the lenght of the longest line in the file
+ max_len_align = false,
+
+ -- padding from the left if max_len_align is true
+ max_len_align_padding = 1,
+
+ -- whether to align to the extreme right or not
+ right_align = false,
+
+ -- padding from the right if right_align is true
+ right_align_padding = 7,
+ },
+
+ hover_actions = {
+ -- the border that is used for the hover window
+ -- see vim.api.nvim_open_win()
+ border = {
+ {"â•­", "FloatBorder"},
+ {"─", "FloatBorder"},
+ {"â•®", "FloatBorder"},
+ {"│", "FloatBorder"},
+ {"╯", "FloatBorder"},
+ {"─", "FloatBorder"},
+ {"â•°", "FloatBorder"},
+ {"│", "FloatBorder"}
+ },
+ }
+ },
+
+ -- all the opts to send to nvim-lspconfig
+ -- these override the defaults set by rust-tools.nvim
+ -- see https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer
+ server = {
+ cmd = {DATA_PATH .. "/lspinstall/rust/rust-analyzer"},
+ on_attach = require'lsp'.common_on_attach
+ }, -- rust-analyser options
+}
+
+
+require('rust-tools').setup(opts)
+
+vim.api.nvim_exec(
+ [[
+ autocmd Filetype rust nnoremap <leader>lm <Cmd>RustExpandMacro<CR>
+ autocmd Filetype rust nnoremap <leader>lH <Cmd>RustToggleInlayHints<CR>
+ autocmd Filetype rust nnoremap <leader>le <Cmd>RustRunnables<CR>
+ autocmd Filetype rust nnoremap <leader>lh <Cmd>RustHoverActions<CR>
+ ]], true)
+
+