From 00294b84031711013a385f18c0fb0e8db84ebaf9 Mon Sep 17 00:00:00 2001 From: William Boman Date: Tue, 7 Sep 2021 02:44:09 +0200 Subject: add direct integration with libuv instead of going through termopen, also implement a UI (#79) * add direct integration with libuv instead of going through termopen, also implement a UI * alleged free perf boosts yo that's free cycles --- lua/nvim-lsp-installer/ui/init.lua | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 lua/nvim-lsp-installer/ui/init.lua (limited to 'lua/nvim-lsp-installer/ui/init.lua') diff --git a/lua/nvim-lsp-installer/ui/init.lua b/lua/nvim-lsp-installer/ui/init.lua new file mode 100644 index 00000000..3b8d830a --- /dev/null +++ b/lua/nvim-lsp-installer/ui/init.lua @@ -0,0 +1,70 @@ +local Data = require "nvim-lsp-installer.data" +local M = {} + +M.NodeType = Data.enum { + "NODE", + "STYLE_BLOCK", + "VIRTUAL_TEXT", + "HL_TEXT", +} + +function M.Node(children) + return { + type = M.NodeType.NODE, + children = children, + } +end + +function M.HlTextNode(lines_with_span_tuples) + if type(lines_with_span_tuples[1]) == "string" then + -- this enables a convenience API for just rendering a single line (with just a single span) + lines_with_span_tuples = { { lines_with_span_tuples } } + end + return { + type = M.NodeType.HL_TEXT, + lines = lines_with_span_tuples, + } +end + +function M.Text(lines) + return M.HlTextNode(Data.list_map(function(line) + return { { line, "Normal" } } + end, lines)) +end + +M.CascadingStyle = Data.enum { + "INDENT", + "CENTERED", +} + +function M.CascadingStyleNode(styles, children) + return { + type = M.NodeType.STYLE_BLOCK, + styles = styles, + children = children, + } +end + +function M.VirtualTextNode(virt_text) + return { + type = M.NodeType.VIRTUAL_TEXT, + virt_text = virt_text, + } +end + +function M.When(condition, a) + if condition then + if type(a) == "function" then + return a() + else + return a + end + end + return M.Node {} +end + +function M.EmptyLine() + return M.Text { "" } +end + +return M -- cgit v1.2.3-70-g09d2