packer.nvim icon indicating copy to clipboard operation
packer.nvim copied to clipboard

packer repeatedly source .vim files many times from`vim-rmarkdown` and `vim-pandoc-syntax`

Open milanglacier opened this issue 3 years ago • 0 comments

  • nvim --version: NVIM v0.7.0-dev+1356-g75ff156d9
  • git --version: git version 2.32.0 (Apple Git-132)
  • Operating system/version: macOS 12.3
  • Terminal name/version: iterm 2 Build 3.4.15

Steps to reproduce

Actual behaviour

open an arbitrary rmd file, with --startuptime profiling, it shows that some filetype related files are sourced multiple of times. say nvim --startuptime profile.txt abc.rmd

See the startup time profiling:

000.005  000.005: --- NVIM STARTING ---
000.796  000.790: locale set
001.261  000.465: inits 1
001.280  000.019: window checked
001.470  000.190: parsing arguments
004.454  002.984: expanding arguments
004.491  000.037: inits 2
005.095  000.604: init highlight
005.096  000.001: waiting for UI
007.133  002.037: done waiting for UI
007.146  000.013: init screen for UI
007.169  000.022: init default mappings
007.204  000.035: init default autocommands
007.993  000.063  000.063: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/ftplugin.vim
008.112  000.034  000.034: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/indent.vim
011.260  003.032  003.032: sourcing /Users/northyear/.config/nvim/init.lua
011.267  000.934: sourcing vimrc file(s)
011.386  000.026  000.026: sourcing /Users/northyear/.local/share/nvim/site/pack/packer/start/filetype.nvim/filetype.vim
011.544  000.054  000.054: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/filetype.lua
011.625  000.017  000.017: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/filetype.vim
011.877  000.088  000.088: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/synload.vim
011.987  000.303  000.215: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/syntax.vim
013.369  000.161  000.161: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/plugin/gzip.vim
013.440  000.021  000.021: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/plugin/health.vim
013.522  000.037  000.037: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/plugin/man.vim
014.416  000.213  000.213: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim
014.575  000.997  000.784: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/plugin/matchit.vim
014.789  000.168  000.168: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/plugin/matchparen.vim
015.172  000.336  000.336: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/plugin/netrwPlugin.vim
015.519  000.015  000.015: sourcing /Users/northyear/.local/share/nvim/rplugin.vim
015.527  000.296  000.282: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/plugin/rplugin.vim
015.683  000.084  000.084: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/plugin/shada.vim
015.783  000.035  000.035: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/plugin/spellfile.vim
015.954  000.109  000.109: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/plugin/tarPlugin.vim
016.122  000.098  000.098: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/plugin/tohtml.vim
016.201  000.024  000.024: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/plugin/tutor.vim
016.398  000.137  000.137: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/plugin/zipPlugin.vim
017.953  000.019  000.019: sourcing /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown/ftdetect/rmarkdown.vim
018.033  000.023  000.023: sourcing /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown/ftdetect/rmd.vim
018.037  001.447  001.406: sourcing /Users/northyear/.config/nvim/plugin/packer_compiled.lua
018.503  002.886: loading rtp plugins
018.960  000.067  000.067: sourcing /Users/northyear/.local/share/nvim/site/pack/packer/start/FixCursorHold.nvim/plugin/fix_cursorhold_nvim.vim
019.413  000.031  000.031: sourcing /Users/northyear/.local/share/nvim/site/pack/packer/start/plenary.nvim/plugin/plenary.vim
019.605  001.004: loading packages
019.607  000.002: loading after plugins
019.640  000.033: inits 3
022.961  003.321: reading ShaDa
025.755  000.153  000.153: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/ftplugin/rmd.vim
027.880  000.229  000.229: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/indent/r.vim
028.103  000.548  000.319: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/indent/rmd.vim
029.528  000.238  000.238: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/javascript.vim
031.432  001.764  001.764: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/vb.vim
036.824  005.276  005.276: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/css.vim
038.006  009.399  002.121: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/html.vim
038.316  009.803  000.403: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/markdown.vim
039.098  000.679  000.679: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/r.vim
039.211  010.898  000.416: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/rmd.vim
040.049  000.016  000.016: sourcing /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown/ftdetect/rmarkdown.vim
040.107  000.018  000.018: sourcing /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown/ftdetect/rmd.vim
040.949  000.159  000.159: sourcing /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-pandoc-syntax/plugin/pandoc-syntax-check.vim
042.117  000.326  000.326: sourcing /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown/ftplugin/rmd.vim
042.306  000.109  000.109: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/ftplugin/rmd.vim
043.163  000.016  000.016: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/indent/r.vim
043.177  000.105  000.089: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/indent/rmd.vim
044.921  000.170  000.170: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/javascript.vim
046.429  001.390  001.390: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/vb.vim
052.239  005.723  005.723: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/css.vim
053.316  009.176  001.893: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/html.vim
060.966  007.535  007.535: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/tex.vim
061.972  000.312  000.312: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/python.vim
062.507  000.415  000.415: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/r.vim
063.030  000.407  000.407: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/r.vim
064.353  001.205  001.205: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/sh.vim
064.609  000.125  000.125: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/json.vim
065.514  000.479  000.479: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/yaml.vim
065.774  021.884  002.229: sourcing /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-pandoc-syntax/syntax/pandoc.vim
066.261  000.409  000.409: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/r.vim
066.648  000.256  000.256: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/python.vim
066.703  023.050  000.502: sourcing /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown/syntax/rmd.vim
066.769  000.011  000.011: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/rmd.vim
067.083  000.075  000.075: sourcing /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown/ftplugin/rmd.vim
067.232  000.084  000.084: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/ftplugin/rmd.vim
067.907  000.013  000.013: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/indent/r.vim
067.918  000.085  000.071: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/indent/rmd.vim
069.190  000.135  000.135: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/javascript.vim
070.400  001.123  001.123: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/vb.vim
076.522  006.055  006.055: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/css.vim
077.718  009.114  001.801: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/html.vim
084.389  006.578  006.578: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/tex.vim
085.184  000.259  000.259: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/python.vim
085.661  000.375  000.375: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/r.vim
086.123  000.357  000.357: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/r.vim
087.256  001.026  001.026: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/sh.vim
087.476  000.101  000.101: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/json.vim
088.277  000.424  000.424: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/yaml.vim
088.483  020.053  001.818: sourcing /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-pandoc-syntax/syntax/pandoc.vim
088.927  000.369  000.369: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/r.vim
089.321  000.276  000.276: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/python.vim
089.369  020.990  000.292: sourcing /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown/syntax/rmd.vim
089.421  000.010  000.010: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/syntax/rmd.vim
089.536  009.940: opening buffers
089.547  000.011: BufEnter autocommands
089.549  000.001: editing files in windows
089.629  000.081: VimEnter autocommands
089.633  000.004: UIEnter autocommands
089.806  000.112  000.112: sourcing /opt/homebrew/Cellar/neovim/HEAD-75ff156/share/nvim/runtime/autoload/provider/clipboard.vim
089.809  000.064: before starting main loop
111.816  022.007: first screen update
111.817  000.001: --- NVIM STARTED ---

Using vimplug, with specification for:['rmd', 'markdown.pandoc'] for those two plugins, with conf.pandoc being required at init.lua yield those xxx/*.vim only being sourced once.

Expected behaviour

it should be sourced only once.

packer files

my init lua looks like this (I excluded all other plugins, and get the same result, so there are no plugins dependency issues.):

require('packer').startup {

    function(use)
        use {
            'vim-pandoc/vim-pandoc-syntax',
            setup = function()
                require 'conf.pandoc'
            end,
            ft = { 'rmd', 'markdown.pandoc', 'markdown' },
        }
        use {
            'vim-pandoc/vim-rmarkdown',
            branch = 'official-filetype',
            ft = 'rmd',
            after = 'vim-pandoc-syntax',
        }
    end,
}

and conf.pandoc file looks like this:

vim.cmd [[

augroup pandoc_syntax
    au! BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc
augroup END

]]

vim.g.r_indent_align_args = 0
vim.g.r_indent_ess_comments = 0
vim.g.r_indent_ess_compatible = 0

-- vim.g['pandoc#syntax#conceal#blacklist'] = {'subscript', 'superscript', 'atx'}
vim.g['pandoc#syntax#codeblocks#embeds#langs'] = { 'python', 'R=r', 'r', 'bash=sh', 'json' }

Plugin specification file(s)

Post or link your plugin specification files here, if you aren't able to provide a minimal reproducer

packer log file

Nothing, since it successfully compiled

Post the contents of ~/.cache/nvim/packer.nvim.log here

nothing, since it is successfully compiled.

packer compiled file

Post the contents of packer_compiled.vim here


if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
  vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
  return
end

vim.api.nvim_command('packadd packer.nvim')

local no_errors, error_msg = pcall(function()

  local time
  local profile_info
  local should_profile = false
  if should_profile then
    local hrtime = vim.loop.hrtime
    profile_info = {}
    time = function(chunk, start)
      if start then
        profile_info[chunk] = hrtime()
      else
        profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
      end
    end
  else
    time = function(chunk, start) end
  end
  
local function save_profiles(threshold)
  local sorted_times = {}
  for chunk_name, time_taken in pairs(profile_info) do
    sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
  end
  table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
  local results = {}
  for i, elem in ipairs(sorted_times) do
    if not threshold or threshold and elem[2] > threshold then
      results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
    end
  end

  _G._packer = _G._packer or {}
  _G._packer.profile_output = results
end

time([[Luarocks path setup]], true)
local package_path_str = "/Users/northyear/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/northyear/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/northyear/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/northyear/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/Users/northyear/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so"
if not string.find(package.path, package_path_str, 1, true) then
  package.path = package.path .. ';' .. package_path_str
end

if not string.find(package.cpath, install_cpath_pattern, 1, true) then
  package.cpath = package.cpath .. ';' .. install_cpath_pattern
end

time([[Luarocks path setup]], false)
time([[try_loadstring definition]], true)
local function try_loadstring(s, component, name)
  local success, result = pcall(loadstring(s), name, _G.packer_plugins[name])
  if not success then
    vim.schedule(function()
      vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
    end)
  end
  return result
end

time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true)
_G.packer_plugins = {
  ["vim-pandoc-syntax"] = {
    after = { "vim-rmarkdown" },
    loaded = false,
    needs_bufread = false,
    only_cond = false,
    path = "/Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-pandoc-syntax",
    url = "https://github.com/vim-pandoc/vim-pandoc-syntax"
  },
  ["vim-rmarkdown"] = {
    load_after = {
      ["vim-pandoc-syntax"] = true
    },
    loaded = false,
    needs_bufread = true,
    only_cond = false,
    path = "/Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown",
    url = "https://github.com/vim-pandoc/vim-rmarkdown"
  }
}

time([[Defining packer_plugins]], false)
-- Setup for: vim-pandoc-syntax
time([[Setup for vim-pandoc-syntax]], true)
try_loadstring("\27LJ\2\n+\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\16conf.pandoc\frequire\0", "setup", "vim-pandoc-syntax")
time([[Setup for vim-pandoc-syntax]], false)
vim.cmd [[augroup packer_load_aucmds]]
vim.cmd [[au!]]
  -- Filetype lazy-loads
time([[Defining lazy-load filetype autocommands]], true)
vim.cmd [[au FileType markdown ++once lua require("packer.load")({'vim-pandoc-syntax'}, { ft = "markdown" }, _G.packer_plugins)]]
vim.cmd [[au FileType rmd ++once lua require("packer.load")({'vim-rmarkdown', 'vim-pandoc-syntax'}, { ft = "rmd" }, _G.packer_plugins)]]
vim.cmd [[au FileType markdown.pandoc ++once lua require("packer.load")({'vim-pandoc-syntax'}, { ft = "markdown.pandoc" }, _G.packer_plugins)]]
time([[Defining lazy-load filetype autocommands]], false)
vim.cmd("augroup END")
vim.cmd [[augroup filetypedetect]]
time([[Sourcing ftdetect script at: /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown/ftdetect/rmarkdown.vim]], true)
vim.cmd [[source /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown/ftdetect/rmarkdown.vim]]
time([[Sourcing ftdetect script at: /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown/ftdetect/rmarkdown.vim]], false)
time([[Sourcing ftdetect script at: /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown/ftdetect/rmd.vim]], true)
vim.cmd [[source /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown/ftdetect/rmd.vim]]
time([[Sourcing ftdetect script at: /Users/northyear/.local/share/nvim/site/pack/packer/opt/vim-rmarkdown/ftdetect/rmd.vim]], false)
vim.cmd("augroup END")
if should_profile then save_profiles() end

end)

if not no_errors then
  error_msg = error_msg:gsub('"', '\\"')
  vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
end

milanglacier avatar Apr 04 '22 17:04 milanglacier