GitHub - ray-x/guihua.lua: A GUI library for Neovim plugin developers (original) (raw)

guihuaGuihua: A Lua Gui and util library for nvim plugins

multigrid

This cool screen shows an external terminal running lazygit and an external floating window running guihua listview

More screen shot please refer to Navigator.lua

Please refer to test file of how to use it

Lua OOP is powered by middleclassfzy is powered by romgrk fzy-lua-native with modified version of sorter/quicksort to sort list of tables

Install

Plugin has implementation of fzy with both ffi and native lua. If you like to try ffi please run make

Packer

use {'ray-x/guihua.lua', run = 'cd lua/fzy && make'}

lazy.nvim

{ 'ray-x/guihua.lua', build = 'cd lua/fzy && make', lazy = true, init = function() local configured = false

local function ensure_guihua()
  if configured then
    return
  end

  configured = true
  require('guihua').setup({})
end

vim.ui.select = function(...)
  ensure_guihua()
  return require('guihua.gui').select(...)
end

vim.ui.input = function(...)
  ensure_guihua()
  return require('guihua.gui').input(...)
end

end, }

The lazy.nvim example above keeps guihua unloaded until the first vim.ui.select() orvim.ui.input() call, which avoids paying the UI startup cost during Neovim startup.

vim.ui.select() callers can attach preview content directly by adding preview to each item or by passing preview_item = function(item) return ... end. Guihua will turn that content into a preview window automatically.

Setup

local icons = { panel_icons = { section_separator = '─', -- '', line_num_left = ':', -- '', line_num_right = '', -- '',

range_left = '', -- '',
range_right = '',
inner_node = '', -- '├○',
folded = '◉',
unfolded = '○',

outer_node = '', -- '╰○',
bracket_left = '', -- '⟪',
bracket_right = '', -- '⟫',

}, syntax_icons = { var = ' ', -- "👹", -- Vampire method = 'ƒ ', -- "🍔", -- mac ['function'] = ' ', -- "🤣", -- Fun ['arrow_function'] = ' ', -- "🤣", -- Fun parameter = '', -- Pi associated = '🤝', namespace = '🚀', type = ' ', field = '🏈', interface = '', module = '📦', flag = '🎏', }, }

require('guihua').setup({ maps = { close_view = '', send_qf = '', save = '', jump_to_list = 'k', jump_to_preview = 'j', prev = '', next = '', pageup = '', pagedown = '', confirm = '', split = '', vsplit = '', tabnew = '', }, icons = icons,

-- guihua disables strikethrough highlights inside its floating views to avoid accidental single-tilde (~) rendering (useful for paths like ~/foo). })

Note: guihua disables the common strikethrough highlight groups for its floating views by default. You can control this behavior with setup options:

Example:

require('guihua').setup({ disable_strikethrough_in_views = false, -- allow strikethrough in guihua views patch_markdown_strikethrough_query = true, -- make Treesitter highlight only double-tilde as strikethrough })

guihua.gui.catalog() adds a tabbed floating browser for TOC-style data. It keeps the@markup.strikethrough override local to guihua popups and opens the selected path on Enter by default. Use <Left> / <Right> to move between tabs.

Catalog options:

require('guihua.gui').catalog({ title = 'Browse', tabs = { agents = { { name = 'grep', description = { 'this is a grep agent' }, path = '/path/to/agent.lua' }, }, skills = { { name = 'lint', description = 'this is a lint skill', path = '/path/to/skill.lua' }, }, }, tab_order = { 'agents', 'skills' }, })

Plug

Plug 'ray-x/guihua.lua', {'do': 'cd lua/fzy && make' }

Usage: check the test files on how the api is used.

Git commit agent

This repository includes a repo-local commit helper at scripts/git_commit_agent.py.

It will:

Examples:

python3 scripts/git_commit_agent.py --dry-run python3 scripts/git_commit_agent.py --all python3 scripts/git_commit_agent.py --all --push