wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.88k stars 265 forks source link

treesitter-textobjects lazy loading issue #553

Closed horseinthesky closed 2 years ago

horseinthesky commented 3 years ago

Steps to reproduce

I am not quite sure this is packer issue but I have no idea how to proceed. I am setting up lazy loading and besides other plugins (lazy loads great) I have treesitter with textobjects addon. Here is packer lua file:

Packer setup ``` local install_path = vim.fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim" if vim.fn.empty(vim.fn.glob(install_path)) > 0 then vim.api.nvim_command("!git clone https://github.com/wbthomason/packer.nvim " .. install_path) end -- vim.cmd [[packadd packer.nvim]] -- vim.cmd "autocmd BufWritePost plugins.lua PackerCompile" -- Auto compile when there are changes in plugins.lua local packer = require "packer" local util = require "packer.util" packer.init { compile_path = util.join_paths(vim.fn.stdpath "config", "packer", "packer_compiled.vim"), profile = { enable = true, threshold = 0, -- the amount in ms that a plugins load time must be over for it to be included in the profile }, display = { open_fn = function() return require("packer.util").float { border = "single" } end, }, } packer.startup(function(use) use "wbthomason/packer.nvim" use { "nvim-treesitter/nvim-treesitter", run = ":TSUpdate", requires = { { "nvim-treesitter/playground", after = "nvim-treesitter", cmd = { "TSPlaygroundToggle", "TSHighlightCapturesUnderCursor" }, }, { "nvim-treesitter/nvim-treesitter-textobjects", module = "nvim-treesitter-textobjects", after = "nvim-treesitter", }, }, event = "BufRead", config = function() require "config.treesitter" end, } use { "nvim-telescope/telescope.nvim", requires = { { "nvim-lua/popup.nvim", opt = true }, { "nvim-lua/plenary.nvim", opt = true }, { "nvim-telescope/telescope-fzf-native.nvim", run = "make", opt = true }, { "nvim-telescope/telescope-symbols.nvim", opt = true }, }, cmd = "Telescope", keys = { "f", "g" }, wants = { "popup.nvim", "plenary.nvim", "telescope-fzf-native.nvim", "telescope-symbols.nvim", }, config = function() require "config.telescope" end, } use { "junegunn/fzf.vim", requires = { { "junegunn/fzf", run="./install --all", opt = true }, }, wants = "fzf", cmd = { "Files", "Rg" }, } -- LSP and completion use { "neovim/nvim-lspconfig", requires = { { "glepnir/lspsaga.nvim", after = "nvim-lspconfig", config = function() require "config.lspsaga" end, }, { "onsails/lspkind-nvim", after = "nvim-lspconfig", config = function() require("lspkind").init { symbol_map = { Class = "", }, } end, }, }, event = "BufReadPre", wants = { "lspsaga.nvim", "lspkind-nvim" }, config = function() require "lsp" end, } use { "ray-x/lsp_signature.nvim", module = "lsp_signature", } use { "hrsh7th/nvim-compe", requires = { { "tzachar/compe-tabnine", run = "./install.sh", opt = true, }, { "honza/vim-snippets", opt = true }, { "SirVer/ultisnips", opt = true, wants = "vim-snippets", }, }, event = "InsertEnter", wants = { "compe-tabnine", "ultisnips" }, config = function() require "config.compe" end, } -- Features use { "folke/todo-comments.nvim", cmd = "TodoTelescope", event = "BufRead", config = function() require "config.todo" end, } use { "simrat39/symbols-outline.nvim", cmd = "SymbolsOutline", } use { "numToStr/FTerm.nvim", keys = { "", "" }, config = function() require "config.fterm" end, } use { "folke/which-key.nvim", event = "BufRead", config = function() require "which_key" end, } use { "dstein64/vim-startuptime", cmd = "StartupTime", } use { "phaazon/hop.nvim", keys = "f", config = function() require "config.hop" end, } use { "mg979/vim-visual-multi", branch = "master", keys = "", } use { "tpope/vim-surround", event = "BufRead", } use { "tpope/vim-commentary", event = "BufRead", } use { "tpope/vim-repeat", event = "BufRead", } use { "tpope/vim-fugitive", cmd = "Gvdiffsplit", } use { "simnalamburt/vim-mundo", cmd = "MundoToggle", } use { "kkoomen/vim-doge", run = ":call doge#install()", keys = "d", } use { "AndrewRadev/linediff.vim", event = "BufRead", } -- Visuals use { "mhinz/vim-startify", event = "BufEnter", } use { "morhetz/gruvbox", } use { "folke/tokyonight.nvim", } use { "lifepillar/vim-solarized8", } use { "Glench/Vim-Jinja2-Syntax", ft = "jinja", } use { "chrisbra/Colorizer", event = "BufRead", } use { "lukas-reineke/indent-blankline.nvim", event = "BufRead", } -- use { -- "sunjon/Shade.nvim", -- event = "BufRead", -- } use { "ntpeters/vim-better-whitespace", event = "BufRead", } -- Statusine use { "glepnir/galaxyline.nvim", branch = "main", requires = { { "kyazdani42/nvim-web-devicons", module = "nvim-web-devicons", }, { "lewis6991/gitsigns.nvim", requires = { { "nvim-lua/plenary.nvim", opt = true, }, }, wants = "plenary.nvim", module = "gitsigns", config = function() require "config.gitsigns" end, }, }, event = "BufRead", wants = { "nvim-web-devicons", "gitsigns.nvim", }, config = function() require "statusline" end, } use { "romgrk/barbar.nvim", -- event = "BufReadPre", wants = "nvim-web-devicons", config = function() require "config.barbar" end, } end) ```

And here is config.treesitter:

Config treesitter ``` local swap_next, swap_prev = (function() local swap_objects = { c = "@class.outer", f = "@function.outer", b = "@block.outer", s = "@statement.outer", p = "@parameter.inner", m = "@call.outer", } local n, p = {}, {} for key, obj in pairs(swap_objects) do n[string.format("s%s", key)] = obj p[string.format("S%s", key)] = obj end return n, p end)() require("nvim-treesitter.configs").setup { ensure_installed = "maintained", highlight = { enable = true, }, indent = { enable = true, disable = { "yaml" }, }, incremental_selection = { enable = true, keymaps = { init_selection = "", node_incremental = "", node_decremental = "", }, }, textobjects = { select = { enable = true, -- Automatically jump forward to textobj, similar to targets.vim lookahead = true, keymaps = { -- You can use the capture groups defined in textobjects.scm ["oc"] = "@class.outer", ["ic"] = "@class.inner", ["of"] = "@function.outer", ["if"] = "@function.inner", ["ob"] = "@block.outer", ["ib"] = "@block.inner", ["ol"] = "@loop.outer", ["il"] = "@loop.inner", ["os"] = "@statement.outer", ["is"] = "@statement.inner", ["oC"] = "@comment.outer", ["iC"] = "@comment.inner", ["om"] = "@call.outer", ["im"] = "@call.inner", }, }, swap = { enable = true, swap_next = swap_next, swap_previous = swap_prev, }, move = { enable = true, set_jumps = true, -- whether to set jumps in the jumplist goto_next_start = { ["]m"] = "@function.outer", ["]]"] = "@class.outer", }, goto_next_end = { ["]M"] = "@function.outer", ["]["] = "@class.outer", }, goto_previous_start = { ["[m"] = "@function.outer", ["[["] = "@class.outer", }, goto_previous_end = { ["[M"] = "@function.outer", ["[]"] = "@class.outer", }, }, }, playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false, }, } ```

The problem is textobjects keymappings are not loaded on BufRead.

:map of
No mappings found

But they are after InsertEnter.

:map of
x  of          *@:lua require'nvim-treesitter.textobjects.select'.select_textobject('@function.outer', 'x')<CR>
o  of          *@:lua require'nvim-treesitter.textobjects.select'.select_textobject('@function.outer', 'o')<CR>

If I remove event = "BufRead", (which would make treesitter a start plugin) and move playground and nvim-treesitter-textobjects to start plugins - mappings are loaded correctly.

Actual behaviour

Mappings are not loaded on BufRead.

Expected behaviour

Mappings are loaded on BufRead.

packer files

No log file created.

packer compiled file ``` " Automatically generated packer.nvim plugin loader code if !has('nvim-0.5') echohl WarningMsg echom "Invalid Neovim version for packer.nvim!" echohl None finish endif packadd packer.nvim try lua << END local time local profile_info local should_profile = true 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 = "/home/horseinthesky/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/horseinthesky/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/horseinthesky/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/horseinthesky/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" local install_cpath_pattern = "/home/horseinthesky/.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)) 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 = { Colorizer = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/Colorizer" }, ["FTerm.nvim"] = { config = { "\27LJ\2\n,\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\17config.fterm\frequire\0" }, keys = { { "", "" }, { "", "" } }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/FTerm.nvim" }, ["Vim-Jinja2-Syntax"] = { loaded = false, needs_bufread = true, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/Vim-Jinja2-Syntax" }, ["barbar.nvim"] = { config = { "\27LJ\2\n-\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\18config.barbar\frequire\0" }, loaded = true, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/start/barbar.nvim", wants = { "nvim-web-devicons" } }, ["compe-tabnine"] = { after_files = { "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/compe-tabnine/after/plugin/compe_tabnine.vim" }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/compe-tabnine" }, fzf = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/fzf" }, ["fzf.vim"] = { commands = { "Files", "Rg" }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/fzf.vim", wants = { "fzf" } }, ["galaxyline.nvim"] = { config = { "\27LJ\2\n*\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\15statusline\frequire\0" }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/galaxyline.nvim", wants = { "nvim-web-devicons", "gitsigns.nvim" } }, ["gitsigns.nvim"] = { config = { "\27LJ\2\n/\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\20config.gitsigns\frequire\0" }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/gitsigns.nvim", wants = { "plenary.nvim" } }, gruvbox = { loaded = true, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/start/gruvbox" }, ["hop.nvim"] = { config = { "\27LJ\2\n*\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\15config.hop\frequire\0" }, keys = { { "", "f" } }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/hop.nvim" }, ["indent-blankline.nvim"] = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/indent-blankline.nvim" }, ["linediff.vim"] = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/linediff.vim" }, ["lsp_signature.nvim"] = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/lsp_signature.nvim" }, ["lspkind-nvim"] = { config = { "\27LJ\2\n[\0\0\4\0\6\0\t6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\4\0005\3\3\0=\3\5\2B\0\2\1K\0\1\0\15symbol_map\1\0\0\1\0\1\nClass\b\tinit\flspkind\frequire\0" }, load_after = { ["nvim-lspconfig"] = true }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/lspkind-nvim" }, ["lspsaga.nvim"] = { config = { "\27LJ\2\n.\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\19config.lspsaga\frequire\0" }, load_after = { ["nvim-lspconfig"] = true }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/lspsaga.nvim" }, ["nvim-compe"] = { after_files = { "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/nvim-compe/after/plugin/compe.vim" }, config = { "\27LJ\2\n,\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\17config.compe\frequire\0" }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/nvim-compe", wants = { "compe-tabnine", "ultisnips" } }, ["nvim-lspconfig"] = { after = { "lspkind-nvim", "lspsaga.nvim" }, config = { "\27LJ\2\n#\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\blsp\frequire\0" }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/nvim-lspconfig", wants = { "lspsaga.nvim", "lspkind-nvim" } }, ["nvim-treesitter"] = { after = { "nvim-treesitter-textobjects", "playground" }, config = { "\27LJ\2\n1\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\22config.treesitter\frequire\0" }, loaded = false, needs_bufread = true, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/nvim-treesitter" }, ["nvim-treesitter-textobjects"] = { load_after = { ["nvim-treesitter"] = true }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/nvim-treesitter-textobjects" }, ["nvim-web-devicons"] = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/nvim-web-devicons" }, ["packer.nvim"] = { loaded = true, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/start/packer.nvim" }, playground = { commands = { "TSPlaygroundToggle", "TSHighlightCapturesUnderCursor" }, load_after = { ["nvim-treesitter"] = true }, loaded = false, needs_bufread = true, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/playground" }, ["plenary.nvim"] = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/plenary.nvim" }, ["popup.nvim"] = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/popup.nvim" }, ["symbols-outline.nvim"] = { commands = { "SymbolsOutline" }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/symbols-outline.nvim" }, ["telescope-fzf-native.nvim"] = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/telescope-fzf-native.nvim" }, ["telescope-symbols.nvim"] = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/telescope-symbols.nvim" }, ["telescope.nvim"] = { commands = { "Telescope" }, config = { "\27LJ\2\n0\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\21config.telescope\frequire\0" }, keys = { { "", "f" }, { "", "g" } }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/telescope.nvim", wants = { "popup.nvim", "plenary.nvim", "telescope-fzf-native.nvim", "telescope-symbols.nvim" } }, ["todo-comments.nvim"] = { commands = { "TodoTelescope" }, config = { "\27LJ\2\n+\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\16config.todo\frequire\0" }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/todo-comments.nvim" }, ["tokyonight.nvim"] = { loaded = true, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/start/tokyonight.nvim" }, ultisnips = { after_files = { "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/ultisnips/after/plugin/UltiSnips_after.vim" }, loaded = false, needs_bufread = true, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/ultisnips", wants = { "vim-snippets" } }, ["vim-better-whitespace"] = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/vim-better-whitespace" }, ["vim-commentary"] = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/vim-commentary" }, ["vim-doge"] = { keys = { { "", "d" } }, loaded = false, needs_bufread = true, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/vim-doge" }, ["vim-fugitive"] = { commands = { "Gvdiffsplit" }, loaded = false, needs_bufread = true, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/vim-fugitive" }, ["vim-mundo"] = { commands = { "MundoToggle" }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/vim-mundo" }, ["vim-repeat"] = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/vim-repeat" }, ["vim-snippets"] = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/vim-snippets" }, ["vim-solarized8"] = { loaded = true, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/start/vim-solarized8" }, ["vim-startify"] = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/vim-startify" }, ["vim-startuptime"] = { commands = { "StartupTime" }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/vim-startuptime" }, ["vim-surround"] = { loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/vim-surround" }, ["vim-visual-multi"] = { keys = { { "", "" } }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/vim-visual-multi" }, ["which-key.nvim"] = { config = { "\27LJ\2\n)\0\0\3\0\2\0\0046\0\0\0'\2\1\0B\0\2\1K\0\1\0\14which_key\frequire\0" }, loaded = false, needs_bufread = false, path = "/home/horseinthesky/.local/share/nvim/site/pack/packer/opt/which-key.nvim" } } time([[Defining packer_plugins]], false) local module_lazy_loads = { ["^gitsigns"] = "gitsigns.nvim", ["^lsp_signature"] = "lsp_signature.nvim", ["^nvim%-treesitter%-textobjects"] = "nvim-treesitter-textobjects", ["^nvim%-web%-devicons"] = "nvim-web-devicons" } local lazy_load_called = {['packer.load'] = true} local function lazy_load_module(module_name) local to_load = {} if lazy_load_called[module_name] then return nil end lazy_load_called[module_name] = true for module_pat, plugin_name in pairs(module_lazy_loads) do if not _G.packer_plugins[plugin_name].loaded and string.match(module_name, module_pat) then to_load[#to_load + 1] = plugin_name end end if #to_load > 0 then require('packer.load')(to_load, {module = module_name}, _G.packer_plugins) local loaded_mod = package.loaded[module_name] if loaded_mod then return function(modname) return loaded_mod end end end end if not vim.g.packer_custom_loader_enabled then table.insert(package.loaders, 1, lazy_load_module) vim.g.packer_custom_loader_enabled = true end -- Config for: barbar.nvim time([[Config for barbar.nvim]], 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\18config.barbar\frequire\0", "config", "barbar.nvim") time([[Config for barbar.nvim]], false) -- Command lazy-loads time([[Defining lazy-load commands]], true) pcall(vim.cmd, [[command! -nargs=* -range -bang -complete=file TSHighlightCapturesUnderCursor lua require("packer.load")({'playground'}, { cmd = "TSHighlightCapturesUnderCursor", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command! -nargs=* -range -bang -complete=file TodoTelescope lua require("packer.load")({'todo-comments.nvim'}, { cmd = "TodoTelescope", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command! -nargs=* -range -bang -complete=file TSPlaygroundToggle lua require("packer.load")({'playground'}, { cmd = "TSPlaygroundToggle", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command! -nargs=* -range -bang -complete=file SymbolsOutline lua require("packer.load")({'symbols-outline.nvim'}, { cmd = "SymbolsOutline", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command! -nargs=* -range -bang -complete=file Rg lua require("packer.load")({'fzf.vim'}, { cmd = "Rg", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command! -nargs=* -range -bang -complete=file Files lua require("packer.load")({'fzf.vim'}, { cmd = "Files", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command! -nargs=* -range -bang -complete=file MundoToggle lua require("packer.load")({'vim-mundo'}, { cmd = "MundoToggle", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command! -nargs=* -range -bang -complete=file Gvdiffsplit lua require("packer.load")({'vim-fugitive'}, { cmd = "Gvdiffsplit", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command! -nargs=* -range -bang -complete=file StartupTime lua require("packer.load")({'vim-startuptime'}, { cmd = "StartupTime", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command! -nargs=* -range -bang -complete=file Telescope lua require("packer.load")({'telescope.nvim'}, { cmd = "Telescope", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) time([[Defining lazy-load commands]], false) -- Keymap lazy-loads time([[Defining lazy-load keymaps]], true) vim.cmd [[noremap d lua require("packer.load")({'vim-doge'}, { keys = "leader>d", prefix = "" }, _G.packer_plugins)]] vim.cmd [[noremap g lua require("packer.load")({'telescope.nvim'}, { keys = "leader>g", prefix = "" }, _G.packer_plugins)]] vim.cmd [[noremap lua require("packer.load")({'vim-visual-multi'}, { keys = "C-n>", prefix = "" }, _G.packer_plugins)]] vim.cmd [[noremap f lua require("packer.load")({'telescope.nvim'}, { keys = "leader>f", prefix = "" }, _G.packer_plugins)]] vim.cmd [[noremap lua require("packer.load")({'FTerm.nvim'}, { keys = "F4>", prefix = "" }, _G.packer_plugins)]] vim.cmd [[noremap f lua require("packer.load")({'hop.nvim'}, { keys = "f", prefix = "" }, _G.packer_plugins)]] vim.cmd [[noremap lua require("packer.load")({'FTerm.nvim'}, { keys = "F3>", prefix = "" }, _G.packer_plugins)]] time([[Defining lazy-load keymaps]], false) vim.cmd [[augroup packer_load_aucmds]] vim.cmd [[au!]] -- Filetype lazy-loads time([[Defining lazy-load filetype autocommands]], true) vim.cmd [[au FileType jinja ++once lua require("packer.load")({'Vim-Jinja2-Syntax'}, { ft = "jinja" }, _G.packer_plugins)]] time([[Defining lazy-load filetype autocommands]], false) -- Event lazy-loads time([[Defining lazy-load event autocommands]], true) vim.cmd [[au InsertEnter * ++once lua require("packer.load")({'nvim-compe'}, { event = "InsertEnter *" }, _G.packer_plugins)]] vim.cmd [[au BufReadPre * ++once lua require("packer.load")({'nvim-lspconfig'}, { event = "BufReadPre *" }, _G.packer_plugins)]] vim.cmd [[au BufRead * ++once lua require("packer.load")({'indent-blankline.nvim', 'linediff.vim', 'vim-repeat', 'nvim-treesitter', 'vim-surround', 'which-key.nvim', 'todo-comments.nvim', 'Colorizer', 'galaxyline.nvim', 'vim-better-whitespace', 'vim-commentary'}, { event = "BufRead *" }, _G.packer_plugins)]] vim.cmd [[au BufEnter * ++once lua require("packer.load")({'vim-startify'}, { event = "BufEnter *" }, _G.packer_plugins)]] time([[Defining lazy-load event autocommands]], false) vim.cmd("augroup END") vim.cmd [[augroup filetypedetect]] time([[Sourcing ftdetect script at: /home/horseinthesky/.local/share/nvim/site/pack/packer/opt/Vim-Jinja2-Syntax/ftdetect/jinja.vim]], true) vim.cmd [[source /home/horseinthesky/.local/share/nvim/site/pack/packer/opt/Vim-Jinja2-Syntax/ftdetect/jinja.vim]] time([[Sourcing ftdetect script at: /home/horseinthesky/.local/share/nvim/site/pack/packer/opt/Vim-Jinja2-Syntax/ftdetect/jinja.vim]], false) vim.cmd("augroup END") if should_profile then save_profiles(0) end END catch echohl ErrorMsg echom "Error in packer_compiled: " .. v:exception echom "Please check your config for correctness" echohl None endtry ```
horseinthesky commented 3 years ago

@ram02z Not quite sure what do you mean.

I was able to fix it by putting:

require "nvim-treesitter-textobjects"

before

require("nvim-treesitter.configs").setup {
  ...

Not sure if is necessary and if there is a better solution.

ram02z commented 3 years ago

Not quite sure what do you mean.

Yeah, I realised my solution didn't make sense so I deleted my comment. Didn't expect you to see it lol.

sabitm commented 2 years ago

Are you sure BufRead event was triggered? (executing nvim (opening empty file) doesn't trigger BufRead. but nvim existing-files.txt does)

horseinthesky commented 2 years ago

@sabitm Yes. I'm sure. The thing is we need to require opt plugins somewhere so this solution is fine.