From 4c743a2afb87994be4ff7c2dc76d21c70d31e4de Mon Sep 17 00:00:00 2001 From: Soispha Date: Sat, 26 Aug 2023 22:52:12 +0200 Subject: Style(treewide): Format all lua-files makes lua ➛ nix easier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The files were formatted according to the `.editorconfig` file and with the formatter from [this](1) repo, as it's the only one that fully understands all keys in the `.editorconfig` file. The formatting was chosen in this special (and honestly unconventional) way because moving code from lua to nix is now easier, as the syntax is nearly identical in some places. --- .../lsp-progress-nvim/lua/lsp-progress-nvim.lua | 276 ++++++++++----------- 1 file changed, 133 insertions(+), 143 deletions(-) (limited to 'home-manager/soispha/config/neovim/nixvim/plugins/lsp-progress-nvim/lua/lsp-progress-nvim.lua') diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/lsp-progress-nvim/lua/lsp-progress-nvim.lua b/home-manager/soispha/config/neovim/nixvim/plugins/lsp-progress-nvim/lua/lsp-progress-nvim.lua index 80c01e4a..4273085c 100644 --- a/home-manager/soispha/config/neovim/nixvim/plugins/lsp-progress-nvim/lua/lsp-progress-nvim.lua +++ b/home-manager/soispha/config/neovim/nixvim/plugins/lsp-progress-nvim/lua/lsp-progress-nvim.lua @@ -1,160 +1,150 @@ --- @type table require("lsp-progress").setup({ - -- Spinning icons. - -- - --- @type string[] - spinner = { "⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷" }, + -- Spinning icons. + -- + --- @type string[] + spinner = { "⣾"; "⣽"; "⣻"; "⢿"; "⡿"; "⣟"; "⣯"; "⣷"; }; - -- Spinning update time in milliseconds. - -- - --- @type integer - spin_update_time = 200, + -- Spinning update time in milliseconds. + -- + --- @type integer + spin_update_time = 200; - -- Last message cached decay time in milliseconds. - -- - -- Message could be really fast(appear and disappear in an - -- instant) that user cannot even see it, thus we cache the last message - -- for a while for user view. - -- - --- @type integer - decay = 700, + -- Last message cached decay time in milliseconds. + -- + -- Message could be really fast(appear and disappear in an + -- instant) that user cannot even see it, thus we cache the last message + -- for a while for user view. + -- + --- @type integer + decay = 700; - -- User event name. - -- - --- @type string - event = "LspProgressStatusUpdated", + -- User event name. + -- + --- @type string + event = "LspProgressStatusUpdated"; - -- Event update time limit in milliseconds. - -- - -- Sometimes progress handler could emit many events in an instant, while - -- refreshing statusline cause too heavy synchronized IO, so we limit the - -- event rate to reduce this cost. - -- - --- @type integer - event_update_time_limit = 100, + -- Event update time limit in milliseconds. + -- + -- Sometimes progress handler could emit many events in an instant, while + -- refreshing statusline cause too heavy synchronized IO, so we limit the + -- event rate to reduce this cost. + -- + --- @type integer + event_update_time_limit = 100; - -- Max progress string length, by default -1 is unlimited. - -- - --- @type integer - max_size = -1, + -- Max progress string length, by default -1 is unlimited. + -- + --- @type integer + max_size = -1; - -- Regular internal update time. - -- - -- Emit user event to update the lsp progress status, even there's no new - -- message. - -- - --- @type integer - regular_internal_update_time = 500, + -- Regular internal update time. + -- + -- Emit user event to update the lsp progress status, even there's no new + -- message. + -- + --- @type integer + regular_internal_update_time = 500; - -- Disable emitting events on specific mode/filetype. - -- User events would interrupt insert mode, thus break which-key like plugins behaviour. - -- See: - -- * https://github.com/linrongbin16/lsp-progress.nvim/issues/50 - -- * https://neovim.io/doc/user/builtin.html#mode() - -- - --- @type table[] - disable_events_opts = { - { - mode = "i", - filetype = "TelescopePrompt", - }, - }, + -- Disable emitting events on specific mode/filetype. + -- User events would interrupt insert mode, thus break which-key like plugins behaviour. + -- See: + -- * https://github.com/linrongbin16/lsp-progress.nvim/issues/50 + -- * https://neovim.io/doc/user/builtin.html#mode() + -- + --- @type table[] + disable_events_opts = { { mode = "i"; filetype = "TelescopePrompt"; }; }; - -- Format series message. - -- - -- By default it looks like: `formatting isort (100%) - done`. - -- - --- @param title string|nil - --- Message title. - --- @param message string|nil - --- Message body. - --- @param percentage number|nil - --- Progress in percentage numbers: 0-100. - --- @param done boolean - --- Indicate whether this series is the last one in progress. - --- @return string|nil messages - --- The returned value will be passed to function `client_format` as - --- one of the `series_messages` array, or ignored if return nil. - series_format = function(title, message, percentage, done) - local builder = {} - local has_title = false - local has_message = false - if title and title ~= "" then - table.insert(builder, title) - has_title = true - end - if message and message ~= "" then - table.insert(builder, message) - has_message = true - end - if percentage and (has_title or has_message) then - table.insert(builder, string.format("(%.0f%%%%)", percentage)) - end - if done and (has_title or has_message) then - table.insert(builder, "- done") - end - return table.concat(builder, " ") - end, + -- Format series message. + -- + -- By default it looks like: `formatting isort (100%) - done`. + -- + --- @param title string|nil + --- Message title. + --- @param message string|nil + --- Message body. + --- @param percentage number|nil + --- Progress in percentage numbers: 0-100. + --- @param done boolean + --- Indicate whether this series is the last one in progress. + --- @return string|nil messages + --- The returned value will be passed to function `client_format` as + --- one of the `series_messages` array, or ignored if return nil. + series_format = function(title, message, percentage, done) + local builder = {} + local has_title = false + local has_message = false + if title and title ~= "" then + table.insert(builder, title) + has_title = true + end + if message and message ~= "" then + table.insert(builder, message) + has_message = true + end + if percentage and (has_title or has_message) then + table.insert(builder, string.format("(%.0f%%%%)", percentage)) + end + if done and (has_title or has_message) then + table.insert(builder, "- done") + end + return table.concat(builder, " ") + end; - -- Format client message. - -- - -- By default it looks like: - -- `[null-ls] ⣷ formatting isort (100%) - done, formatting black (50%)`. - -- - --- @param client_name string - --- Client name. - --- @param spinner string - --- Spinner icon. - --- @param series_messages string[]|table[] - --- Messages array. - --- @return string|nil messages - --- The returned value will be passed to function `format` as one of the - --- `client_messages` array, or ignored if return nil. - client_format = function(client_name, spinner, series_messages) - return #series_messages > 0 - and ("[" .. client_name .. "] " .. spinner .. " " .. table.concat( - series_messages, - ", " - )) - or nil - end, + -- Format client message. + -- + -- By default it looks like: + -- `[null-ls] ⣷ formatting isort (100%) - done, formatting black (50%)`. + -- + --- @param client_name string + --- Client name. + --- @param spinner string + --- Spinner icon. + --- @param series_messages string[]|table[] + --- Messages array. + --- @return string|nil messages + --- The returned value will be passed to function `format` as one of the + --- `client_messages` array, or ignored if return nil. + client_format = function(client_name, spinner, series_messages) + return #series_messages > 0 + and ("[" .. client_name .. "] " .. spinner .. " " .. table.concat(series_messages, ", ")) + or nil + end; - -- Format (final) message. - -- - -- By default it looks like: - -- ` LSP [null-ls] ⣷ formatting isort (100%) - done, formatting black (50%)` - -- - --- @param client_messages string[]|table[] - --- Client messages array. - --- @return nil|string message - --- The returned value will be returned from `progress` API. - format = function(client_messages) - local sign = " LSP" -- nf-fa-gear \uf013 - return #client_messages > 0 - and (sign .. " " .. table.concat(client_messages, " ")) - or sign - end, + -- Format (final) message. + -- + -- By default it looks like: + -- ` LSP [null-ls] ⣷ formatting isort (100%) - done, formatting black (50%)` + -- + --- @param client_messages string[]|table[] + --- Client messages array. + --- @return nil|string message + --- The returned value will be returned from `progress` API. + format = function(client_messages) + local sign = " LSP" -- nf-fa-gear \uf013 + return #client_messages > 0 and (sign .. " " .. table.concat(client_messages, " ")) or sign + end; - -- Enable debug. - -- - --- @type boolean - debug = false, + -- Enable debug. + -- + --- @type boolean + debug = false; - -- Print log to console(command line). - -- - --- @type boolean - console_log = false, + -- Print log to console(command line). + -- + --- @type boolean + console_log = false; - -- Print log to file. - -- - --- @type boolean - file_log = true, + -- Print log to file. + -- + --- @type boolean + file_log = true; - -- Log file to write, work with `file_log=true`. - -- - -- For Windows: `$env:USERPROFILE\AppData\Local\nvim-data\lsp-progress.log`. - -- For *NIX: `~/.local/share/nvim/lsp-progress.log`. - -- - --- @type string - file_log_name = "lsp-progress.log", + -- Log file to write, work with `file_log=true`. + -- + -- For Windows: `$env:USERPROFILE\AppData\Local\nvim-data\lsp-progress.log`. + -- For *NIX: `~/.local/share/nvim/lsp-progress.log`. + -- + --- @type string + file_log_name = "lsp-progress.log"; }) -- cgit 1.4.1