Files
gitlab.nvim/lua/gitlab/actions/help.lua
Jakub F. Bortlík 3f1c5effe5 Feat collapse and expand nodes (#176)
This MR adds the ability to expand and collapse nodes in the discussion tree in bulk. You can now toggle expansion of all nodes, toggle expansion of only resolved discussions, and toggle expansion of only unresolved discussions.

The MR also adjusts keybindings in the discussion tree to support forward and backward searching, as well as the keybinding for the help popup.

Thank you for the contribution @jakubbortlik!

This is a #MINOR bump since it's changing keybindings, although core workflows are unchanged.
2024-02-13 11:39:21 -05:00

28 lines
940 B
Lua

local M = {}
local u = require("gitlab.utils")
local state = require("gitlab.state")
local Popup = require("nui.popup")
M.open = function()
local bufnr = vim.api.nvim_get_current_buf()
local keymaps = vim.api.nvim_buf_get_keymap(bufnr, "n")
local help_content_lines = {}
for _, keymap in ipairs(keymaps) do
if keymap.desc ~= nil then
local new_line = string.format("%s: %s", keymap.lhs:gsub(" ", "<space>"), keymap.desc)
table.insert(help_content_lines, new_line)
end
end
local longest_line = u.get_longest_string(help_content_lines)
local help_popup =
Popup(u.create_popup_state("Help", state.settings.popup.help, longest_line + 3, #help_content_lines + 3, 60))
help_popup:mount()
state.set_popup_keymaps(help_popup, "Help", nil)
local currentBuffer = vim.api.nvim_get_current_buf()
vim.api.nvim_buf_set_lines(currentBuffer, 0, #help_content_lines, false, help_content_lines)
end
return M