[fix] Update plugins and use inlayHints from nvim 0.10

This commit is contained in:
Uttarayan Mondal
2024-01-12 12:11:38 +05:30
parent 2fb460549d
commit 15121db53c
8 changed files with 115 additions and 271 deletions

View File

@@ -41,3 +41,4 @@ vim.cmd('hi NormalNC guibg=' .. colors.black)
vim.cmd('hi EndOfBuffer guibg=' .. colors.black)
-- vim.cmd('hi ToggleTerm1Buffer guibg='..colors.black)
vim.cmd('hi NonText guibg=' .. colors.black)
vim.cmd('hi LspInlayHint guifg=' .. colors.bg4)

View File

@@ -47,7 +47,7 @@ local normal_mode_maps = {
{ key = '<leader>fh', map = [[<cmd>lua require('telescope.builtin').help_tags()<cr>]] },
{ key = '<leader>gB', map = [[<cmd>Git blame<cr>]] },
{ key = '<leader>rd', map = [[<cmd>RustDebuggables<cr>]] },
{ key = '<leader>rr', map = [[<cmd>RustRunnables<cr>]] },
-- { key = '<leader>rr', map = vim.cmd.RustLsp('runnables') },
{ key = 'vff', map = [[<cmd>vertical Gdiffsplit<cr>]] },
-- { key = 'vff!', map = [[<cmd>vertical Gdiffsplit!<cr>]] },
-- { key = 'ssr', map = [[<cmd>lua require'rust-tools'.ssr.ssr(query)<cr>]] },

View File

@@ -6,12 +6,16 @@ local capabilities = cmp_nvim_lsp.default_capabilities()
require("mason-lspconfig").setup_handlers {
function(server_name) -- default handler (optional)
lspconfig[server_name].setup {
on_attach = lspstatus.on_attach,
on_attach = function(client, bufnr)
if client.server_capabilities.inlayHintProvider then
vim.lsp.inlay_hint.enable(bufnr, true)
end
lspstatus.on_attach(client, bufnr)
end,
capabilities = capabilities,
}
end,
["rust_analyzer"] = function()
-- require 'lazy'.load('rust-tools');
vim.cmd([[autocmd BufEnter *.rs lua require("setup.rtools")]])
end,
["clangd"] = function()

View File

@@ -45,7 +45,7 @@ return require('lazy').setup({
{ 'rest-nvim/rest.nvim', event = "BufEnter" },
-- 'b0o/SchemaStore.nvim',
-- 'rcarriga/nvim-notify',
{ 'echasnovski/mini.nvim', version = '*' },
{ 'echasnovski/mini.nvim', version = '*' },
{
'folke/todo-comments.nvim',
event = "BufEnter",
@@ -197,16 +197,19 @@ return require('lazy').setup({
{ 'norcalli/nvim-colorizer.lua', config = function() require 'colorizer'.setup() end },
{
'IndianBoy42/tree-sitter-just',
config = function() require 'tree-sitter-just'.setup({}) end,
dependencies = {
"nvim-treesitter/nvim-treesitter" },
config = function()
require 'tree-sitter-just'.setup({})
end,
dependencies = { "nvim-treesitter/nvim-treesitter" },
ft = "just"
},
{
'LhKipp/nvim-nu',
config = function() require 'nu'.setup({
use_lsp_features = false,
}) end,
config = function()
require 'nu'.setup({
use_lsp_features = false,
})
end,
ft = "nu"
},
-- lsp
@@ -432,9 +435,17 @@ return require('lazy').setup({
-- }
-- end,
-- },
-- {
-- 'simrat39/rust-tools.nvim',
-- ft = 'rust',
-- config = function()
-- require 'setup.rtools'
-- end,
-- },
{
'simrat39/rust-tools.nvim',
ft = 'rust',
'mrcjkb/rustaceanvim',
version = '^3', -- Recommended
ft = { 'rust' },
config = function()
require 'setup.rtools'
end,

View File

@@ -4,247 +4,64 @@
-- local liblldb_path = extension_path .. 'lldb/lib/liblldb.dylib'
local codelldb_path = '/Users/fs0c131y/.vscode-oss/extensions/vadimcn.vscode-lldb-1.8.1-universal/adapter/codelldb'
local liblldb_path = '/Users/fs0c131y/.vscode-oss/extensions/vadimcn.vscode-lldb-1.8.1-universal/lldb/lib/liblldb.dylib'
local rt = require('rust-tools')
local lspstatus = require('lsp-status')
-- local lsp_signature = require('lsp_signature')
local opts = {
tools = { -- rust-tools options
-- automatically set inlay hints (type hints)
-- There is an issue due to which the hints are not applied on the first
-- opened file. For now, write to the file to trigger a reapplication of
-- the hints or just run :RustSetInlayHints.
-- default: true
autoSetHints = true,
-- whether to show hover actions inside the hover window
-- this overrides the default hover handler so something like lspsaga.nvim's hover would be overriden by this
-- default: true
-- hover_with_actions = true,
-- how to execute terminal commands
-- options right now: termopen / quickfix
executor = require("rust-tools/executors").termopen,
-- callback to execute once rust-analyzer is done initializing the workspace
-- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error"
on_initialized = nil,
-- 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",
-- whether to show parameter hints with the inlay hints or not
-- default: true
show_parameter_hints = true,
-- whether to show variable name before type hints with the inlay hints or not
-- default: false
show_variable_name = false,
-- prefix for parameter hints
-- default: "<-"
parameter_hints_prefix = "<- ",
-- prefix for all the other hints (type, chaining)
-- default: "=>"
other_hints_prefix = "=> ",
-- whether to align to the lenght 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",
},
-- options same as lsp hover / vim.lsp.util.open_floating_preview()
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
-- default: false
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,
-- List of backends found on: https://graphviz.org/docs/outputs/
-- Is used for input validation and autocompletion
-- Last updated: 2021-08-26
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",
},
},
},
-- 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 = {
-- standalone file support
-- setting it to false may improve startup time
-- cmd = { "ra-multiplex" },
standalone = true,
settings = {
["rust-analyzer"] = {
imports = {
enforce = true,
prefix = "self",
granularity = {
group = "module",
},
importPrefix = "self",
prefer = {
no = {
std = true
},
}
},
check = {
},
inlayHints = {
closureReturnTypeHints = {
enable = true,
}
},
cargo = {
loadOutDirsFromCheck = true,
},
procMacro = {
enable = true,
},
completion = {
autoimport = {
enalbe = true,
}
},
checkOnSave = {
command = "clippy",
-- targets = "all",
allTargets = true,
},
},
},
on_attach = function(client, bufnr)
-- Hover actions
vim.keymap.set("n", "<S-K>", rt.hover_actions.hover_actions, { buffer = bufnr })
-- Code action groups
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
-- lsp_signature.on_attach(client, bufnr)
lspstatus.on_attach(client)
end,
-- capabilities = lspstatus.capabilities,
capabilities = require('cmp_nvim_lsp').default_capabilities(),
}, -- rust-analyer options
-- debugging stuff
dap = {
-- adapter = {
-- type = "executable",
-- command = "lldb-vscode",
-- name = "rt_lldb",
-- },
adapter = require('rust-tools.dap').get_codelldb_adapter(
codelldb_path, liblldb_path)
},
}
-- vim.cmd([[autocmd BufEnter,BufWinEnter,TabEnter *.rs :lua require('rust-tools.inlay_hints').set_inlay_hints()]])
require('rust-tools').setup(opts)
-- require('rust-tools').setup(opts)
local bufnr = vim.api.nvim_get_current_buf()
vim.keymap.set(
"n",
"<leader>a",
function()
vim.cmd.RustLsp('codeAction')
end,
{ silent = true, buffer = bufnr }
)
vim.keymap.set(
"n",
"<leader>rr",
function()
vim.cmd.RustLsp('runnables')
end,
{ silent = true, buffer = bufnr }
)
vim.keymap.set(
"n",
"<leader>rd",
function()
vim.cmd.RustLsp('debuggables')
end,
{ silent = true, buffer = bufnr }
)
vim.keymap.set(
"n",
"ssr",
function()
vim.cmd.RustLsp('ssr')
end,
{ buffer = bufnr }
)
vim.g.rustaceanvim = {
-- Plugin configuration
-- tools = {},
-- LSP configuration
server = {
on_attach = function(client, bufnr)
-- you can also put keymaps in here
if client.server_capabilities.inlayHintProvider then
print("Inlay hints enabled")
vim.lsp.inlay_hint.enable(bufnr, true)
end
end,
-- settings = {
-- -- rust-analyzer language server configuration
-- ["rust-analyzer"] = {},
-- },
-- },
-- -- DAP configuration
-- dap = {},
},
}