diff --git a/lua/commands.lua b/lua/commands.lua index c33ed4c..aa934c8 100644 --- a/lua/commands.lua +++ b/lua/commands.lua @@ -52,3 +52,29 @@ end local makeprg_augroup = vim.api.nvim_create_augroup('MyMakeprg', {}) vim.api.nvim_create_autocmd('BufEnter', { pattern = '*', group = makeprg_augroup, callback = set_makeprg, }) + +vim.api.nvim_create_autocmd("BufRead", { + pattern = "*.ui", + callback = function(args) + local designer_path = "/home/schmidtf/Qt/6.10.0/gcc_64/bin/designer" + local filename = vim.fn.expand(":p") + + -- Check if Qt Designer is available + if vim.fn.executable(designer_path) == 0 then + vim.notify("Qt Designer not found in PATH", vim.log.levels.WARN) + return + end + + -- Open in Qt Designer and close the buffer + vim.fn.jobstart({ designer_path, filename }, { + detach = true, + on_exit = function() + vim.schedule(function() + vim.cmd("bd!") + end) + end + }) + + vim.notify("Opening " .. filename .. " in Qt Designer") + end +})