setup a small rust environment

This commit is contained in:
antifallobst 2023-08-23 16:59:36 +02:00
parent f3b9a3c9a9
commit b97577b370
Signed by: antifallobst
GPG Key ID: 2B4F402172791BAF
6 changed files with 115 additions and 0 deletions

6
lua/custom/chadrc.lua Normal file
View File

@ -0,0 +1,6 @@
---@type ChadrcConfig
local M = {}
M.ui = {theme = 'gatekeeper'}
M.plugins = 'custom.plugins'
M.mappings = require "custom.mappings"
return M

View File

@ -0,0 +1,6 @@
local on_attach = require("plugins.configs.lspconfig").on_attach
local capabilities = require("plugins.configs.lspconfig").capabilities
local lspconfig = require("lspconfig")
local util = require "lspconfig/util"

View File

@ -0,0 +1,10 @@
local on_attach = require("plugins.configs.lspconfig").on_attach
local capabilities = require("plugins.configs.lspconfig").capabilities
local options = {
server = {
on_attach = on_attach,
capabilities = capabilities,
}
}
return options

6
lua/custom/init.lua Normal file
View File

@ -0,0 +1,6 @@
vim.opt.colorcolumn = "180"
vim.opt.expandtab = true
vim.opt.tabstop = 4
vim.opt.softtabstop = 0
vim.opt.shiftwidth = 0

30
lua/custom/mappings.lua Normal file
View File

@ -0,0 +1,30 @@
local M = {}
M.dap = {
n = {
["<leader>db"] = {
"<cmd> DapToggleBreakpoint <CR>",
"Toggle Breakpoint"
},
["<leader>dus"] = {
function ()
local widgets = require("dap.ui.widgets");
local sidebar = widgets.sidebar(widgets.scopes);
sidebar.open();
end,
"Open debugging sidebar"
},
["<leader>dc"] = {
"<cmd> DapContinue <CR>",
"Continue debugging"
},
["<leader>rcu"] = {
function ()
require("crates").upgrade_all_crates()
end,
"Update all rust crates"
}
}
}
return M

57
lua/custom/plugins.lua Normal file
View File

@ -0,0 +1,57 @@
local plugins = {
{
"neovim/nvim-lspconfig",
config = function()
require "plugins.configs.lspconfig"
require "custom.configs.lspconfig"
end
},
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
"lua-language-server",
"rust-analyzer"
}
}
},
{
"rust-lang/rust.vim",
ft = "rust",
init = function ()
vim.g.rustfmt_autosave = 1
end
},
{
"simrat39/rust-tools.nvim",
ft = "rust",
dependencies = "neovim/nvim-lspconfig",
opts = function ()
return require "custom.configs.rust-tools"
end,
config = function (_, opts)
require("rust-tools").setup(opts)
end
},
{
"mfussenegger/nvim-dap"
},
{
"saecki/crates.nvim",
ft = {"rust", "toml"},
config = function (_, opts)
local crates = require("crates")
crates.setup(opts)
crates.show()
end
},
{
"hrsh7th/nvim-cmp",
opts = function ()
local M = require "plugins.configs.cmp",
table.insert(M.sources, {name = "crates"})
return M
end
}
}
return plugins