Add more keybindings to task-runner

This commit is contained in:
Alexander Navarro 2024-05-09 10:54:49 -04:00
parent 2213374567
commit 3a8b297e91
9 changed files with 147 additions and 13 deletions

View file

@ -5,5 +5,5 @@
Execute the following command: Execute the following command:
```bash ```bash
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b $HOME/.local/bin init --apply sh -c "$(curl -fsLS get.chezmoi.io)" -- -b $HOME/.local/bin init --apply git@codeberg.org:aleidk/dots.git
``` ```

View file

@ -1,8 +1,9 @@
packages: packages:
cargo: cargo:
- du-dust
- mise - mise
- yazi-fm
- rbw - rbw
- yazi-fm
dnf: dnf:
copr: copr:
- atim/lazygit - atim/lazygit

View file

@ -1122,7 +1122,7 @@ confirm_os_window_close 0
#: The foreground and background colors. #: The foreground and background colors.
# background_opacity 1.0 background_opacity 0.8
#: The opacity of the background. A number between zero and one, where #: The opacity of the background. A number between zero and one, where
#: one is opaque and zero is fully transparent. This will only work if #: one is opaque and zero is fully transparent. This will only work if

View file

@ -4,7 +4,7 @@ return { -- Change colors.none if not using a transparent background
lazy = false, lazy = false,
opts = { opts = {
flavour = "macchiato", flavour = "macchiato",
transparent_background = false, transparent_background = true,
integrations = { integrations = {
cmp = true, cmp = true,
notify = true, notify = true,

View file

@ -28,6 +28,7 @@ return {
winhighlight = "Normal:Pmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None", winhighlight = "Normal:Pmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None",
} }
local opts = { local opts = {
visible_docs = false,
completion = { completion = {
completeopt = "menu,menuone,noinsert", completeopt = "menu,menuone,noinsert",
}, },
@ -43,6 +44,13 @@ return {
["<C-k>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), ["<C-k>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-u>"] = cmp.mapping.scroll_docs(-4), ["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4), ["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-o>"] = function()
if cmp.visible_docs() then
cmp.close_docs()
else
cmp.open_docs()
end
end,
["<C-Space>"] = cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(), ["<C-e>"] = cmp.mapping.abort(),
["<BR>"] = cmp.mapping.abort(), ["<BR>"] = cmp.mapping.abort(),

View file

@ -18,7 +18,7 @@ return {
dashboard.section.buttons.val = { dashboard.section.buttons.val = {
dashboard.button("LDR f f", " Find File ", "<leader>ff"), dashboard.button("LDR f f", " Find File ", "<leader>ff"),
dashboard.button("LDR LDR t", "Harpoon", "<leader><leader>t"), dashboard.button("LDR LDR t", "Bookmars", "<leader><leader>t"),
dashboard.button("LDR g g", " Git ", "<leader>gg"), dashboard.button("LDR g g", " Git ", "<leader>gg"),
} }

View file

@ -59,9 +59,28 @@ return {
emmet_ls = {}, emmet_ls = {},
html = {}, html = {},
pyright = {}, pyright = {},
rust_analyzer = {}, rust_analyzer = {
settings = {
["rust-analyzer"] = {
imports = {
granularity = {
group = "module",
},
prefix = "self",
},
cargo = {
buildScripts = {
enable = true,
},
},
procMacro = {
enable = true,
},
},
},
},
sqlls = {}, sqlls = {},
nimlsp = {}, nimls = {},
yamlls = {}, yamlls = {},
lua_ls = { lua_ls = {
settings = { settings = {

View file

@ -1,12 +1,118 @@
local function term_get_effective_line_count(bufnr)
local linecount = vim.api.nvim_buf_line_count(bufnr)
local non_blank_lines = linecount
for i = linecount, 1, -1 do
local line = vim.api.nvim_buf_get_lines(bufnr, i - 1, i, true)[1]
non_blank_lines = i
if line ~= "" then
break
end
end
return non_blank_lines
end
-- This is a copy of the original util function of overseer with the change that
-- vim.api.nvim_win_set_cursor(winid, { lnum, 0 }) column is set to 0 so the output is visible
-- the rest is the same
local scroll_to_end = function(winid)
winid = winid or 0
local bufnr = vim.api.nvim_win_get_buf(winid)
local lnum = vim.api.nvim_buf_line_count(bufnr)
local last_line = vim.api.nvim_buf_get_lines(bufnr, -2, -1, true)[1]
-- Hack: terminal buffers add a bunch of empty lines at the end. We need to ignore them so that
-- we don't end up scrolling off the end of the useful output.
local not_much_output = lnum < vim.o.lines + 6
if vim.bo[bufnr].buftype == "terminal" and not_much_output then
lnum = term_get_effective_line_count(bufnr)
last_line = vim.api.nvim_buf_get_lines(bufnr, lnum - 1, lnum, true)[1]
end
local scrolloff = vim.api.nvim_get_option_value("scrolloff", { scope = "local", win = winid })
vim.api.nvim_set_option_value("scrolloff", 0, { scope = "local", win = winid })
vim.api.nvim_win_set_cursor(winid, { lnum, 0 })
vim.api.nvim_set_option_value("scrolloff", scrolloff, { scope = "local", win = winid })
end
local open_split = function(task, horizontal)
local original_window = vim.api.nvim_get_current_win()
if horizontal then
-- horizontal split across all vertical splits
vim.cmd([[botright split]])
else
-- vertical split across all horizontal splits
vim.cmd([[vert botright split]])
end
-- Update tasks buffer options
vim.api.nvim_win_set_buf(0, task:get_bufnr())
vim.api.nvim_set_option_value("number", false, { scope = "local", win = 0 })
vim.api.nvim_set_option_value("relativenumber", false, { scope = "local", win = 0 })
vim.api.nvim_set_option_value("signcolumn", "no", { scope = "local", win = 0 })
scroll_to_end(0)
-- Go back to the original window
vim.api.nvim_set_current_win(original_window)
end
return { return {
"stevearc/overseer.nvim", "stevearc/overseer.nvim",
keys = { keys = {
{ "<leader>pp", "<CMD>OverseerToggle<CR>", desc = "Toggle task runner" }, { "<leader>pO", "<CMD>OverseerQuickAction hsplit<CR>", desc = "Open task in a hsplit" },
{ "<leader>pr", "<CMD>OverseerRun<CR>", desc = "Run task" }, {
{ "<leader>pf", "<CMD>OverseerQuickAction open float<CR>", desc = "Display current tasks" }, "<leader>pQ",
{ "<leader>pm", "<CMD>OverseerTaskAction<CR>", desc = "Manage current tasks" }, "<CMD>OverseerQuickAction close win<CR><CMD>OverseerQuickAction dispose<CR>",
desc = "Close and dispose task's windows",
},
{ "<leader>pW", "<CMD>OverseerQuickAction unwatch<CR>", desc = "Unwatch task" },
{ "<leader>pf", "<CMD>OverseerQuickAction open float<CR>", desc = "Open task in a float window" },
{ "<leader>pl", "<CMD>OverseerLoadBundle<CR>", desc = "Load tasks" },
{ "<leader>pm", "<CMD>OverseerTaskAction<CR>", desc = "Manage task" },
{ "<leader>po", "<CMD>OverseerQuickAction vsplit<CR>", desc = "Open task in a vsplit" },
{ "<leader>pp", "<CMD>OverseerRun<CR>", desc = "Run task" },
{ "<leader>pq", "<CMD>OverseerQuickAction close win<CR>", desc = "Close task's windows" },
{ "<leader>ps", "<CMD>OverseerSaveBundle<CR>", desc = "Save tasks" },
{ "<leader>pt", "<CMD>OverseerToggle<CR>", desc = "Toggle tasks list" },
{ "<leader>pw", "<CMD>OverseerQuickAction watch<CR>", desc = "Watch task" },
}, },
opts = { opts = {
actions = {
["hsplit"] = {
desc = "open terminal in a horizontal split",
condition = function(task)
local bufnr = task:get_bufnr()
return bufnr and vim.api.nvim_buf_is_valid(bufnr)
end,
run = function(task)
open_split(task, true)
end,
},
["vsplit"] = {
desc = "open terminal in a vertical split",
condition = function(task)
local bufnr = task:get_bufnr()
return bufnr and vim.api.nvim_buf_is_valid(bufnr)
end,
run = function(task)
open_split(task, false)
end,
},
["close win"] = {
desc = "open terminal in a vertical split",
condition = function(task)
local bufnr = task:get_bufnr()
return bufnr and vim.api.nvim_buf_is_valid(bufnr)
end,
run = function(task)
local buf = task:get_bufnr()
-- iterar sobre todas las windows y ver si la window tiene attach el buf que quiero cerrar
for _, win in ipairs(vim.api.nvim_list_wins()) do
if buf == vim.api.nvim_win_get_buf(win) then
vim.api.nvim_win_close(win, false)
end
end
end,
},
},
task_list = { task_list = {
direction = "bottom", direction = "bottom",
bindings = { bindings = {

View file

@ -16,7 +16,7 @@
"comment-box.nvim": { "branch": "main", "commit": "dd1a48f8d06102e9b87ae1e0069bc365c006979b" }, "comment-box.nvim": { "branch": "main", "commit": "dd1a48f8d06102e9b87ae1e0069bc365c006979b" },
"conform.nvim": { "branch": "master", "commit": "e4ecb6e8ed3163c86d7e647f1dc3d94de77ca687" }, "conform.nvim": { "branch": "master", "commit": "e4ecb6e8ed3163c86d7e647f1dc3d94de77ca687" },
"debugprint.nvim": { "branch": "main", "commit": "159c7522438c6cf53540fb588fcf5bdad692d1bc" }, "debugprint.nvim": { "branch": "main", "commit": "159c7522438c6cf53540fb588fcf5bdad692d1bc" },
"diffview.nvim": { "branch": "main", "commit": "d38c1b5266850f77f75e006bcc26213684e1e141" }, "diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" },
"dressing.nvim": { "branch": "master", "commit": "1f2d1206a03bd3add8aedf6251e4534611de577f" }, "dressing.nvim": { "branch": "master", "commit": "1f2d1206a03bd3add8aedf6251e4534611de577f" },
"flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" }, "flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" },
"friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" }, "friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" },
@ -43,7 +43,7 @@
"nvim-cmp": { "branch": "main", "commit": "51260c02a8ffded8e16162dcf41a23ec90cfba62" }, "nvim-cmp": { "branch": "main", "commit": "51260c02a8ffded8e16162dcf41a23ec90cfba62" },
"nvim-lint": { "branch": "master", "commit": "962a76877a4479a535b935bd7ef35ad41ba308b2" }, "nvim-lint": { "branch": "master", "commit": "962a76877a4479a535b935bd7ef35ad41ba308b2" },
"nvim-lspconfig": { "branch": "master", "commit": "6c797ff9324094e333e2ace9526ca4a62ad9d1ca" }, "nvim-lspconfig": { "branch": "master", "commit": "6c797ff9324094e333e2ace9526ca4a62ad9d1ca" },
"nvim-treesitter": { "branch": "master", "commit": "107e61afb7129d637ea6c3c68b97a22194b0bf16" }, "nvim-treesitter": { "branch": "master", "commit": "40e8c92f99ef26625ff2206f5e183ac3109f20ba" },
"nvim-treesitter-context": { "branch": "master", "commit": "8aa32aa6b84dda357849dbc0f775e69f2e04c041" }, "nvim-treesitter-context": { "branch": "master", "commit": "8aa32aa6b84dda357849dbc0f775e69f2e04c041" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "eb208bfdfcf76efea0424747e23e44641e13aaa6" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "eb208bfdfcf76efea0424747e23e44641e13aaa6" },
"nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" }, "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" },