Change makeprg only if makefile doesn't exist
Change makeprg only if makefile doesn't exist
Hi everyone long time vim/neovim user, currently for my latex I have in
~/.config/nvim/after/ftplugin.lua
the following line:
vim.opt_local.makeprg="pdflatex -output-format pdf -output-directory /tmp %"
I am now working in a latex project that has a makefile, is it possible to create something in the lines of:
if ! makefile_exists then
vim.opt_local.makeprg="pdflatex -output-format pdf -output-directory /tmp %"
end
Ended up with this and it seems to work fine:
~/.config/nvim/after/ftplugin/tex.lua
local makefile_exists = vim.fs.find('makefile', {
upward = true,
stop = vim.uv.os_homedir(),
path = vim.fs.dirname(vim.api.nvim_buf_get_name(0)),
})
if #makefile_exists == 0 then
vim.opt_local.makeprg = "pdflatex -output-format pdf -output-directory /tmp %"
end
2
comments
what about autocmd on DirChanged or VimEnter that sets the option?
1 0 ReplyThanks for the comment, but I ended up finding a solution. Added tto the main comment
1 0 Reply