nvf icon indicating copy to clipboard operation
nvf copied to clipboard

utility/oil-nvim: key-value pair

Open SibaldH opened this issue 4 months ago • 2 comments

Hey,

I am having some trouble creating the key-values pairs for the setupOpts. I dont really understaind how the conversion works. Mostly with the keymaps. In the lua code, there is no key for the first element, but I guess the setupOpts requires one. So I dont really know what to do.

Nix code:

  setupOpts = {
      columns = [ "icon" ];
      keymaps = {
        "g?" = { "1" = "actions.show_help"; mode = "n"; };
        "<CR>" = "actions.select";
        "<C-p>" = "actions.preview";
        "<C-c>" = { "1" = "actions.close"; mode = "n"; };
        "<C-l>" = "actions.refresh";
        "<BS>" = { "1" = "actions.parent"; mode = "n"; };
        "<A-BS>" = { "1" = "actions.open_cwd"; mode = "n"; };
        "g." = { "1" = "actions.toggle_hidden"; mode = "n"; };
      };
      use_default_keymaps = false;
      view_options = {
        show_hidden = true;
      };
    };

original lua code:

		require("oil").setup({
			columns = {
				"icon",
				-- "permissions",
				-- "size",
				-- "mtime",
			},
			keymaps = {
				["g?"] = { "actions.show_help", mode = "n" },
				["<CR>"] = "actions.select",
				["<C-p>"] = "actions.preview",
				["<C-c>"] = { "actions.close", mode = "n" },
				["<C-l>"] = "actions.refresh",
				["<BS>"] = { "actions.parent", mode = "n" },
				["<A-BS>"] = { "actions.open_cwd", mode = "n" },
				["g."] = { "actions.toggle_hidden", mode = "n" },
				["gd"] = {
					desc = "Toggle file detail view",
					callback = function()
						detail = not detail
						if detail then
							require("oil").set_columns({ "icon", "permissions", "size", "mtime" })
						else
							require("oil").set_columns({ "icon" })
						end
					end,
				},
			},
			use_default_keymaps = false,
			view_options = {
				show_hidden = true,
			},
		})

SibaldH avatar Aug 09 '25 12:08 SibaldH

We had a special syntax for this, but I can't remember it for the death of me. @horriblename do you remember what it is, was it "@1"?

NotAShelf avatar Aug 09 '25 12:08 NotAShelf

Yes!! that's it. Thx!! Maybe add it to the manual https://notashelf.github.io/nvf/#sec-details-of-toluaobject

SibaldH avatar Aug 09 '25 12:08 SibaldH