From 3a8b297e91652aaaa348b55bc0aa76cd1930443f Mon Sep 17 00:00:00 2001 From: aleidk Date: Thu, 9 May 2024 10:54:49 -0400 Subject: [PATCH] Add more keybindings to task-runner --- README.md | 2 +- chezmoi/.chezmoidata/packages.yaml | 3 +- chezmoi/dot_config/kitty/kitty.conf | 2 +- .../nvim/lua/aleidk/plugins/colorscheme.lua | 2 +- .../nvim/lua/aleidk/plugins/completion.lua | 8 ++ .../nvim/lua/aleidk/plugins/dashboard.lua | 2 +- .../nvim/lua/aleidk/plugins/lsp.lua | 23 +++- .../nvim/lua/aleidk/plugins/task-runner.lua | 114 +++++++++++++++++- .../dot_config/nvim/original_lazy-lock.json | 4 +- 9 files changed, 147 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 5ff6d0a..1a9e959 100644 --- a/README.md +++ b/README.md @@ -5,5 +5,5 @@ Execute the following command: ```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 ``` diff --git a/chezmoi/.chezmoidata/packages.yaml b/chezmoi/.chezmoidata/packages.yaml index 41dca92..3436b9e 100644 --- a/chezmoi/.chezmoidata/packages.yaml +++ b/chezmoi/.chezmoidata/packages.yaml @@ -1,8 +1,9 @@ packages: cargo: + - du-dust - mise - - yazi-fm - rbw + - yazi-fm dnf: copr: - atim/lazygit diff --git a/chezmoi/dot_config/kitty/kitty.conf b/chezmoi/dot_config/kitty/kitty.conf index 935aa25..248820d 100644 --- a/chezmoi/dot_config/kitty/kitty.conf +++ b/chezmoi/dot_config/kitty/kitty.conf @@ -1122,7 +1122,7 @@ confirm_os_window_close 0 #: 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 #: one is opaque and zero is fully transparent. This will only work if diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/colorscheme.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/colorscheme.lua index cf520d8..5f126e9 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/colorscheme.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/colorscheme.lua @@ -4,7 +4,7 @@ return { -- Change colors.none if not using a transparent background lazy = false, opts = { flavour = "macchiato", - transparent_background = false, + transparent_background = true, integrations = { cmp = true, notify = true, diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/completion.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/completion.lua index d3af000..a3cad37 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/completion.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/completion.lua @@ -28,6 +28,7 @@ return { winhighlight = "Normal:Pmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None", } local opts = { + visible_docs = false, completion = { completeopt = "menu,menuone,noinsert", }, @@ -43,6 +44,13 @@ return { [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), + [""] = function() + if cmp.visible_docs() then + cmp.close_docs() + else + cmp.open_docs() + end + end, [""] = cmp.mapping.complete(), [""] = cmp.mapping.abort(), ["
"] = cmp.mapping.abort(), diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/dashboard.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/dashboard.lua index 94b5051..db755d4 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/dashboard.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/dashboard.lua @@ -18,7 +18,7 @@ return { dashboard.section.buttons.val = { dashboard.button("LDR f f", " Find File ", "ff"), - dashboard.button("LDR LDR t", " Harpoon", "t"), + dashboard.button("LDR LDR t", " Bookmars", "t"), dashboard.button("LDR g g", " Git ", "gg"), } diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/lsp.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/lsp.lua index 3c40245..04605e5 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/lsp.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/lsp.lua @@ -59,9 +59,28 @@ return { emmet_ls = {}, html = {}, pyright = {}, - rust_analyzer = {}, + rust_analyzer = { + settings = { + ["rust-analyzer"] = { + imports = { + granularity = { + group = "module", + }, + prefix = "self", + }, + cargo = { + buildScripts = { + enable = true, + }, + }, + procMacro = { + enable = true, + }, + }, + }, + }, sqlls = {}, - nimlsp = {}, + nimls = {}, yamlls = {}, lua_ls = { settings = { diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/task-runner.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/task-runner.lua index 7b3d44c..97b9d26 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/task-runner.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/task-runner.lua @@ -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 { "stevearc/overseer.nvim", keys = { - { "pp", "OverseerToggle", desc = "Toggle task runner" }, - { "pr", "OverseerRun", desc = "Run task" }, - { "pf", "OverseerQuickAction open float", desc = "Display current tasks" }, - { "pm", "OverseerTaskAction", desc = "Manage current tasks" }, + { "pO", "OverseerQuickAction hsplit", desc = "Open task in a hsplit" }, + { + "pQ", + "OverseerQuickAction close winOverseerQuickAction dispose", + desc = "Close and dispose task's windows", + }, + { "pW", "OverseerQuickAction unwatch", desc = "Unwatch task" }, + { "pf", "OverseerQuickAction open float", desc = "Open task in a float window" }, + { "pl", "OverseerLoadBundle", desc = "Load tasks" }, + { "pm", "OverseerTaskAction", desc = "Manage task" }, + { "po", "OverseerQuickAction vsplit", desc = "Open task in a vsplit" }, + { "pp", "OverseerRun", desc = "Run task" }, + { "pq", "OverseerQuickAction close win", desc = "Close task's windows" }, + { "ps", "OverseerSaveBundle", desc = "Save tasks" }, + { "pt", "OverseerToggle", desc = "Toggle tasks list" }, + { "pw", "OverseerQuickAction watch", desc = "Watch task" }, }, 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 = { direction = "bottom", bindings = { diff --git a/chezmoi/dot_config/nvim/original_lazy-lock.json b/chezmoi/dot_config/nvim/original_lazy-lock.json index 1283bfa..5a40d5d 100644 --- a/chezmoi/dot_config/nvim/original_lazy-lock.json +++ b/chezmoi/dot_config/nvim/original_lazy-lock.json @@ -16,7 +16,7 @@ "comment-box.nvim": { "branch": "main", "commit": "dd1a48f8d06102e9b87ae1e0069bc365c006979b" }, "conform.nvim": { "branch": "master", "commit": "e4ecb6e8ed3163c86d7e647f1dc3d94de77ca687" }, "debugprint.nvim": { "branch": "main", "commit": "159c7522438c6cf53540fb588fcf5bdad692d1bc" }, - "diffview.nvim": { "branch": "main", "commit": "d38c1b5266850f77f75e006bcc26213684e1e141" }, + "diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" }, "dressing.nvim": { "branch": "master", "commit": "1f2d1206a03bd3add8aedf6251e4534611de577f" }, "flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" }, "friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" }, @@ -43,7 +43,7 @@ "nvim-cmp": { "branch": "main", "commit": "51260c02a8ffded8e16162dcf41a23ec90cfba62" }, "nvim-lint": { "branch": "master", "commit": "962a76877a4479a535b935bd7ef35ad41ba308b2" }, "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-textobjects": { "branch": "master", "commit": "eb208bfdfcf76efea0424747e23e44641e13aaa6" }, "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" },