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: E127 Cannot redefine function #235

Closed
3 tasks done
dimbleby opened this issue Dec 29, 2022 · 1 comment · Fixed by #238
Closed
3 tasks done

bug: E127 Cannot redefine function #235

dimbleby opened this issue Dec 29, 2022 · 1 comment · Fixed by #238
Labels
bug Something isn't working

Comments

@dimbleby
Copy link

dimbleby commented Dec 29, 2022

Did you check docs and existing issues?

  • I have read all the lazy docs
  • I have searched the existing issues of lazy
  • I have searched the exsiting issues of the plugin I have a problem with

Neovim version (nvim -v)

NVIM v0.9.0-dev-580+g4703e561d

Operating system/version

Ubuntu 22.0.4

Describe the bug

When using fzf-lua's previewer to search for text that appears in a rust file (EDIT or just when opening a rust file, see follow-up comment):

Failed to source `/home/dch/.local/share/nvim/lazy/rust.vim/ftdetect/rust.vim`
...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:303: Vim(function):E127: Cannot redefine function <SNR>5_set_rust_filetype: It is in use
# stacktrace:
  - /fzf-lua/lua/fzf-lua/previewer/builtin.lua:589
  - /fzf-lua/lua/fzf-lua/previewer/builtin.lua:588 _in_ **do_syntax**
  - /fzf-lua/lua/fzf-lua/previewer/builtin.lua:661 _in_ **preview_buf_post**
  - /fzf-lua/lua/fzf-lua/previewer/builtin.lua:538 _in_ ****
  - vim/_editor.lua:0

which seems surprising, rust.vim goes function!, I thought I understood that the meaning of the exclamation mark was exactly to make this not happen

I'm experimenting with the switch from packer to lazy.nvim, and still have a computer with the packer setup - and can confirm that the problem does not reproduce there. So while I could imagine this turning out to be a bug elsewhere, I'm starting with lazy.nvim.

Steps To Reproduce

  1. Have a rust project eg https://github.com/dimbleby/rust-c-ares
  2. Open a file eg Cargo.toml
  3. fzf-lua live_grep_native() for something eg "metadep". (I've mapped the fzf-lua function to <Leader>r in the repro.lua below)
  4. scroll down the preview until you hit a rust file containing that text

Expected Behavior

No errors

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "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",
  { "rust-lang/rust.vim", ft = "rust" },
  {
    "ibhagwan/fzf-lua",
    lazy = true,
    config = function()
      require("fzf-lua").setup({})
    end,
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")

vim.keymap.set("n", "<Leader>r", function()
  require("fzf-lua").live_grep_native()
end, { noremap = true })
@dimbleby dimbleby added the bug Something isn't working label Dec 29, 2022
@dimbleby
Copy link
Author

oh actually I seem to be able to reproduce this error without involving fzf-lua at all: just opening a rust file is enough.

so that simplifies the repro, you can remove all fzf-lua related bits

Failed to source `/home/dch/rust-c-ares/.repro//plugins/rust.vim/ftdetect/rust.vim`
...c-ares/.repro/plugins/lazy.nvim/lua/lazy/core/loader.lua:303: Vim(function):E127: Cannot redefine function <SNR>4_set_rust_filetype: It is in use

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

Successfully merging a pull request may close this issue.

1 participant