nvim: lsp: Enable rust-tools for inlay hints
This commit is contained in:
parent
0aa93c6e9b
commit
00670a867f
3 changed files with 53 additions and 1 deletions
12
nvim/.config/nvim/after/ftplugin/rust.vim
Normal file
12
nvim/.config/nvim/after/ftplugin/rust.vim
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
nnoremap <buffer> <Leader>rD :RustDisableInlayHints<CR>
|
||||||
|
nnoremap <buffer> <Leader>rt :RustToggleInlayHints<CR>
|
||||||
|
nnoremap <buffer> <Leader>rr :RustRunnables<CR>
|
||||||
|
nnoremap <buffer> <Leader>rm :RustExpandMacro<CR>
|
||||||
|
nnoremap <buffer> <Leader>rc :RustOpenCargo<CR>
|
||||||
|
nnoremap <buffer> <Leader>rp :RustParentModule<CR>
|
||||||
|
nnoremap <buffer> <Leader>rj :RustJoinLines<CR>
|
||||||
|
nnoremap <buffer> <Leader>rh :RustHoverActions<CR>
|
||||||
|
nnoremap <buffer> <Leader>rd :RustMoveItemDown<CR>
|
||||||
|
nnoremap <buffer> <Leader>ru :RustMoveItemUp<CR>
|
||||||
|
nnoremap <buffer> <Leader>rs :RustStartStandaloneServerForBuffer<CR>
|
||||||
|
nnoremap <buffer> <Leader>rg :RustViewCrateGraph<CR>
|
|
@ -176,7 +176,7 @@ end
|
||||||
null_ls.config {}
|
null_ls.config {}
|
||||||
nvim_lsp["null-ls"].setup {}
|
nvim_lsp["null-ls"].setup {}
|
||||||
|
|
||||||
local servers = { 'hls', 'rust_analyzer', 'pylsp', 'tsserver' }
|
local servers = { 'hls', 'pylsp', 'tsserver' }
|
||||||
for _, lsp in ipairs(servers) do
|
for _, lsp in ipairs(servers) do
|
||||||
nvim_lsp[lsp].setup {
|
nvim_lsp[lsp].setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
|
@ -199,6 +199,45 @@ nvim_lsp.clangd.setup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local rust_tool_opts = {
|
||||||
|
tools = {
|
||||||
|
autoSetHints = true,
|
||||||
|
hover_with_actions = false,
|
||||||
|
runnables = { use_telescope = false },
|
||||||
|
debuggables = { use_telescope = false },
|
||||||
|
inlay_hints = {
|
||||||
|
only_current_line = false,
|
||||||
|
only_current_line_autocmd = "CursorHold",
|
||||||
|
show_parameter_hints = true,
|
||||||
|
parameter_hints_prefix = "<- ",
|
||||||
|
other_hints_prefix = "=> ",
|
||||||
|
other_hints_prefix = "",
|
||||||
|
highlight = "Hint",
|
||||||
|
},
|
||||||
|
hover_actions = {
|
||||||
|
auto_focus = true
|
||||||
|
},
|
||||||
|
crate_graph = {
|
||||||
|
backend = "svg",
|
||||||
|
output = "crates_graph.svg",
|
||||||
|
full = false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
server = {
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = set_snippet_capabilities(),
|
||||||
|
settings = {
|
||||||
|
["rust-analyzer"] = {
|
||||||
|
checkOnSave = {
|
||||||
|
command = "clippy"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
require('rust-tools').setup(rust_tool_opts)
|
||||||
|
|
||||||
-- See https://github.com/sumneko/lua-language-server/wiki/Setting-without-VSCode#neovim-with-built-in-lsp-client
|
-- See https://github.com/sumneko/lua-language-server/wiki/Setting-without-VSCode#neovim-with-built-in-lsp-client
|
||||||
-- on why we do this library thing
|
-- on why we do this library thing
|
||||||
-- Idea taken from https://gist.github.com/folke/fe5d28423ea5380929c3f7ce674c41d8
|
-- Idea taken from https://gist.github.com/folke/fe5d28423ea5380929c3f7ce674c41d8
|
||||||
|
|
|
@ -81,6 +81,7 @@ local init = function ()
|
||||||
'kosayoda/nvim-lightbulb',
|
'kosayoda/nvim-lightbulb',
|
||||||
}
|
}
|
||||||
-- Language support & syntax highlighting
|
-- Language support & syntax highlighting
|
||||||
|
use 'simrat39/rust-tools.nvim'
|
||||||
-- Coq
|
-- Coq
|
||||||
use {
|
use {
|
||||||
'whonore/Coqtail',
|
'whonore/Coqtail',
|
||||||
|
|
Loading…
Reference in a new issue