mirror of
https://github.com/chenasraf/dotfiles.git
synced 2026-05-17 17:28:07 +00:00
feat: wezterm keymap for tabs nav, rust run command
This commit is contained in:
@@ -67,6 +67,67 @@ vim.api.nvim_create_autocmd("FileType", {
|
||||
end,
|
||||
})
|
||||
|
||||
local function run_rust()
|
||||
-- telescope options:
|
||||
-- Run current file
|
||||
-- Run current file (terminal)
|
||||
local actions = require('telescope.actions')
|
||||
local action_state = require('telescope.actions.state')
|
||||
|
||||
local function run_selected(prompt_bufnr, map)
|
||||
actions.select_default:replace(function()
|
||||
local selection = action_state.get_selected_entry()
|
||||
actions.close(prompt_bufnr)
|
||||
if selection.value == 'inline' then
|
||||
vim.cmd('!cargo run')
|
||||
elseif selection.value == 'terminal' then
|
||||
-- set new split height to 30
|
||||
vim.cmd('split | wincmd J | resize 20 | terminal cargo run')
|
||||
end
|
||||
end)
|
||||
return 1
|
||||
end
|
||||
local items = {
|
||||
{ label = 'Run project (terminal)', value = 'terminal' },
|
||||
{ label = 'Run project', value = 'inline' },
|
||||
}
|
||||
|
||||
local opts = {
|
||||
prompt_title = 'Select run configuration',
|
||||
attach_mappings = run_selected,
|
||||
layout_config = {
|
||||
width = 0.5,
|
||||
height = 8,
|
||||
},
|
||||
finder = require('telescope.finders').new_table {
|
||||
results = items,
|
||||
entry_maker = function(entry)
|
||||
return {
|
||||
value = entry.value,
|
||||
display = entry.label,
|
||||
ordinal = entry.label,
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
require('telescope.pickers').new(opts):find()
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("RustRun", run_rust, {
|
||||
nargs = 0,
|
||||
-- complete = "customlist,v:lua.require('telescope.themes').get_dropdown({})",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "rust",
|
||||
callback = function()
|
||||
vim.keymap.set("n", "<F5>", run_rust, { buffer = true, desc = "Flutter commands" })
|
||||
vim.keymap.set("n", 'gd', vim.lsp.buf.declaration,
|
||||
{ buffer = true, desc = 'Type [D]efinition', remap = true })
|
||||
end,
|
||||
})
|
||||
|
||||
-- mason-lspconfig requires that these setup functions are called in this order
|
||||
-- before setting up the servers.
|
||||
require('mason').setup()
|
||||
@@ -83,7 +144,7 @@ local servers = {
|
||||
-- clangd = {},
|
||||
-- gopls = {},
|
||||
-- pyright = {},
|
||||
-- rust_analyzer = {},
|
||||
rust_analyzer = {},
|
||||
-- tsserver = {},
|
||||
-- html = { filetypes = { 'html', 'twig', 'hbs'} },
|
||||
cssls = {},
|
||||
|
||||
@@ -93,8 +93,8 @@ config.keys = {
|
||||
{ key = "9", mods = "CMD", action = act { SendString = "\x029" } },
|
||||
{ key = "0", mods = "CMD", action = act { SendString = "\x020" } },
|
||||
-- Previous/Next tmux window: Cmd+{/}
|
||||
{ key = "[", mods = "CMD", action = act { SendString = "\x02p" } },
|
||||
{ key = "]", mods = "CMD", action = act { SendString = "\x02n" } },
|
||||
{ key = "{", mods = "CMD|SHIFT", action = act { SendString = "\x02p" } },
|
||||
{ key = "}", mods = "CMD|SHIFT", action = act { SendString = "\x02n" } },
|
||||
--
|
||||
-- Zoom - Cmd+Z
|
||||
{ key = "z", mods = "CMD", action = act { SendString = "\x02z" } },
|
||||
|
||||
Reference in New Issue
Block a user