diff options
| author | William Boman <william@redwill.se> | 2022-05-17 13:49:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-17 13:49:18 +0200 |
| commit | 9fa0bb2822af391db96687ad6ddb66ddb3529c58 (patch) | |
| tree | 82d5838c98e5c0b3f273f23326099383be6b8c0e /lua/nvim-lsp-installer/ui | |
| parent | run autogen_metadata.lua (diff) | |
| download | mason-9fa0bb2822af391db96687ad6ddb66ddb3529c58.tar mason-9fa0bb2822af391db96687ad6ddb66ddb3529c58.tar.gz mason-9fa0bb2822af391db96687ad6ddb66ddb3529c58.tar.bz2 mason-9fa0bb2822af391db96687ad6ddb66ddb3529c58.tar.lz mason-9fa0bb2822af391db96687ad6ddb66ddb3529c58.tar.xz mason-9fa0bb2822af391db96687ad6ddb66ddb3529c58.tar.zst mason-9fa0bb2822af391db96687ad6ddb66ddb3529c58.zip | |
chore(functional): restructure and extend functional modules (#703)
Diffstat (limited to 'lua/nvim-lsp-installer/ui')
| -rw-r--r-- | lua/nvim-lsp-installer/ui/components/settings-schema.lua | 6 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/ui/init.lua | 54 |
2 files changed, 29 insertions, 31 deletions
diff --git a/lua/nvim-lsp-installer/ui/components/settings-schema.lua b/lua/nvim-lsp-installer/ui/components/settings-schema.lua index 4954d456..04d8e0d5 100644 --- a/lua/nvim-lsp-installer/ui/components/settings-schema.lua +++ b/lua/nvim-lsp-installer/ui/components/settings-schema.lua @@ -1,8 +1,6 @@ -- Here be dragons local Ui = require "nvim-lsp-installer.core.ui" -local functional = require "nvim-lsp-installer.core.functional" - -local list_map = functional.list_map +local _ = require "nvim-lsp-installer.core.functional" local property_type_highlights = { ["string"] = "String", @@ -135,7 +133,7 @@ local function ServerSettingsSchema(server, schema, key, level, key_width, compo heading, toggle_expand_keybind, Ui.When(node_is_expanded, function() - local description = list_map(function(line) + local description = _.map(function(line) return { { line, "Comment" } } end, vim.split(schema.description or "No description available.", "\n")) diff --git a/lua/nvim-lsp-installer/ui/init.lua b/lua/nvim-lsp-installer/ui/init.lua index 48791d2a..73548d1f 100644 --- a/lua/nvim-lsp-installer/ui/init.lua +++ b/lua/nvim-lsp-installer/ui/init.lua @@ -3,7 +3,7 @@ local Ui = require "nvim-lsp-installer.core.ui" local display = require "nvim-lsp-installer.core.ui.display" local fs = require "nvim-lsp-installer.core.fs" local log = require "nvim-lsp-installer.log" -local functional = require "nvim-lsp-installer.core.functional" +local _ = require "nvim-lsp-installer.core.functional" local settings = require "nvim-lsp-installer.settings" local lsp_servers = require "nvim-lsp-installer.servers" local JobExecutionPool = require "nvim-lsp-installer.jobs.pool" @@ -35,7 +35,7 @@ local function Indent(children) return Ui.CascadingStyleNode({ "INDENT" }, children) end -local create_vader = functional.memoize( +local create_vader = _.memoize( ---@param saber_ticks number function(saber_ticks) -- stylua: ignore start @@ -88,7 +88,7 @@ local function Help(is_current_settings_expanded, vader_saber_ticks) { "Keyboard shortcuts", "LspInstallerLabel" }, }, }, - functional.list_map(function(keymap_tuple) + _.map(function(keymap_tuple) return { { keymap_tuple[1], "LspInstallerMuted" }, { keymap_tuple[2], "LspInstallerHighlighted" } } end, keymap_tuples) )), @@ -157,7 +157,7 @@ local function Help(is_current_settings_expanded, vader_saber_ticks) Ui.Keybind("<CR>", "TOGGLE_EXPAND_CURRENT_SETTINGS", nil), Ui.When(is_current_settings_expanded, function() local settings_split_by_newline = vim.split(vim.inspect(settings.current), "\n") - local current_settings = functional.list_map(function(line) + local current_settings = _.map(function(line) return { { line, "LspInstallerMuted" } } end, settings_split_by_newline) return Ui.HlTextNode(current_settings) @@ -211,11 +211,11 @@ end ---@param server ServerState local function ServerMetadata(server) - return Ui.Node(functional.list_not_nil( - functional.lazy_when(server.is_installed and server.deprecated, function() - return Ui.Node(functional.list_not_nil( + return Ui.Node(_.list_not_nil( + _.lazy_when(server.is_installed and server.deprecated, function() + return Ui.Node(_.list_not_nil( Ui.HlTextNode { server.deprecated.message, "Comment" }, - functional.lazy_when(server.deprecated.replace_with, function() + _.lazy_when(server.deprecated.replace_with, function() return Ui.Node { Ui.HlTextNode { { @@ -229,8 +229,8 @@ local function ServerMetadata(server) end) )) end), - Ui.Table(functional.list_not_nil( - functional.lazy_when(server.is_installed, function() + Ui.Table(_.list_not_nil( + _.lazy_when(server.is_installed, function() return { { "version", "LspInstallerMuted" }, server.installed_version_err and { @@ -239,7 +239,7 @@ local function ServerMetadata(server) } or { server.installed_version or "Loading...", "" }, } end), - functional.lazy_when(#server.metadata.outdated_packages > 0, function() + _.lazy_when(#server.metadata.outdated_packages > 0, function() return { { "latest version", "LspInstallerGreen" }, { @@ -248,17 +248,17 @@ local function ServerMetadata(server) }, } end), - functional.lazy_when(server.metadata.install_timestamp_seconds, function() + _.lazy_when(server.metadata.install_timestamp_seconds, function() return { { "installed", "LspInstallerMuted" }, { format_time(server.metadata.install_timestamp_seconds), "" }, } end), - functional.when(not server.is_installed, { + _.when(not server.is_installed, { { "filetypes", "LspInstallerMuted" }, { server.metadata.filetypes, "" }, }), - functional.when(server.is_installed, { + _.when(server.is_installed, { { "path", "LspInstallerMuted" }, { server.metadata.install_dir, "String" }, }), @@ -323,17 +323,17 @@ end ---@param servers ServerState[] ---@param props ServerGroupProps local function InstalledServers(servers, props) - return Ui.Node(functional.list_map( + return Ui.Node(_.map( ---@param server ServerState function(server) local is_expanded = props.expanded_server == server.name return Ui.Node { Ui.HlTextNode { - functional.list_not_nil( + _.list_not_nil( { settings.current.ui.icons.server_installed, "LspInstallerGreen" }, { " " .. server.name .. " ", "" }, { server.hints, "Comment" }, - functional.when(server.deprecated, { " deprecated", "LspInstallerOrange" }) + _.when(server.deprecated, { " deprecated", "LspInstallerOrange" }) ), }, Ui.When( @@ -363,7 +363,7 @@ end ---@param server ServerState local function TailedOutput(server) - return Ui.HlTextNode(functional.list_map(function(line) + return Ui.HlTextNode(_.map(function(line) return { { line, "LspInstallerMuted" } } end, server.installer.tailed_output)) end @@ -382,21 +382,21 @@ end ---@param servers ServerState[] local function PendingServers(servers) - return Ui.Node(functional.list_map(function(_server) + return Ui.Node(_.map(function(_server) ---@type ServerState local server = _server local has_failed = server.installer.has_run or server.uninstaller.has_run local note = has_failed and "(failed)" or (server.installer.is_queued and "(queued)" or "(installing)") return Ui.Node { Ui.HlTextNode { - functional.list_not_nil( + _.list_not_nil( { settings.current.ui.icons.server_pending, has_failed and "LspInstallerError" or "LspInstallerOrange", }, { " " .. server.name, server.installer.is_running and "" or "LspInstallerMuted" }, { " " .. note, "Comment" }, - functional.when(not has_failed, { + _.when(not has_failed, { (" " .. get_last_non_empty_line(server.installer.tailed_output)), "Comment", }) @@ -419,22 +419,22 @@ end ---@param servers ServerState[] ---@param props ServerGroupProps local function UninstalledServers(servers, props) - return Ui.Node(functional.list_map(function(_server) + return Ui.Node(_.map(function(_server) ---@type ServerState local server = _server local is_prioritized = props.prioritized_servers[server.name] local is_expanded = props.expanded_server == server.name return Ui.Node { Ui.HlTextNode { - functional.list_not_nil( + _.list_not_nil( { settings.current.ui.icons.server_uninstalled, is_prioritized and "LspInstallerHighlighted" or "LspInstallerMuted", }, { " " .. server.name .. " ", "LspInstallerMuted" }, { server.hints, "Comment" }, - functional.when(server.uninstaller.has_run, { " (uninstalled) ", "Comment" }), - functional.when(server.deprecated, { "deprecated ", "LspInstallerOrange" }) + _.when(server.uninstaller.has_run, { " (uninstalled) ", "Comment" }), + _.when(server.deprecated, { "deprecated ", "LspInstallerOrange" }) ), }, Ui.Keybind(settings.current.ui.keymaps.toggle_server_expand, "EXPAND_SERVER", { server.name }), @@ -468,7 +468,7 @@ local function ServerGroup(props) subtitle = props.subtitle, count = total_server_count, }, - Indent(functional.list_map(function(servers) + Indent(_.map(function(servers) return props.renderer(servers, props) end, props.servers)), } @@ -954,7 +954,7 @@ local function init(all_servers) mutate_state(function(state) state.is_showing_help = false - state.prioritized_servers = functional.set_of(prioritized_servers) + state.prioritized_servers = _.set_of(prioritized_servers) end) if not has_opened then |
