From 5f54148153a878cc9cbe370adccda0f706251d89 Mon Sep 17 00:00:00 2001 From: William Boman Date: Sun, 10 Oct 2021 19:20:16 +0200 Subject: 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. --- lua/nvim-lsp-installer/data.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lua/nvim-lsp-installer/data.lua') diff --git a/lua/nvim-lsp-installer/data.lua b/lua/nvim-lsp-installer/data.lua index 901c293a..b5689142 100644 --- a/lua/nvim-lsp-installer/data.lua +++ b/lua/nvim-lsp-installer/data.lua @@ -33,6 +33,21 @@ function Data.list_map(fn, list) return result end +function Data.table_pack(...) + return { n = select("#", ...), ... } +end + +function Data.list_not_nil(...) + local result = {} + local args = Data.table_pack(...) + for i = 1, args.n do + if args[i] ~= nil then + result[#result + 1] = args[i] + end + end + return result +end + function Data.tbl_pack(...) return { n = select("#", ...), ... } end @@ -41,6 +56,10 @@ function Data.when(condition, value) return condition and value or nil end +function Data.lazy(condition, fn) + return condition and fn() or nil +end + function Data.coalesce(...) local args = Data.tbl_pack(...) for i = 1, args.n do -- cgit v1.2.3-70-g09d2