From c82b90244d441ee4a4c7cb77a64bf3f2c542b290 Mon Sep 17 00:00:00 2001 From: Jeremy Kaplan Date: Fri, 27 May 2022 20:40:16 +0100 Subject: [PATCH] neovim: Rust inlay hints with rust-tools --- neovim/init.vim | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/neovim/init.vim b/neovim/init.vim index c86c18e..c1aff9d 100644 --- a/neovim/init.vim +++ b/neovim/init.vim @@ -39,6 +39,7 @@ Plug 'qpkorr/vim-bufkill' Plug 'rust-lang/rust.vim' Plug 'saadparwaiz1/cmp_luasnip' Plug 'scrooloose/nerdtree' +Plug 'simrat39/rust-tools.nvim' Plug 'sirtaj/vim-openscad' Plug 'tpope/vim-abolish' Plug 'tpope/vim-bundler' @@ -387,13 +388,40 @@ local lsp_settings = { } for _, server in ipairs(lsp_installer.get_installed_servers()) do + -- rust-analyzer will be configured by rust-tools. + if server.name == 'rust_analyzer' then goto continue end + nvim_lsp[server.name].setup { on_attach = on_attach, settings = lsp_settings[server.name], capabilities = capabilities, } + ::continue:: end +require('rust-tools').setup({ + tools = { + autoSetHints = true, + hover_with_actions = false, + inlay_hints = { + only_current_line = true, + -- Parameter hints are more annoying than useful here. Neovim can't show + -- virtual text in the middle of the line like other editors do. It would + -- mess with grid-based motion anyway. + show_parameter_hints = false, + parameter_hints_prefix = "", + other_hints_prefix = "//", + }, + }, + + server = { + standalone = false, + capabilities = capabilities, + on_attach = on_attach, + settings = lsp_settings.rust_analyzer, + }, +}) + local luasnip = require 'luasnip' local cmp = require 'cmp'