From e5d101c0b1398978d0c484a376632b57da3b2514 Mon Sep 17 00:00:00 2001 From: krolyxon Date: Wed, 7 Sep 2022 13:08:37 +0530 Subject: [PATCH] rust-tools configures --- lua/plugins/configs/lspconfig.lua | 19 ++++--- lua/plugins/configs/rust-tools.lua | 87 +++++++----------------------- lua/plugins/init.lua | 11 ++-- 3 files changed, 38 insertions(+), 79 deletions(-) diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index e9efb19..6d83c3a 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -116,11 +116,18 @@ lspconfig.sumneko_lua.setup { }, } -lspconfig.rust_analyzer.setup { - on_attach = M.on_attach, - capabilities = M.capabilities, - - settings = {}, -} +-- lspconfig.rust_analyzer.setup { +-- on_attach = M.on_attach, +-- capabilities = M.capabilities, +-- +-- settings = { +-- tools = { +-- inlay_hints = { +-- auto = true, +-- show_parameter_hints = true, +-- }, +-- }, +-- } +-- } return M diff --git a/lua/plugins/configs/rust-tools.lua b/lua/plugins/configs/rust-tools.lua index d44f762..c640fdf 100644 --- a/lua/plugins/configs/rust-tools.lua +++ b/lua/plugins/configs/rust-tools.lua @@ -3,76 +3,27 @@ if not present then return end -local options = { - tools = { - on_initialized = nil, - reload_workspace_from_cargo_toml = true, +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) - -- inlay hints - inlay_hints = { - auto = true, - only_current_line = false, - show_parameter_hints = true, - parameter_hints_prefix = "<- ", - max_len_align = false, - }, - enabled_graphviz_backends = { - "bmp", - "cgimage", - "canon", - "dot", - "gv", - "xdot", - "xdot1.2", - "xdot1.4", - "eps", - "exr", - "fig", - "gd", - "gd2", - "gif", - "gtk", - "ico", - "cmap", - "ismap", - "imap", - "cmapx", - "imap_np", - "cmapx_np", - "jpg", - "jpeg", - "jpe", - "jp2", - "json", - "json0", - "dot_json", - "xdot_json", - "pdf", - "pic", - "pct", - "pict", - "plain", - "plain-ext", - "png", - "pov", - "ps", - "ps2", - "psd", - "sgi", - "svg", - "svgz", - "tga", - "tiff", - "tif", - "tk", - "vml", - "vmlz", - "wbmp", - "webp", - "xlib", - "x11", - }, + +local options = { + tools = { + inlay_hints = { + auto = true, + only_current_line = false, + -- whether to show parameter hints with the inlay hints or not + -- default: true + show_parameter_hints = true, }, + on_initialized = function() + -- ih.set_all() + end, + }, + server = { + on_attach = function(client, bufnr) + end, + }, } rust.setup(options) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 0ff8757..0fee571 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -63,11 +63,12 @@ local plugins = { }, ["simrat39/rust-tools.nvim"] = { - ft = "rs", - config = function () - require("plugins.configs.rust-tools") - end, - }, + after = "nvim-lspconfig", + config = function () + require("plugins.configs.rust-tools") + require("core.utils").load_mappings "lspconfig" + end, + }, -- load luasnips + cmp related in insert mode only