b0o / nvim-tree-preview.lua

🍃 Floating preview windows for nvim-tree
MIT License
59 stars 2 forks source link

`title_pos` not set (or even set) but it still errors out: `title_pos must be one of top-left, top-center, top-right, bottom-left, bottom-center, bottom-right` #6

Closed kohane27 closed 2 months ago

kohane27 commented 2 months ago

Hello! Hope you're doing well. Thank you for maintaining this plugin.

I have the following error after an update:

Failed to run `config` for nvim-tree-preview.lua

...y/nvim-tree-preview.lua/lua/nvim-tree-preview/config.lua:36: title_pos must be one of top-left, top-center, top-right, bottom-left, bottom-center, bottom-right

# stacktrace:
  - lua/plugins/nvim-tree-preview.lua:41 _in_ **config**

My config:

return {
  "b0o/nvim-tree-preview.lua",
  event = "VeryLazy",
  opts = {
    keymaps = {
      ["<Esc>"] = { action = "close", unwatch = true },
      ["<Tab>"] = { action = "toggle_focus" },
      ["<CR>"] = { open = "edit" },
      ["<C-w>t"] = { open = "tab" },
      ["<C-w>v"] = { open = "vertical" },
      ["<C-w>s"] = { open = "horizontal" },
    },
  },
  config = function(_, opts)
    local preview = require("nvim-tree-preview")
    preview.setup(opts)
  end,
}

Even if I set title_pos = "top-left", the error still persists.

Using commit = "e968df027d86797556e9bf5f1d5ffca87045150d", has no issue.

Thank you!

Wppopqpu commented 2 months ago

maybe use vim.tbl_contains to check the title_pos option ?


lua/nvim-tree-preview/config.lua, line 36

assert(
    ({
      'top-left',
      'top-center',
      'top-right',
      'bottom-left',
      'bottom-center',
      'bottom-right',
    })[M.config.title_pos],
    'title_pos must be one of top-left, top-center, top-right, bottom-left, bottom-center, bottom-right'
  )

this assumes title_pos is an integer index, but it is not.

mimikun commented 2 months ago

I have same issue too.

b0o commented 2 months ago

Sorry about the slow response! Should be fixed now.

kohane27 commented 2 months ago

@b0o Thank you for the fix. I can confirm the plugin is working now. Thank you!:)