feat: use rustaceanvim ratheer than rust-tools

also inlay hint fixes
This commit is contained in:
əlemi 2024-05-31 18:09:45 +02:00
parent 188bb40227
commit f5bd91045d
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 17 additions and 28 deletions

View file

@ -161,6 +161,7 @@ require('lazy').setup(PLUGINS)
--|| THEME --|| THEME
vim.cmd("colorscheme peak") -- TODO can I do it in lua? vim.cmd("colorscheme peak") -- TODO can I do it in lua?
vim.lsp.inlay_hint.enable(true) -- default on
--|| UTILITY --|| UTILITY
function P(something) print(vim.inspect(something)) end function P(something) print(vim.inspect(something)) end

View file

@ -45,7 +45,7 @@ function KEYBINDS:set_global_keys(opts)
vim.keymap.set('n', '<C-t>', ':Neotree toggle<CR>', {noremap=true}) vim.keymap.set('n', '<C-t>', ':Neotree toggle<CR>', {noremap=true})
vim.keymap.set('n', '<C-S-t>', ':Neotree toggle source=symbolmap right<CR>', {noremap=true}) vim.keymap.set('n', '<C-S-t>', ':Neotree toggle source=symbolmap right<CR>', {noremap=true})
vim.keymap.set('n', '<C-PageUp>', ':Neotree toggle source=diagnostics bottom<CR>', opts) vim.keymap.set('n', '<C-PageUp>', ':Neotree toggle source=diagnostics bottom<CR>', opts)
vim.keymap.set('n', '<C-h>', vim.cmd.UndotreeToggle, {noremap=true}) -- vim.keymap.set('n', '<C-h>', vim.cmd.UndotreeToggle, {noremap=true})
-- Esc goes back to normal mode in terminal -- Esc goes back to normal mode in terminal
vim.keymap.set('t', '<ESC>', '<C-\\><C-n>', opts) vim.keymap.set('t', '<ESC>', '<C-\\><C-n>', opts)
@ -80,12 +80,13 @@ function KEYBINDS:set_lsp_keys(opts)
vim.keymap.set('n', '<leader>D', vim.lsp.buf.declaration, opts) vim.keymap.set('n', '<leader>D', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', '<leader>d', vim.lsp.buf.definition, opts) vim.keymap.set('n', '<leader>d', vim.lsp.buf.definition, opts)
vim.keymap.set('n', '<leader>y', vim.lsp.buf.type_definition, opts) vim.keymap.set('n', '<leader>y', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<leader>i', vim.lsp.buf.implementation, opts) vim.keymap.set('n', '<leader>R', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<leader>r', vim.lsp.buf.references, opts) vim.keymap.set('n', '<leader>r', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<leader>h', vim.lsp.buf.hover, opts) vim.keymap.set('n', '<leader>h', vim.lsp.buf.hover, opts)
vim.keymap.set('n', '<leader>f', vim.lsp.buf.signature_help, opts) vim.keymap.set('n', '<leader>f', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<C-Space>', vim.lsp.buf.hover, opts) vim.keymap.set('n', '<C-Space>', vim.lsp.buf.hover, opts)
vim.keymap.set('n', '<C-x>', vim.lsp.buf.hover, opts) vim.keymap.set('n', '<C-x>', vim.lsp.buf.hover, opts)
vim.keymap.set('n', '<leader>H', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end)
-- vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts) -- vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
-- vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts) -- vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<M-r>', vim.lsp.buf.rename, opts) vim.keymap.set('n', '<M-r>', vim.lsp.buf.rename, opts)
@ -93,6 +94,7 @@ function KEYBINDS:set_lsp_keys(opts)
vim.keymap.set('n', '<leader><Del>', vim.diagnostic.open_float, opts) vim.keymap.set('n', '<leader><Del>', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '<C-Del>', vim.diagnostic.open_float, opts) vim.keymap.set('n', '<C-Del>', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '<M-x>', vim.diagnostic.open_float, opts) -- fallback for windows vim.keymap.set('n', '<M-x>', vim.diagnostic.open_float, opts) -- fallback for windows
vim.keymap.set('n', '<C-h>', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end)
-- It's not really a keybind but whatever -- It's not really a keybind but whatever
vim.api.nvim_create_user_command( vim.api.nvim_create_user_command(
'Format', 'Format',

View file

@ -15,10 +15,10 @@
PPPPPPPPPPPPGBPG&&& &&&&&&###BBBGGGGGGGBB##&& - pickers: telescope.nvim PPPPPPPPPPPPGBPG&&& &&&&&&###BBBGGGGGGGBB##&& - pickers: telescope.nvim
&BGPPPPPPPPPPPPPPGGGGGGGGGGGGGGGGGGGBBB##&&& - files: neo-tree.nvim &BGPPPPPPPPPPPPPPGGGGGGGGGGGGGGGGGGGBBB##&&& - files: neo-tree.nvim
&&##BBBBGGGGGGGPGBBBBBB####&&&& - git: vim-fugitive + gitsigns.nvim &&##BBBBGGGGGGGPGBBBBBB####&&&& - git: vim-fugitive + gitsigns.nvim
&#B#& - extra: hexmode, vim-combo, &#B#& - extra: hexmode, vim-surround,
&& ###& rust-tools, nvim-colorizer, && ###& undotree, nvim-colorizer,
&G# &&#&&& nvim-jdtls, vim-surround, &G# &&#&&& nvim-jdtls, rustaceanvim,
&&& undotree, &&& vim-combo,
]]-- ]]--
local function set_lsp_binds(_, bufnr) local function set_lsp_binds(_, bufnr)
@ -156,32 +156,18 @@ return {
}, },
{ {
'simrat39/rust-tools.nvim', -- extra LSP defaults for rust
dependencies = {
'hrsh7th/nvim-cmp', -- referenced here to guarantee load order
},
config = function () config = function ()
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) {
local rust_tools = require("rust-tools") 'mrcjkb/rustaceanvim',
rust_tools.setup({ init = function ()
tools = { vim.g.rustaceanvim = {
inlay_hints = { auto = true, highlight = "InlayHint" },
hover_actions = { border = "none" },
},
server = { server = {
capabilities = capabilities, capabilites = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()),
on_attach = set_lsp_binds, on_attach = set_lsp_binds,
settings = {
['rust-analyzer'] = {
checkOnSave = { command = "clippy" },
}
}
}, },
dap = { adapter = require('dap').adapters.lldb }, }
}) end,
rust_tools.inlay_hints.enable() lazy = false,
end
}, },
{ {