diff options
| author | William Boman <william@redwill.se> | 2021-10-10 19:20:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-10 19:20:16 +0200 |
| commit | 5f54148153a878cc9cbe370adccda0f706251d89 (patch) | |
| tree | 28ae0436232486323dfce3444e1d25657c34d75e /lua/nvim-lsp-installer/ui/init.lua | |
| parent | jdtls: fix jar argument (diff) | |
| download | mason-5f54148153a878cc9cbe370adccda0f706251d89.tar mason-5f54148153a878cc9cbe370adccda0f706251d89.tar.gz mason-5f54148153a878cc9cbe370adccda0f706251d89.tar.bz2 mason-5f54148153a878cc9cbe370adccda0f706251d89.tar.lz mason-5f54148153a878cc9cbe370adccda0f706251d89.tar.xz mason-5f54148153a878cc9cbe370adccda0f706251d89.tar.zst mason-5f54148153a878cc9cbe370adccda0f706251d89.zip | |
add keybindings to UI window (#140)
- Allows for expanding servers to view more information about it.
- Allows for installing/reinstalling/uninstalling servers.
The default keybindings is an attempt to mimic vim-fugitive's :Git
maps, and these can be overriden.
The keybinding implementation in display.lua is a bit hacky, but it
works and the "public" API is at least manageable. This will also
open up for adding more metadata in the future, such as filetype
information, currently installed version, latest available version,
etc.
Also there's Cowth Vader.
Diffstat (limited to 'lua/nvim-lsp-installer/ui/init.lua')
| -rw-r--r-- | lua/nvim-lsp-installer/ui/init.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/ui/init.lua b/lua/nvim-lsp-installer/ui/init.lua index 8f5d86a6..4f8d6935 100644 --- a/lua/nvim-lsp-installer/ui/init.lua +++ b/lua/nvim-lsp-installer/ui/init.lua @@ -6,6 +6,7 @@ M.NodeType = Data.enum { "CASCADING_STYLE", "VIRTUAL_TEXT", "HL_TEXT", + "KEYBIND_HANDLER", } function M.Node(children) @@ -63,8 +64,41 @@ function M.When(condition, a) return M.Node {} end +function M.Keybind(key, effect, payload, is_global) + return { + type = M.NodeType.KEYBIND_HANDLER, + key = key, + effect = effect, + payload = payload, + is_global = is_global or false, + } +end + function M.EmptyLine() return M.Text { "" } end +function M.Table(rows) + local col_maxwidth = {} + for i = 1, #rows do + local row = rows[i] + for j = 1, #row do + local col = row[j] + local content = col[1] + col_maxwidth[j] = math.max(#content, col_maxwidth[j] or 0) + end + end + + for i = 1, #rows do + local row = rows[i] + for j = 1, #row do + local col = row[j] + local content = col[1] + col[1] = content .. string.rep(" ", (col_maxwidth[j] - #content) + 1) -- +1 for default minimum padding + end + end + + return M.HlTextNode(rows) +end + return M |
