From 28bcb1cdd44cbddc0a2ec3137caabacc350b41eb Mon Sep 17 00:00:00 2001 From: bekaboo <18127878294@qq.com> Date: Wed, 30 Oct 2024 21:48:44 -0400 Subject: [PATCH] fix(configs,sources.path): concat nil when icons disabled (#190) --- README.md | 16 ++++++++-------- doc/dropbar.txt | 8 ++++---- lua/dropbar/configs.lua | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 4d0524c0..28d41d7c 100644 --- a/README.md +++ b/README.md @@ -301,19 +301,19 @@ vim.ui.select = require('dropbar.utils.menu').select icons = { enable = true, kinds = { - ---Directory icon and highlighting getter, set to `false` to disable + ---Directory icon and highlighting getter, set to empty string to disable ---@param path string path to the directory ---@return string: icon for the directory ---@return string?: highlight group for the icon - ---@type fun(path: string): string, string?|false + ---@type fun(path: string): string, string?|string? dir_icon = function(_) return M.opts.icons.kinds.symbols.Folder, 'DropBarIconKindFolder' end, - ---File icon and highlighting getter, set to `false` to disable + ---File icon and highlighting getter, set to empty string to disable ---@param path string path to the file ---@return string: icon for the file ---@return string?: highlight group for the icon - ---@type fun(path: string): string, string?|false + ---@type fun(path: string): string, string?|string? file_icon = function(path) local icon_kind_opts = M.opts.icons.kinds local file_icon = icon_kind_opts.symbols.File @@ -1443,16 +1443,16 @@ used by the plugin: - `opts.icons.enable`: `boolean` - Whether to enable icons - Default: `true` -- `opts.icons.kinds.dir_icon`: `fun(path: string): string, string?|false` - - Directory icon and highlighting getter, set to `false` to disable +- `opts.icons.kinds.dir_icon`: `fun(path: string): string, string?|string?` + - Directory icon and highlighting getter, set to empty string to disable - Default: ```lua function(_) return M.opts.icons.kinds.symbols.Folder, 'DropBarIconKindFolder' end ``` -- `opts.icons.kinds.file_icon`: `fun(path: string): string, string?|false` - - File icon and highlighting getter, set to `false` to disable +- `opts.icons.kinds.file_icon`: `fun(path: string): string, string?|string?` + - File icon and highlighting getter, set to empty string to disable - Default: ```lua function(path) diff --git a/doc/dropbar.txt b/doc/dropbar.txt index 59a7442a..ed5b5de4 100644 --- a/doc/dropbar.txt +++ b/doc/dropbar.txt @@ -684,16 +684,16 @@ by the plugin: - `opts.icons.enable`: `boolean` - Whether to enable icons - Default: `true` -- `opts.icons.kinds.dir_icon`: `fun(path: string): string, string?|false` - - Directory icon and highlighting getter, set to `false` to disable +- `opts.icons.kinds.dir_icon`: `fun(path: string): string, string?|string?` + - Directory icon and highlighting getter, set to empty string to disable - Default: >lua function(_) return M.opts.icons.kinds.symbols.Folder, 'DropBarIconKindFolder' end < -- `opts.icons.kinds.file_icon`: `fun(path: string): string, string?|false` - - File icon and highlighting getter, set to `false` to disable +- `opts.icons.kinds.file_icon`: `fun(path: string): string, string?|string?` + - File icon and highlighting getter, set to empty string to disable - Default: >lua function(path) diff --git a/lua/dropbar/configs.lua b/lua/dropbar/configs.lua index 4b3c8316..b9957808 100644 --- a/lua/dropbar/configs.lua +++ b/lua/dropbar/configs.lua @@ -7,19 +7,19 @@ M.opts = { icons = { enable = true, kinds = { - ---Directory icon and highlighting getter, set to `false` to disable + ---Directory icon and highlighting getter, set to empty string to disable ---@param path string path to the directory ---@return string: icon for the directory ---@return string?: highlight group for the icon - ---@type fun(path: string): string, string?|false + ---@type fun(path: string): string, string?|string? dir_icon = function(_) return M.opts.icons.kinds.symbols.Folder, 'DropBarIconKindFolder' end, - ---File icon and highlighting getter, set to `false` to disable + ---File icon and highlighting getter, set to empty string to disable ---@param path string path to the file ---@return string: icon for the file ---@return string?: highlight group for the icon - ---@type fun(path: string): string, string?|false + ---@type fun(path: string): string, string?|string? file_icon = function(path) local icon_kind_opts = M.opts.icons.kinds local file_icon = icon_kind_opts.symbols.File @@ -771,8 +771,8 @@ function M.set(new_opts) return ' ' end, }) - M.opts.icons.kinds.dir_icon = false - M.opts.icons.kinds.file_icon = false + M.opts.icons.kinds.dir_icon = '' + M.opts.icons.kinds.file_icon = '' M.opts.icons.kinds.symbols = blank_icons M.opts.icons.ui.bar = blank_icons M.opts.icons.ui.menu = blank_icons