Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: show_hidden causes an error #548

Closed
3 tasks done
kekscode opened this issue Jan 4, 2025 · 4 comments
Closed
3 tasks done

bug: show_hidden causes an error #548

kekscode opened this issue Jan 4, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@kekscode
Copy link

kekscode commented Jan 4, 2025

Did you check the docs and existing issues?

  • I have read the docs
  • I have searched the existing issues

Neovim version (nvim -v)

NVIM v0.10.3

Operating system/version

MacOS 15.2 (24C101)

Describe the bug

The show_hidden configuration is set to true in my configuration and this worked before, but stopped working recently throwing an error message.

What is the severity of this bug?

tolerable (can work around it)

Steps To Reproduce

When using this configuration, my oil.nvim configuration does not work anymore with the most recent version (but worked before). It likely is an issue with hidden file handling or a side-effect occuring somewhere in this part of the code, but i am guessing. Here are the details:

My configuration which stopped working recently:

	{
		"stevearc/oil.nvim", -- an awesome file manager
		enabled = true,
		config = function()
			local oil = require("oil")
			require("oil").setup({
				-- Oil will take over directory buffers (e.g. `vim .` or `:e src/`)
				-- Set to false if you still want to use netrw.
				default_file_explorer = true,
				watch_for_changes = true,
				-- Buffer-local options to use for oil buffers
				buf_options = {
					buflisted = false,
					bufhidden = "hide",
				},
				columns = {
					-- "type",
					"icon",
					"permissions",
					-- { "atime",     format = "%Y-%m-%d %H:%M" },
					-- { "ctime",     format = "%Y-%m-%d %H:%M" },
					-- { "birthtime", format = "%Y-%m-%d %H:%M" },
					{ "mtime", format = "%Y-%m-%d %H:%M" },
					-- "size",
				},
				-- Window-local options to use for oil buffers
				win_options = {
					wrap = false,
					signcolumn = "no",
					cursorcolumn = false,
					foldcolumn = "0",
					spell = false,
					list = false,
					conceallevel = 3,
					concealcursor = "nvic",
					number = false,
				},
				-- Restore window options to previous values when leaving an oil buffer
				restore_win_options = true,
				-- Skip the confirmation popup for simple operations
				skip_confirm_for_simple_edits = true,
				use_default_keymaps = false,
				view_options = {
					-- Show files and directories that start with "."
					show_hidden = false,
					natural_order = false,
					sort = {
						-- sort order can be "asc" or "desc"
						-- see :help oil-columns to see which columns are sortable
						{ "type", "asc" },
						{ "name", "asc" },
					},
				},
				-- Configuration for the floating window in oil.open_float
				float = {
					-- Padding around the floating window
					padding = 2,
					max_width = 0,
					max_height = 0,
					border = "none",
					win_options = {
						winblend = 10, -- transparency
					},
				},
				-- Id is automatically added at the beginning, and name at the end
				-- See :help oil-columns
				keymaps = {
					-- Keymaps in oil buffer. Can be any value that `vim.keymap.set` accepts OR a table of keymap
					-- options with a `callback` (e.g. { callback = function() ... end, desc = "", nowait = true })
					-- Additionally, if it is a string that matches "actions.<name>",
					-- it will use the mapping at require("oil.actions").<name>
					-- Set to `false` to remove a keymap
					-- See :help oil-actions for a list of all available actions
					-- Template:
					-- [""] = { callback = "actions.", mode = "n" },

					-- get out
					["q"] = { callback = "actions.close", mode = "n" },
					["<ESC>"] = { callback = "actions.close", mode = "n" },

					-- refresh
					["<C-r>"] = { callback = "actions.refresh", mode = "n" },

					-- interact
					["<CR>"] = { callback = "actions.select", mode = "n" },
					["L"] = { callback = "actions.select", mode = "n" },

					["<BS>"] = { callback = "actions.parent", mode = "n" },
					["-"] = { callback = "actions.parent", mode = "n" },
					["H"] = { callback = "actions.parent", mode = "n" },

					-- preview
					["<C-p>"] = { callback = "actions.preview", mode = "n" },

					-- splits and tabs
					["<leader>v"] = {
						"actions.select",
						opts = { vertical = true },
						desc = "Open the entry in a vertical split",
					},
					["<leader>s"] = {
						"actions.select",
						opts = { horizontal = true },
						desc = "Open the entry in a horizontal split",
					},
					[",t"] = { "actions.select", opts = { tab = true }, desc = "Open the entry in new tab" },

					-- set things
					["`"] = { callback = "actions.cd", mode = "n" },
					["~"] = { callback = "actions.tcd", mode = "n" },

					-- open external programm
					["go"] = "actions.open_external",
					["gx"] = "actions.open_external",

					-- more stuff
					["g."] = "actions.toggle_hidden",
					["gs"] = "actions.change_sort",
					["g?"] = { callback = "actions.show_help", mode = "n" },
				},
			})
		end,
	},

I get this error message:

Error executing vim.schedule lua callback: ...ocal/share/nvim/lazy/oil.nvim/lua/oil/adapters/files.lua:96: attempt to index local 'meta' (a nil value)
stack traceback:
	...ocal/share/nvim/lazy/oil.nvim/lua/oil/adapters/files.lua:96: in function 'render'
	.../user/.local/share/nvim/lazy/oil.nvim/lua/oil/columns.lua:72: in function 'render_col'
	.../user/.local/share/nvim/lazy/oil.nvim/lua/oil/view.lua:746: in function 'format_entry_cols'
	.../user/.local/share/nvim/lazy/oil.nvim/lua/oil/view.lua:647: in function 'render_buffer'
	.../user/.local/share/nvim/lazy/oil.nvim/lua/oil/view.lua:890: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

I did some digging in the code and based on that some try-and-error config changes and this works:

Using this configuration diff works:

                                view_options = {
                                        -- Show files and directories that start with "."
-                                       show_hidden = false,
+                                       show_hidden = true,
                                        natural_order = false,
                                        sort = {
                                                -- sort order can be "asc" or "desc"

Is this a bug or a side effect of my custom configuration (or both?)

Expected Behavior

I expected my config to keep working with recent releases. I didn't catch a configuration options deprecation in the docs, but I may overlook something?

Directory structure

./init.lua/lua/plugins/init.lua
./init.lua/lua/plugins/config/init.lua [...]

Repro

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
	vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system({
		"git",
		"clone",
		"--filter=blob:none",
		"--single-branch",
		"https://github.com/folke/lazy.nvim.git",
		lazypath,
	})
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
	"folke/tokyonight.nvim",
	{
		"stevearc/oil.nvim",
		config = function()
			require("oil").setup({
				-- Oil will take over directory buffers (e.g. `vim .` or `:e src/`)
				-- Set to false if you still want to use netrw.
				default_file_explorer = true,
				watch_for_changes = true,
				-- Buffer-local options to use for oil buffers
				buf_options = {
					buflisted = false,
					bufhidden = "hide",
				},
				columns = {
					-- "type",
					"icon",
					"permissions",
					-- { "atime",     format = "%Y-%m-%d %H:%M" },
					-- { "ctime",     format = "%Y-%m-%d %H:%M" },
					-- { "birthtime", format = "%Y-%m-%d %H:%M" },
					{ "mtime", format = "%Y-%m-%d %H:%M" },
					-- "size",
				},
				-- Window-local options to use for oil buffers
				win_options = {
					wrap = false,
					signcolumn = "no",
					cursorcolumn = false,
					foldcolumn = "0",
					spell = false,
					list = false,
					conceallevel = 3,
					concealcursor = "nvic",
					number = false,
				},
				-- Restore window options to previous values when leaving an oil buffer
				restore_win_options = true,
				-- Skip the confirmation popup for simple operations
				skip_confirm_for_simple_edits = true,
				use_default_keymaps = false,
				view_options = {
					-- Show files and directories that start with "."
					show_hidden = true,
					natural_order = false,
					sort = {
						-- sort order can be "asc" or "desc"
						-- see :help oil-columns to see which columns are sortable
						{ "type", "asc" },
						{ "name", "asc" },
					},
				},
				-- Configuration for the floating window in oil.open_float
				float = {
					-- Padding around the floating window
					padding = 2,
					max_width = 0,
					max_height = 0,
					border = "none",
					win_options = {
						winblend = 10, -- transparency
					},
				},
				-- Id is automatically added at the beginning, and name at the end
				-- See :help oil-columns
				keymaps = {
					-- Keymaps in oil buffer. Can be any value that `vim.keymap.set` accepts OR a table of keymap
					-- options with a `callback` (e.g. { callback = function() ... end, desc = "", nowait = true })
					-- Additionally, if it is a string that matches "actions.<name>",
					-- it will use the mapping at require("oil.actions").<name>
					-- Set to `false` to remove a keymap
					-- See :help oil-actions for a list of all available actions
					-- Template:
					-- [""] = { callback = "actions.", mode = "n" },

					-- get out
					["q"] = { callback = "actions.close", mode = "n" },
					["<ESC>"] = { callback = "actions.close", mode = "n" },

					-- refresh
					["<C-r>"] = { callback = "actions.refresh", mode = "n" },

					-- interact
					["<CR>"] = { callback = "actions.select", mode = "n" },
					["L"] = { callback = "actions.select", mode = "n" },

					["<BS>"] = { callback = "actions.parent", mode = "n" },
					["-"] = { callback = "actions.parent", mode = "n" },
					["H"] = { callback = "actions.parent", mode = "n" },

					-- preview
					["<C-p>"] = { callback = "actions.preview", mode = "n" },

					-- splits and tabs
					["<leader>v"] = {
						"actions.select",
						opts = { vertical = true },
						desc = "Open the entry in a vertical split",
					},
					["<leader>s"] = {
						"actions.select",
						opts = { horizontal = true },
						desc = "Open the entry in a horizontal split",
					},
					[",t"] = { "actions.select", opts = { tab = true }, desc = "Open the entry in new tab" },

					-- set things
					["`"] = { callback = "actions.cd", mode = "n" },
					["~"] = { callback = "actions.tcd", mode = "n" },

					-- open external programm
					["go"] = "actions.open_external",
					["gx"] = "actions.open_external",

					-- more stuff
					["g."] = "actions.toggle_hidden",
					["gs"] = "actions.change_sort",
					["g?"] = { callback = "actions.show_help", mode = "n" },
				},
			})
		end,
	},
	-- add any other plugins here
}
require("lazy").setup(plugins, {
	root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Did you check the bug with a clean config?

  • I have confirmed that the bug reproduces with nvim -u repro.lua using the repro.lua file above.
@kekscode kekscode added the bug Something isn't working label Jan 4, 2025
@JohnWilliston
Copy link

I have this same issue. Thanks for posting the workaround. I look forward to a fix.

@stevearc
Copy link
Owner

stevearc commented Jan 4, 2025

I believe I've fixed it, but I was unable to reproduce the issue on my local machine. Can you confirm that the fix worked?

@stevearc stevearc added the question Further information is requested label Jan 4, 2025
@kmoschcau
Copy link

That seems to have fixed the issue for me at least.

@github-actions github-actions bot removed the question Further information is requested label Jan 4, 2025
@JohnWilliston
Copy link

Can confirm fixed for me too. Thanks!

@stevearc stevearc closed this as completed Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants