From 0ab499d32d9caf4b10b7e3f85d07289464060d91 Mon Sep 17 00:00:00 2001 From: "Florian RICHER (MrDev023)" Date: Thu, 18 Nov 2021 21:16:48 +0100 Subject: [PATCH] Add rust tools + fixes --- configs/nvim/lua/mappings.lua | 4 + configs/nvim/lua/plugins/init.lua | 6 +- configs/nvim/lua/plugins/nvim-rust-tools.lua | 119 +++++++++++++++++++ 3 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 configs/nvim/lua/plugins/nvim-rust-tools.lua diff --git a/configs/nvim/lua/mappings.lua b/configs/nvim/lua/mappings.lua index 0b6dad2..1d802ae 100644 --- a/configs/nvim/lua/mappings.lua +++ b/configs/nvim/lua/mappings.lua @@ -22,6 +22,7 @@ local function init() map('n', 'm', 'lua vim.lsp.buf.rename()') map('n', 'r', 'lua vim.lsp.buf.references()') map('n', 's', 'lua vim.lsp.buf.document_symbol()') + map('n', 'T', 'lua require\'lsp_extensions\'.inlay_hints()') -------------------- HlsLens ------------------------------- map('n', 'n', "execute('normal! ' . v:count1 . 'n')lua require('hlslens').start()") @@ -39,6 +40,9 @@ local function init() -- Install docs : https://github.com/jesseduffield/lazygit map('n', '', 'LazyGit') + -------------------- OTHER --------------------------------- + map('i', '', ':w') + -------------------- COMMANDS ------------------------------ cmd 'au TextYankPost * lua vim.highlight.on_yank {on_visual = false}' -- disabled in visual mode end diff --git a/configs/nvim/lua/plugins/init.lua b/configs/nvim/lua/plugins/init.lua index 1867b09..3cc4a60 100644 --- a/configs/nvim/lua/plugins/init.lua +++ b/configs/nvim/lua/plugins/init.lua @@ -1,6 +1,7 @@ function configure_packages() call_with_helpers(require('plugins.lspconfig').init) call_with_helpers(require('plugins.compe').init) + call_with_helpers(require('plugins.nvim-rust-tools').init) call_with_helpers(require('plugins.nvim-tree').init) call_with_helpers(require('plugins.nvim-treesitter').init) call_with_helpers(require('plugins.nvim-web-devicons').init) @@ -30,7 +31,8 @@ function install_packages() use 'neovim/nvim-lspconfig' use 'onsails/lspkind-nvim' use 'kabouzeid/nvim-lspinstall' - + use 'simrat39/rust-tools.nvim' + -- Autocomplete use 'hrsh7th/nvim-compe' use 'SirVer/ultisnips' @@ -118,7 +120,7 @@ function install_packages() use 'ludovicchabant/vim-gutentags' -- General Plugins - use 'github/copilot' -- Copilot is a vim plugin that helps you to create your own vim plugins. + use 'github/copilot.vim' -- Copilot is a vim plugin that helps you to create your own vim plugins. use 'rcarriga/nvim-notify' -- fancy notification use 'mfussenegger/nvim-dap' -- debugger use 'numtostr/FTerm.nvim' -- Floating terminal diff --git a/configs/nvim/lua/plugins/nvim-rust-tools.lua b/configs/nvim/lua/plugins/nvim-rust-tools.lua new file mode 100644 index 0000000..76519e4 --- /dev/null +++ b/configs/nvim/lua/plugins/nvim-rust-tools.lua @@ -0,0 +1,119 @@ +local opts = { + tools = { -- rust-tools options + -- Automatically set inlay hints (type hints) + autoSetHints = true, + + -- Whether to show hover actions inside the hover window + -- This overrides the default hover handler + hover_with_actions = true, + + -- how to execute terminal commands + -- options right now: termopen / quickfix + executor = require("rust-tools/executors").termopen, + + runnables = { + -- whether to use telescope for selection menu or not + use_telescope = true + + -- rest of the opts are forwarded to telescope + }, + + debuggables = { + -- whether to use telescope for selection menu or not + use_telescope = true + + -- rest of the opts are forwarded to telescope + }, + + -- These apply to the default RustSetInlayHints command + inlay_hints = { + + -- Only show inlay hints for the current line + only_current_line = false, + + -- Event which triggers a refersh of the inlay hints. + -- You can make this "CursorMoved" or "CursorMoved,CursorMovedI" but + -- not that this may cause higher CPU usage. + -- This option is only respected when only_current_line and + -- autoSetHints both are true. + only_current_line_autocmd = "CursorHold", + + -- wheter to show parameter hints with the inlay hints or not + show_parameter_hints = true, + + -- prefix for parameter hints + parameter_hints_prefix = "<- ", + + -- prefix for all the other hints (type, chaining) + other_hints_prefix = "=> ", + + -- whether to align to the length 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, + + -- The color of the hints + highlight = "Comment", + }, + + 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"} + }, + + -- whether the hover action window gets automatically focused + auto_focus = false + }, + + -- settings for showing the crate graph based on graphviz and the dot + -- command + crate_graph = { + -- Backend used for displaying the graph + -- see: https://graphviz.org/docs/outputs/ + -- default: x11 + backend = "x11", + -- where to store the output, nil for no output stored (relative + -- path from pwd) + -- default: nil + output = nil, + -- true for all crates.io and external crates, false only the local + -- crates + -- default: true + full = true, + } + }, + + -- 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/doc/server_configurations.md#rust_analyzer + server = {}, -- rust-analyer options + + -- debugging stuff + dap = { + adapter = { + type = 'executable', + command = 'lldb-vscode', + name = "rt_lldb" + } + } +} + +local function init() + require('rust-tools').setup(opts) +end + +return { + init = init +} \ No newline at end of file