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

Template configuration fails with lazy.nvim #25

Open
ChausseBenjamin opened this issue Nov 7, 2023 · 1 comment
Open

Template configuration fails with lazy.nvim #25

ChausseBenjamin opened this issue Nov 7, 2023 · 1 comment

Comments

@ChausseBenjamin
Copy link

I tried porting your configuration to the lazy.nvim package manager. This is what I got:

return {
  "lmburns/lf.nvim",
  dependencies = {
    {
      "akinsho/toggleterm.nvim",
      version = "*",
      config = true, -- Runs require("toggleterm").setup()
    },
  },
  config = function()
    vim.g.lf_netrw = 1
    require("lf").setup()
    vim.api.nvim_create_autocmd({
      event = "User",
      pattern = "LfTermEnter",
      callback = function(a)
        vim.api.nvim_buf_set_keymap(a.buf, "t", "q", "q", { nowait = true })
      end,
    })
  end,
}

The one bit that seems to be having issues is the autocmd. Without it, nvim launches fine (but lf doesn't seem to work). With it, nvim gives me the following error at launch:

Failed to run `config` for lf.nvim

/home/master/.config/nvim/lua/ben/plugins/lf.lua:13: Expected 2 arguments

# stacktrace:
  - lua/ben/plugins/lf.lua:13 _in_ **config**
  - lua/ben/lazy.lua:13
  - init.lua:2
Press ENTER or type command to continue
@knuffelbeer
Copy link

I had the same. the event "User" should be the first argument in the autocommand, and the rest of the array the second. In the default code the event is defined in the array, which causes the error. This code worked for me:

{
"lmburns/lf.nvim",
config = function()
-- This feature will not work if the plugin is lazy-loaded
vim.g.lf_netrw = 1

    require("lf").setup({
        escape_quit = false,
        border = "rounded",
     })
    vim.api.nvim_create_autocmd(
         "User",{
        pattern = "LfTermEnter",
        callback = function(a)
            vim.api.nvim_buf_set_keymap(a.buf, "t", "q", "q", {nowait = true})
        end,
    })
end,
requires = {"toggleterm.nvim"}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants