made rust keybinds for cargo. leader c {(b)uild (r)un (n)ew}
This commit is contained in:
parent
800ae4badd
commit
50d6df2de7
@ -1,7 +1,7 @@
|
||||
---@type ChadrcConfig
|
||||
local M = {}
|
||||
|
||||
M.ui = { theme = 'melange' }
|
||||
M.ui = { theme = 'oceanic-light' }
|
||||
M.plugins = 'custom.plugins'
|
||||
M.mappings = require "custom.mappings"
|
||||
return M
|
||||
|
||||
@ -73,8 +73,17 @@ lspconfig.clangd.setup {
|
||||
filetypes = { "c", "cpp" },
|
||||
}
|
||||
|
||||
local function marksman_on_attach(client, bufnr)
|
||||
-- Call the global version first
|
||||
on_attach(client, bufnr)
|
||||
|
||||
-- Then do the Markdown-specific logic
|
||||
-- vim.api.nvim_set_option_value("spell", true, { buf = bufnr })
|
||||
-- vim.api.nvim_set_option_value("spelllang", "en_us", { buf = bufnr })
|
||||
end
|
||||
|
||||
lspconfig.marksman.setup {
|
||||
on_attach = on_attach,
|
||||
on_attach = marksman_on_attach,
|
||||
capabilities = capabilities,
|
||||
filetypes = { "markdown" },
|
||||
}
|
||||
|
||||
45
lua/custom/language_specific_commands/rust.lua
Normal file
45
lua/custom/language_specific_commands/rust.lua
Normal file
@ -0,0 +1,45 @@
|
||||
-- We modify our previously defined Cargo user command:
|
||||
vim.api.nvim_create_user_command("Cargo", function(opts)
|
||||
-- Split the entire command-line input (opts.args) by spaces.
|
||||
-- For example, if someone types :Cargo new test_project --bin
|
||||
-- the split might be {"new", "test_project", "--bin"}.
|
||||
local args = vim.split(opts.args, "%s+")
|
||||
|
||||
-- The first item is the subcommand: "run", "build", or "new".
|
||||
local subcommand = args[1]
|
||||
|
||||
if subcommand == "run" then
|
||||
vim.cmd "!cargo run"
|
||||
elseif subcommand == "build" then
|
||||
vim.cmd "!cargo build"
|
||||
elseif subcommand == "new" then
|
||||
-- Everything after 'new' is the project name plus optional flags.
|
||||
-- Let's remove 'new' from the table, then join the rest with spaces.
|
||||
table.remove(args, 1) -- remove 'new'
|
||||
local new_args = table.concat(args, " ")
|
||||
if #new_args == 0 then
|
||||
print "Usage: :Cargo new <name> [options]"
|
||||
return
|
||||
end
|
||||
|
||||
-- Run "cargo new whatever-is-left"
|
||||
vim.cmd("!cargo new " .. new_args)
|
||||
else
|
||||
print(
|
||||
"Please provide 'run', 'build', or 'new' as an argument to :Cargo. "
|
||||
.. "For 'new', also specify <name> [options]."
|
||||
)
|
||||
end
|
||||
end, {
|
||||
-- We make nargs = '*' so you can type multiple arguments
|
||||
-- e.g. ':Cargo new test_project --bin'
|
||||
nargs = "*",
|
||||
})
|
||||
|
||||
-- Keymaps remain the same, or you could add more if you want:
|
||||
vim.keymap.set("n", "<leader>cr", ":Cargo run<CR>", { desc = "Cargo: run" })
|
||||
vim.keymap.set("n", "<leader>cb", ":Cargo build<CR>", { desc = "Cargo: build" })
|
||||
-- Optionally, bind something for "new":
|
||||
vim.keymap.set("n", "<leader>cn", ":Cargo new ", { desc = "Cargo: new" })
|
||||
-- Notice we didn't put <CR> at the end of ':Cargo new ' because you typically
|
||||
-- want to type your project name before pressing Enter.
|
||||
@ -46,5 +46,6 @@ vim.api.nvim_create_autocmd("CursorHold", {
|
||||
vim.api.nvim_set_keymap("n", "<leader>e", "<cmd>lua vim.diagnostic.open_float()<CR>", { noremap = true, silent = true })
|
||||
|
||||
require "custom.language_specific_commands.matlab"
|
||||
require "custom.language_specific_commands.rust"
|
||||
|
||||
return M
|
||||
|
||||
@ -11,6 +11,7 @@ local plugins = {
|
||||
"matlab-language-server",
|
||||
"clangd",
|
||||
"marksman",
|
||||
"pyright",
|
||||
|
||||
--- formatters
|
||||
"stylua",
|
||||
@ -101,7 +102,22 @@ local plugins = {
|
||||
keys = {
|
||||
-- Will use Telescope if installed or a vim.ui.select picker otherwise
|
||||
{ "<leader>fs", "<cmd>SessionSearch<CR>", desc = "Session search" },
|
||||
{ "<leader>ws", "<cmd>SessionSave<CR>", desc = "Save session" },
|
||||
{
|
||||
"<leader>ws",
|
||||
function()
|
||||
-- prompt for a session name using the built-in input function:
|
||||
local session_name = vim.fn.input "Enter session name: "
|
||||
|
||||
-- optionally check if the user provided something
|
||||
if session_name ~= nil and session_name ~= "" then
|
||||
-- construct the command with the chosen name
|
||||
vim.cmd("SessionSave " .. session_name)
|
||||
else
|
||||
print "No session name given. Session not saved."
|
||||
end
|
||||
end,
|
||||
desc = "Save session (prompts for name)",
|
||||
},
|
||||
{ "<leader>wa", "<cmd>SessionToggleAutoSave<CR>", desc = "Toggle autosave" },
|
||||
},
|
||||
---enables autocomplete for opts
|
||||
@ -109,6 +125,7 @@ local plugins = {
|
||||
---@type AutoSession.Config
|
||||
opts = {
|
||||
suppressed_dirs = { "~/", "~/Projects", "~/Downloads", "/" },
|
||||
root_dir = os.getenv "HOME" .. "/Documents/Dane's Vault/.sessions/",
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -181,44 +198,28 @@ local plugins = {
|
||||
|
||||
local logo = {
|
||||
[[ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ]],
|
||||
[[ %%%%===========================================%%%% ]],
|
||||
[[ %%%%%=-------------------------------------------=#%%% ]],
|
||||
[[ %%%%%=---------------------------------------------=#%%% ]],
|
||||
[[ %%%%%=-----------------------------------------------=#%% ]],
|
||||
[[ %%%%%====----------==========================---------+%% ]],
|
||||
[[ %%%%%%%%#----------*%%%%%%%%%%%%%%%%%%%%%%%%%---------+%% ]],
|
||||
[[ %%%%%%%%#----------*%%%%%%%%%%%%%%%%%%%%%%%%%---------+%% ]],
|
||||
[[ %%%%#----------*%%%%%%%%%%%%%%%%%%%%%%%%%---------+%% ]],
|
||||
[[ %%%%#----------*%% %%%%%---------+%% ]],
|
||||
[[ %%%%#----------*%% %%%%%---------+%% ]],
|
||||
[[ %%%%#----------*%####################%%%%---------+%% ]],
|
||||
[[ %%%%#----------+*************************---------+%% ]],
|
||||
[[ %%%%#---------------------------------------------+%% ]],
|
||||
[[ %%%%#--------------------------------------------+%%% ]],
|
||||
[[ %%%%#------------------------------------------=#%%%% ]],
|
||||
[[ %%%%#-----------------------------------------#%%%% ]],
|
||||
[[ %%%%#----------=============================+%%%% ]],
|
||||
[[ %%%%#----------*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ]],
|
||||
[[ %%%%#----------*%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ]],
|
||||
[[ %%%%#----------*%%%%%%%%%%%%%%%%%%%%%%%%%%% ]],
|
||||
[[ %%%%#----------*%% ]],
|
||||
[[ %%%%#----------*%% %%%##**++++++*#%%%%%%% %%#***#%% ]],
|
||||
[[%#+=% %%%%#----------*%% %%%#=--------==---------------------=%===+#%%##% ]],
|
||||
[[%==% %%%%#----------*%%%%=+#=-----------+------------=+-------+==--=*=#=-==%% ]],
|
||||
[[#-=% %%%%#---------=#*===**------------*=-----------++-------=%=----*=--=+=*%*# ]],
|
||||
[[%*-#% %%%%#----==*#+--=+#%#----------=*+------------*=-------=+=----+#------+%=# ]],
|
||||
[[ %*==#%%%%#*##*==-=**#%%%+=--------+*=+**----------*++=----+*#=---=*#%*+==-* % ]],
|
||||
[[ %#+==--==+*#*+===*#*=--------=*+*%%%%%#+=-==----%#=---+#=---=#%%%%%% %*+% ]],
|
||||
[[ %%%%#=-----**=----=+*#####% %%%%%%% %#*+=#=#==--++-=+#%%%%%%%*==%% ]],
|
||||
[[ %%%%#-----+*==*#%% %#++==#% %%%%%%#=--=% %%#*=+#=-=+%% ]],
|
||||
[[ %%%%#----+*-=%#%%% %+=-*% %% %#=-=# %%#==--=*#%%%% ]],
|
||||
[[ %%%%%%%#----*=---=*#%%%% %+-===%#% %*=-==*#% %####==-+** ]],
|
||||
[[ %%%%%=----------------#%% %%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%]],
|
||||
[[ %%%%%=----------------#%% %%-----------+%% %%=-------------------=%% %%--------------------=%%]],
|
||||
[[ %%%%%=----------------#%% %%%%%%=---*%%%%% %%=----#%%*----%%%%=--=%% %%-----#%%+---=%%%%=--=%%]],
|
||||
[[ %%%%%=----------------#%% %%=---*% %%%%%%%%%%*----%%%%%%%%%% %%%%%%%%%%+---=%%%%%%%%%%]],
|
||||
[[ %%%%%=----------------#%% %%=---*% %*----%% %+---=%% ]],
|
||||
[[ %%%%%##################%% %%%%%%=---*%%%%% %%%%%*----%%%%% %%%%%+---=%%%%%% ]],
|
||||
[[ %%%%%%%%%%%%%%%%%%%%%%%%% %%-----------+%% %%=----------*%% %%=----------*%% ]],
|
||||
[[ %%%%%%%%%%%%%%%%%%%%%%%%% %%############%% %%###########%%% %%############%% ]],
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user