Closed horseinthesky closed 2 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.
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.
Are you sure BufRead
event was triggered? (executing nvim
(opening empty file) doesn't trigger BufRead
. but nvim existing-files.txt
does)
@sabitm Yes. I'm sure.
The thing is we need to require
opt plugins somewhere so this solution is fine.
nvim --version
: v0.6.0-dev+116-g35041432bgit --version
: 2.25.1Steps 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 = { "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("The problem is textobjects keymappings are not loaded on
BufRead
.But they are after
InsertEnter
.If I remove
event = "BufRead",
(which would make treesitter a start plugin) and moveplayground
andnvim-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 = { { "", "