nvim: plugins: Drop rust-tools & use lsp-inlayhints
We do not use any of the other features provided by rust-tools and only ever needed the inlay hints. Now that there is a plugin for that which also allows us to use inlay hints for other languages use that. There are two options https://github.com/lvimuser/lsp-inlayhints.nvim https://github.com/simrat39/inlay-hints.nvim The second one is from the rust-tools author himself but we could not get that to work.
This commit is contained in:
parent
eecc7b4021
commit
490fe4e853
3 changed files with 49 additions and 48 deletions
|
@ -1,18 +1,6 @@
|
|||
compiler cargo
|
||||
setlocal makeprg=cargo\ build\ --all
|
||||
|
||||
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> cbb :Dispatch! cargo build<CR>
|
||||
nnoremap <buffer> cbc :Dispatch! cargo clean<CR>
|
||||
nnoremap <buffer> cbd :Dispatch! cargo doc<CR>
|
||||
|
|
|
@ -2,6 +2,14 @@ local nvim_lsp = require 'lspconfig'
|
|||
local protocol = require 'vim.lsp.protocol'
|
||||
local util = require 'lspconfig/util'
|
||||
local lightbulb = require 'nvim-lightbulb'
|
||||
local inlay_hint = require 'lsp-inlayhints'
|
||||
|
||||
-- Set up inlay hints
|
||||
inlay_hint.setup({
|
||||
inlay_hints = {
|
||||
highlight = "Hint"
|
||||
}
|
||||
})
|
||||
|
||||
-- https://github.com/neovim/nvim-lspconfig/wiki/User-contributed-tips
|
||||
function FormatRangeOperator()
|
||||
|
@ -147,6 +155,8 @@ local on_attach = function(client, bufnr)
|
|||
})
|
||||
end
|
||||
end
|
||||
|
||||
inlay_hint.on_attach(bufnr, client)
|
||||
end
|
||||
|
||||
local on_init = function(client)
|
||||
|
@ -162,40 +172,6 @@ capabilities.textDocument.completion.completionItem.resolveSupport = {
|
|||
properties = { 'documentation', 'detail', 'additionalTextEdits', }
|
||||
}
|
||||
|
||||
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 = "=> ",
|
||||
highlight = "Hint",
|
||||
},
|
||||
hover_actions = {
|
||||
auto_focus = true
|
||||
},
|
||||
},
|
||||
server = {
|
||||
on_init = on_init,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
checkOnSave = {
|
||||
command = "clippy"
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
require('rust-tools').setup(rust_tool_opts)
|
||||
|
||||
local servers = {
|
||||
clangd = {
|
||||
default_config = {
|
||||
|
@ -227,7 +203,44 @@ local servers = {
|
|||
},
|
||||
},
|
||||
},
|
||||
tsserver = {},
|
||||
rust_analyzer = {
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
procMacro = {
|
||||
enable = true
|
||||
},
|
||||
checkOnSave = {
|
||||
command = "clippy"
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
tsserver = {
|
||||
settings = {
|
||||
typescript = {
|
||||
inlayHints = {
|
||||
includeInlayParameterNameHints = 'all',
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||
includeInlayFunctionParameterTypeHints = true,
|
||||
includeInlayVariableTypeHints = true,
|
||||
includeInlayPropertyDeclarationTypeHints = true,
|
||||
includeInlayFunctionLikeReturnTypeHints = true,
|
||||
includeInlayEnumMemberValueHints = true,
|
||||
}
|
||||
},
|
||||
javascript = {
|
||||
inlayHints = {
|
||||
includeInlayParameterNameHints = 'all',
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||
includeInlayFunctionParameterTypeHints = true,
|
||||
includeInlayVariableTypeHints = true,
|
||||
includeInlayPropertyDeclarationTypeHints = true,
|
||||
includeInlayFunctionLikeReturnTypeHints = true,
|
||||
includeInlayEnumMemberValueHints = true,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
for client, config in pairs(servers) do
|
||||
|
|
|
@ -69,7 +69,7 @@ local init = function ()
|
|||
}
|
||||
-- Language support & syntax highlighting
|
||||
use 'mfussenegger/nvim-lint'
|
||||
use 'simrat39/rust-tools.nvim'
|
||||
use 'lvimuser/lsp-inlayhints.nvim'
|
||||
-- treesitter based syntax highlighting
|
||||
use {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
|
|
Loading…
Reference in a new issue