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

Autocommand not working with ChkTeX #162

Closed
tarsobcaldas opened this issue Jan 13, 2022 · 3 comments
Closed

Autocommand not working with ChkTeX #162

tarsobcaldas opened this issue Jan 13, 2022 · 3 comments

Comments

@tarsobcaldas
Copy link

I'm trying to get the autocommand to work in my lua config with

require('lint').linters_by_ft = {
	tex = {'chktex'}
}

and

vim.cmd([[au BufWritePost <buffer> lua require('lint').try_lint()]]) 

but it's not working. When I run only lua require('lint').try_lint on a .tex buffer, it works, but the autocmd doesn't.

I'm using Windows 11 with Neovim 6.0. I'm trying to build a lua only neovim config, so I'm not using .vimrc or any .vim file. Will try though, if anything else fails.

@mfussenegger
Copy link
Owner

Where do you run vim.cmd([[au BufWritePost <buffer> lua require('lint').try_lint()]]) ? If it is only set once in the init.lua it will only be triggered once on initial startup. The <buffer> in the autocmd definition means it will only apply for the current buffer at the time the vim.cmd call is made.

You can either remove the <buffer> or make sure you setup the BufWritePost autocmd on each buffer

@fillipe-gsm
Copy link

I was facing the same issue but with pylint. When writing

vim.cmd([[ au BufWritePost <buffer> lua require('lint').try_lint() ]])

in my init.lua the linter was never triggered, but when I ran au BufWritePost <buffer> lua require('lint').try_lint() manually at an opened file it worked.

Following @mfussenegger's explanation, I replaced the previous line with

vim.cmd([[ au BufWritePost * lua require('lint').try_lint() ]])

and now the linter is automatically called whenever I write at any buffer.

@tarsobcaldas
Copy link
Author

Substituted for BufRead,BufWritePost and it now works as I expected. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants