Skip to content

Commit

Permalink
feat(rust-tools): added rust-tools
Browse files Browse the repository at this point in the history
Nice inline hints and run tests helper.
  • Loading branch information
realeinherjar committed Sep 6, 2023
1 parent 250ce3c commit faaab99
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -535,17 +535,55 @@ require("lazy").setup({
loadOutDirsFromCheck = true,
runBuildScripts = true,
},
checkOnSave = true,
-- Add clippy lints for Rust
checkOnSave = {
check = {
allFeatures = true,
command = "clippy",
extraArgs = { "--no-deps" },
},
imports = {
granularity = {
enforce = true,
group = "one",
},
},
},
},
})
end,
},
{
"simrat39/rust-tools.nvim",
event = { "BufReadPre", "BufNewFile" },
lazy = true,
opts = {
on_initialized = function()
vim.cmd([[
augroup RustLSP
autocmd CursorHold *.rs silent! lua vim.lsp.buf.document_highlight()
autocmd CursorMoved,InsertEnter *.rs silent! lua vim.lsp.buf.clear_references()
autocmd BufEnter,CursorHold,InsertLeave *.rs silent! lua vim.lsp.codelens.refresh()
augroup END
]])
end,
},
config = function()
local rt = require("rust-tools")
rt.setup({
server = {
on_attach = function(_, bufnr)
-- Hover actions
vim.keymap.set("n", "K", "<CMD>RustHoverActions<CR>", { buffer = bufnr, desc = "Hover Documentation" })
-- Code action groups
vim.keymap.set("n", "<leader>ca", "<CMD>RustCodeAction<CR>", { buffer = bufnr, desc = "Code [A]ction" })
-- Run tests
vim.keymap.set("n", "<leader>ct", "<CMD>RustRunnables<CR>", { buffer = bufnr, desc = "[T]est" })
end,
},
})
end,
},
-- LSP Formatters and Linters
-- null-ls is archived
{
Expand Down

0 comments on commit faaab99

Please sign in to comment.