mirror of
https://github.com/DefectingCat/nvim
synced 2025-07-15 16:51:33 +00:00
add rust
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||
"codesnap.nvim": { "branch": "main", "commit": "c2924bf6c9a2c2c03318fae9b7fe0706412b9d9c" },
|
||||
"conform.nvim": { "branch": "master", "commit": "0ebe875d9c306f5fc829db38492ffff2a70d8e9d" },
|
||||
"crates.nvim": { "branch": "main", "commit": "b3b9ac6ed9618955b24bf9adede7530ef608495b" },
|
||||
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
|
||||
"dressing.nvim": { "branch": "master", "commit": "c5775a888adbc50652cb370073fcfec963eca93e" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" },
|
||||
@ -38,6 +39,7 @@
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "9793801f974bba70e4ac5d7eae6c4f5659993d8e" },
|
||||
"oil.nvim": { "branch": "master", "commit": "1fe476daf0b3c108cb8ee1fc1226cc282fa2c9c1" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" },
|
||||
"rustaceanvim": { "branch": "master", "commit": "047f9c9d8cd2861745eb9de6c1570ee0875aa795" },
|
||||
"schemastore.nvim": { "branch": "main", "commit": "b546852f7a477276805b01f84ac79c28a962c55b" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
|
||||
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
|
||||
|
62
lua/rua/config/rust-analyzer.lua
Normal file
62
lua/rua/config/rust-analyzer.lua
Normal file
@ -0,0 +1,62 @@
|
||||
local cmp_nvim_lsp = require("cmp_nvim_lsp")
|
||||
local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||
|
||||
local M = {
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
standalone = true,
|
||||
checkOnSave = {
|
||||
command = "clippy",
|
||||
},
|
||||
cargo = {
|
||||
allFeatures = true,
|
||||
loadOutDirsFromCheck = true,
|
||||
buildScripts = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
files = {
|
||||
excludeDirs = {
|
||||
".flatpak-builder",
|
||||
"_build",
|
||||
".dart_tool",
|
||||
".flatpak-builder",
|
||||
".git",
|
||||
".gitlab",
|
||||
".gitlab-ci",
|
||||
".gradle",
|
||||
".idea",
|
||||
".next",
|
||||
".project",
|
||||
".scannerwork",
|
||||
".settings",
|
||||
".venv",
|
||||
"archetype-resources",
|
||||
"bin",
|
||||
"docs",
|
||||
"hooks",
|
||||
"node_modules",
|
||||
"po",
|
||||
"screenshots",
|
||||
"target",
|
||||
"out",
|
||||
"examples/node_modules",
|
||||
"../out",
|
||||
"../node_modules",
|
||||
"../.next",
|
||||
},
|
||||
},
|
||||
},
|
||||
procMacro = {
|
||||
enable = true,
|
||||
ignored = {
|
||||
["async-trait"] = { "async_trait" },
|
||||
["napi-derive"] = { "napi" },
|
||||
["async-recursion"] = { "async_recursion" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
@ -1,12 +1,11 @@
|
||||
return {
|
||||
{ "b0o/schemastore.nvim", lazy = true }, -- json schema store
|
||||
{ "b0o/schemastore.nvim" }, -- json schema store
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
{ "hrsh7th/cmp-nvim-lsp", lazy = true },
|
||||
{ "antosha417/nvim-lsp-file-operations", config = true, lazy = true },
|
||||
{ "folke/neodev.nvim", opts = {}, lazy = true },
|
||||
{ "hrsh7th/cmp-nvim-lsp" },
|
||||
{ "antosha417/nvim-lsp-file-operations", config = true },
|
||||
{ "folke/neodev.nvim", opts = {} },
|
||||
},
|
||||
opts = { document_highlight = { enabled = false } },
|
||||
config = function()
|
||||
@ -77,6 +76,26 @@ return {
|
||||
capabilities = capabilities,
|
||||
})
|
||||
end,
|
||||
["rust_analyzer"] = function()
|
||||
-- lspconfig["rust_analyzer"].setup(require("rua.config.rust-analyzer"))
|
||||
end,
|
||||
["taplo"] = function()
|
||||
lspconfig["taplo"].setup({
|
||||
keys = {
|
||||
{
|
||||
"gh",
|
||||
function()
|
||||
if vim.fn.expand("%:t") == "Cargo.toml" and require("crates").popup_available() then
|
||||
require("crates").show_popup()
|
||||
else
|
||||
vim.lsp.buf.hover()
|
||||
end
|
||||
end,
|
||||
desc = "Show Crate Documentation",
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
["vtsls"] = function()
|
||||
lspconfig["vtsls"].setup(require("rua.config.vtsls"))
|
||||
map("n", "<leader>co", "<cmd> OrganizeImports <CR>", { desc = "Organize imports" })
|
||||
|
79
lua/rua/plugins/rust.lua
Normal file
79
lua/rua/plugins/rust.lua
Normal file
@ -0,0 +1,79 @@
|
||||
return {
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
{
|
||||
"Saecki/crates.nvim",
|
||||
event = { "BufRead Cargo.toml" },
|
||||
opts = {
|
||||
completion = {
|
||||
cmp = { enabled = true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
---@param opts cmp.ConfigSchema
|
||||
opts = function(_, opts)
|
||||
opts.sources = opts.sources or {}
|
||||
table.insert(opts.sources, { name = "crates" })
|
||||
end,
|
||||
},
|
||||
{
|
||||
"Saecki/crates.nvim",
|
||||
event = { "BufRead Cargo.toml" },
|
||||
opts = {
|
||||
completion = {
|
||||
cmp = { enabled = true },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"mrcjkb/rustaceanvim",
|
||||
version = "^4", -- Recommended
|
||||
ft = { "rust" },
|
||||
opts = {
|
||||
server = {
|
||||
on_attach = function(_, bufnr)
|
||||
vim.keymap.set("n", "<leader>ca", function()
|
||||
vim.cmd.RustLsp("codeAction")
|
||||
end, { desc = "Code Action", buffer = bufnr })
|
||||
vim.keymap.set("n", "<leader>dr", function()
|
||||
vim.cmd.RustLsp("debuggables")
|
||||
end, { desc = "Rust Debuggables", buffer = bufnr })
|
||||
end,
|
||||
default_settings = {
|
||||
-- rust-analyzer language server configuration
|
||||
["rust-analyzer"] = {
|
||||
cargo = {
|
||||
allFeatures = true,
|
||||
loadOutDirsFromCheck = true,
|
||||
buildScripts = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
-- Add clippy lints for Rust.
|
||||
checkOnSave = true,
|
||||
procMacro = {
|
||||
enable = true,
|
||||
ignored = {
|
||||
["async-trait"] = { "async_trait" },
|
||||
["napi-derive"] = { "napi" },
|
||||
["async-recursion"] = { "async_recursion" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
vim.g.rustaceanvim = vim.tbl_deep_extend("keep", vim.g.rustaceanvim or {}, opts or {})
|
||||
if vim.fn.executable("rust-analyzer") == 0 then
|
||||
print("**rust-analyzer** not found in PATH, please install it.\nhttps://rust-analyzer.github.io/")
|
||||
-- LazyVim.error(
|
||||
-- "**rust-analyzer** not found in PATH, please install it.\nhttps://rust-analyzer.github.io/",
|
||||
-- { title = "rustaceanvim" }
|
||||
-- )
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
@ -31,9 +31,6 @@ return {
|
||||
},
|
||||
{
|
||||
"mg979/vim-visual-multi",
|
||||
keys = {
|
||||
{ "<C-n>", desc = "vim visual multi" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"mistricky/codesnap.nvim",
|
||||
|
Reference in New Issue
Block a user