nvim-treesitter/module-template

Attach function never ran

winston0410 opened this issue · 2 comments

I am trying to use this module template to create a new treesitter module, but I found out that the attach function never run. I haven't change the structure and only added a few print() statement, but it just won't work.

This is my internal.lua, I cannot get the hello world printed.

local M = {}

function M.attach(bufnr, lang)
	print("hello world", bufnr, lang)
	-- TODO: Fill this with what you need to do when attaching to a buffer
end

function M.detach(bufnr)
	print("check bufnr")
	-- TODO: Fill this with what you need to do when detaching from a buffer
end

return M

module-template.lua

I am getting init from template here, therefore I am sure it has run.

local queries = require("nvim-treesitter.query")

local M = {}

-- TODO: In this function replace `module-template` with the actual name of your module.
function M.init()
	print("init from template")
	require("nvim-treesitter").define_modules({
		module_template = {
			module_path = "module-template.internal",
			is_supported = function(lang)
				-- TODO: you don't want your queries to be named `awesome-query`, do you ?
				return true
			end,
		},
	})
end

return M

And these code in my own setup:

	local treesitter = require("nvim-treesitter.configs")
	treesitter.setup({
		highlight = { enable = true },
        module_template = { enable = true },
		indent = { enable = true },
		context_commentstring = { enable = true, enable_autocmd = false },
	})

What have I missed?

Not sure why, but it seems like the function ran but the message is never printed.

Yes, this might happen, what happend if you use nvim_err_writeln instead of print in here ?