From bf20bca78ddae7fd98ba98046014f3b06c8352ce Mon Sep 17 00:00:00 2001 From: Juan David Merchan Torres Date: Wed, 29 Mar 2023 14:47:47 -0500 Subject: [PATCH 01/11] feat(config): Add custom icons --- lua/oil/config.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/oil/config.lua b/lua/oil/config.lua index 86d978e..60cd537 100644 --- a/lua/oil/config.lua +++ b/lua/oil/config.lua @@ -22,6 +22,11 @@ local default_config = { conceallevel = 3, concealcursor = "n", }, + -- Custom icons + icons = { + default_file = "", + directory = " ", + }, -- Oil will take over directory buffers (e.g. `vim .` or `:e src/` default_file_explorer = true, -- Restore window options to previous values when leaving an oil buffer From 6dc65dcf83dbd68a031d848dde61d104e6209b0c Mon Sep 17 00:00:00 2001 From: Juan David Merchan Torres Date: Wed, 29 Mar 2023 14:48:00 -0500 Subject: [PATCH 02/11] feat(columns): Change to use custom icons --- lua/oil/columns.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/oil/columns.lua b/lua/oil/columns.lua index ca0e978..949cee3 100644 --- a/lua/oil/columns.lua +++ b/lua/oil/columns.lua @@ -205,12 +205,12 @@ if has_devicons then end end if type == "directory" then - return { " ", "OilDir" } + return { config.icons.directory, "OilDir" } else local icon local hl icon, hl = devicons.get_icon(name) - icon = icon or "" + icon = icon or config.icons.default_file return { icon .. " ", hl } end end, From f09256c1ded79a266c55822d91ec42b7d67c2f8c Mon Sep 17 00:00:00 2001 From: Juan David Merchan Torres Date: Wed, 29 Mar 2023 14:53:00 -0500 Subject: [PATCH 03/11] docs(root): Add custom icons to options section --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 165bd53..4a33d0b 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,11 @@ require("oil").setup({ conceallevel = 3, concealcursor = "n", }, + -- Custom icons + icons = { + default_file = "", + directory = " ", + }, -- Oil will take over directory buffers (e.g. `vim .` or `:e src/` default_file_explorer = true, -- Restore window options to previous values when leaving an oil buffer From 4a103df99de5e0fb05df49cf9d653a7b2688274b Mon Sep 17 00:00:00 2001 From: Juan David Merchan Torres Date: Wed, 29 Mar 2023 14:53:44 -0500 Subject: [PATCH 04/11] docs(doc): Add custom icons to options section --- doc/oil.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/oil.txt b/doc/oil.txt index e9e5190..a4aa2ec 100644 --- a/doc/oil.txt +++ b/doc/oil.txt @@ -37,6 +37,11 @@ OPTIONS *oil-option conceallevel = 3, concealcursor = "n", }, + -- Custom icons + icons = { + default_file = "", + directory = " ", + }, -- Oil will take over directory buffers (e.g. `vim .` or `:e src/` default_file_explorer = true, -- Restore window options to previous values when leaving an oil buffer From cb54e034905ea67c7dd20008952203f0f7b4ed08 Mon Sep 17 00:00:00 2001 From: Juan David Merchan Torres Date: Fri, 31 Mar 2023 14:27:01 -0500 Subject: [PATCH 05/11] feat(config): Change custom icons to columns config --- lua/oil/config.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lua/oil/config.lua b/lua/oil/config.lua index 60cd537..9a22d80 100644 --- a/lua/oil/config.lua +++ b/lua/oil/config.lua @@ -2,7 +2,7 @@ local default_config = { -- Id is automatically added at the beginning, and name at the end -- See :help oil-columns columns = { - "icon", + { "icon", default_file = "", directory = " " }, -- "permissions", -- "size", -- "mtime", @@ -22,11 +22,6 @@ local default_config = { conceallevel = 3, concealcursor = "n", }, - -- Custom icons - icons = { - default_file = "", - directory = " ", - }, -- Oil will take over directory buffers (e.g. `vim .` or `:e src/` default_file_explorer = true, -- Restore window options to previous values when leaving an oil buffer From c19f2d74de8dc6b60b878dcf41521f1622e5b010 Mon Sep 17 00:00:00 2001 From: Juan David Merchan Torres Date: Fri, 31 Mar 2023 14:27:53 -0500 Subject: [PATCH 06/11] refactor(columns): Add custom icons from conf param --- lua/oil/columns.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/oil/columns.lua b/lua/oil/columns.lua index 949cee3..f3453c8 100644 --- a/lua/oil/columns.lua +++ b/lua/oil/columns.lua @@ -205,12 +205,12 @@ if has_devicons then end end if type == "directory" then - return { config.icons.directory, "OilDir" } + return { conf.directory, "OilDir" } else local icon local hl icon, hl = devicons.get_icon(name) - icon = icon or config.icons.default_file + icon = icon or conf.default_file return { icon .. " ", hl } end end, From 4c528a0ad851fa1711d891cd20fdd3efe18ade4e Mon Sep 17 00:00:00 2001 From: Juan David Merchan Torres Date: Fri, 31 Mar 2023 14:28:34 -0500 Subject: [PATCH 07/11] docs(root): Change custom icons to columns config --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 4a33d0b..1824ed2 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ require("oil").setup({ -- Id is automatically added at the beginning, and name at the end -- See :help oil-columns columns = { - "icon", + { "icon", default_file = "", directory = " " }, -- "permissions", -- "size", -- "mtime", @@ -132,11 +132,6 @@ require("oil").setup({ conceallevel = 3, concealcursor = "n", }, - -- Custom icons - icons = { - default_file = "", - directory = " ", - }, -- Oil will take over directory buffers (e.g. `vim .` or `:e src/` default_file_explorer = true, -- Restore window options to previous values when leaving an oil buffer From f687b721e91454413e32d252ea0a094d643e8877 Mon Sep 17 00:00:00 2001 From: Juan David Merchan Torres Date: Fri, 31 Mar 2023 14:29:59 -0500 Subject: [PATCH 08/11] docs(doc): Change custom icons to columns config --- doc/oil.txt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/doc/oil.txt b/doc/oil.txt index a4aa2ec..08c3908 100644 --- a/doc/oil.txt +++ b/doc/oil.txt @@ -17,7 +17,7 @@ OPTIONS *oil-option -- Id is automatically added at the beginning, and name at the end -- See :help oil-columns columns = { - "icon", + { "icon", default_file = "", directory = " " }, -- "permissions", -- "size", -- "mtime", @@ -37,11 +37,6 @@ OPTIONS *oil-option conceallevel = 3, concealcursor = "n", }, - -- Custom icons - icons = { - default_file = "", - directory = " ", - }, -- Oil will take over directory buffers (e.g. `vim .` or `:e src/` default_file_explorer = true, -- Restore window options to previous values when leaving an oil buffer From 98a186e8f9bd12621f988e95e8dbc4c67f0f3167 Mon Sep 17 00:00:00 2001 From: Juan David Merchan Torres Date: Sun, 2 Apr 2023 18:31:02 -0500 Subject: [PATCH 09/11] feat(columns): Add compatibility with previous versions --- lua/oil/columns.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/oil/columns.lua b/lua/oil/columns.lua index f3453c8..4225edf 100644 --- a/lua/oil/columns.lua +++ b/lua/oil/columns.lua @@ -205,12 +205,12 @@ if has_devicons then end end if type == "directory" then - return { conf.directory, "OilDir" } + return { conf.directory or " ", "OilDir" } else local icon local hl icon, hl = devicons.get_icon(name) - icon = icon or conf.default_file + icon = icon or conf.default_file or "" return { icon .. " ", hl } end end, From f6d2102e2b671ffe28029c0b4b0915e625c3f09f Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Tue, 11 Apr 2023 08:27:41 -0700 Subject: [PATCH 10/11] fix: icon column does nil-check of config --- lua/oil/columns.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/oil/columns.lua b/lua/oil/columns.lua index 4225edf..03c4620 100644 --- a/lua/oil/columns.lua +++ b/lua/oil/columns.lua @@ -205,12 +205,13 @@ if has_devicons then end end if type == "directory" then - return { conf.directory or " ", "OilDir" } + local icon = conf and conf.directory or " " + return { icon, "OilDir" } else local icon local hl icon, hl = devicons.get_icon(name) - icon = icon or conf.default_file or "" + icon = icon or (conf and conf.default_file or "") return { icon .. " ", hl } end end, From 54af7e013d65ccf7dc7f4f943982771a620e87ec Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Tue, 11 Apr 2023 08:28:03 -0700 Subject: [PATCH 11/11] doc: put documentation of icon config parameters in correct place --- .github/generate.py | 6 +++++- README.md | 2 +- doc/oil.txt | 9 ++++++--- lua/oil/config.lua | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/generate.py b/.github/generate.py index 8477266..d6abe65 100755 --- a/.github/generate.py +++ b/.github/generate.py @@ -100,7 +100,11 @@ COL_DEFS = [ "*", False, "An icon for the entry's type (requires nvim-web-devicons)", - HL + [], + HL + + [ + LuaParam("default_file", "string", "Fallback icon for files when nvim-web-devicons returns nil"), + LuaParam("directory", "string", "Icon for directories"), + ], ), ColumnDef("size", "files, ssh", False, "The size of the file", HL + []), ColumnDef( diff --git a/README.md b/README.md index 1824ed2..165bd53 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ require("oil").setup({ -- Id is automatically added at the beginning, and name at the end -- See :help oil-columns columns = { - { "icon", default_file = "", directory = " " }, + "icon", -- "permissions", -- "size", -- "mtime", diff --git a/doc/oil.txt b/doc/oil.txt index 08c3908..6c4f808 100644 --- a/doc/oil.txt +++ b/doc/oil.txt @@ -17,7 +17,7 @@ OPTIONS *oil-option -- Id is automatically added at the beginning, and name at the end -- See :help oil-columns columns = { - { "icon", default_file = "", directory = " " }, + "icon", -- "permissions", -- "size", -- "mtime", @@ -218,8 +218,11 @@ icon *column-ico An icon for the entry's type (requires nvim-web-devicons) Parameters: - {highlight} `string|fun(value: string): string` Highlight group, or - function that returns a highlight group + {highlight} `string|fun(value: string): string` Highlight group, or + function that returns a highlight group + {default_file} `string` Fallback icon for files when nvim-web-devicons + returns nil + {directory} `string` Icon for directories size *column-size* Adapters: files, ssh diff --git a/lua/oil/config.lua b/lua/oil/config.lua index 9a22d80..86d978e 100644 --- a/lua/oil/config.lua +++ b/lua/oil/config.lua @@ -2,7 +2,7 @@ local default_config = { -- Id is automatically added at the beginning, and name at the end -- See :help oil-columns columns = { - { "icon", default_file = "", directory = " " }, + "icon", -- "permissions", -- "size", -- "mtime",