From 1723110693647eee6b250e20077f08f54143a8e6 Mon Sep 17 00:00:00 2001 From: Zeioth Date: Wed, 15 Nov 2023 15:21:14 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8Frefactor:=20of=20the=20former?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/compiler/init.lua | 17 +++++++++-------- lua/compiler/telescope.lua | 16 +++++++++------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lua/compiler/init.lua b/lua/compiler/init.lua index e6d619c..20381ab 100644 --- a/lua/compiler/init.lua +++ b/lua/compiler/init.lua @@ -17,11 +17,10 @@ M.setup = function(opts) cmd("CompilerRedo", function() -- If the user didn't select an option yet, send a notification. - if _G.compiler_redo == nil then + if _G.compiler_redo_selection == nil and _G.compiler_redo_bau_selection == nil then vim.notify("Open the compiler and select an option before doing redo.", vim.log.levels.INFO, { title = "Compiler.nvim" } ) - return end -- If filetype is not the same as when the option was selected, send a notification. local current_filetype = vim.bo.filetype @@ -32,13 +31,15 @@ M.setup = function(opts) return end -- Redo - local language = require('compiler.utils').require_language(current_filetype) - if not language then language = require("compiler.languages.make") end - language.action(_G.compiler_redo) - -- Redo (bau) local bau = _G.compiler_redo_bau - local bau_selection = _G.compiler_redo_bau_selection - if bau and bau_selection then bau.action(bau_selection) end + if bau then + local bau_selection = _G.compiler_redo_bau_selection + if bau_selection then bau.action(bau_selection) end + else + local language = require('compiler.utils').require_language(current_filetype) + if not language then language = require("compiler.languages.make") end + language.action(_G.compiler_redo_selection) + end end, { desc = "Redo the last selected compiler option" }) diff --git a/lua/compiler/telescope.lua b/lua/compiler/telescope.lua index dd65a81..408dabe 100644 --- a/lua/compiler/telescope.lua +++ b/lua/compiler/telescope.lua @@ -77,22 +77,24 @@ function M.show() end end - -- If bau → call the bau backend. - -- If ~=bau → call the language backend. - if bau then + if bau then -- call the bau backend. bau = utils_bau.require_bau(bau) if bau then bau.action(selection.value) end + -- then + -- clean redo (language) + _G.compiler_redo_selection = nil -- save redo (bau) - _G.compiler_redo_bau = bau _G.compiler_redo_bau_selection = selection.value - else + _G.compiler_redo_bau = bau + else -- call the language backend. language.action(selection.value) + -- then -- save redo (language) - _G.compiler_redo = selection.value + _G.compiler_redo_selection = selection.value _G.compiler_redo_filetype = filetype -- clean redo (bau) - _G.compiler_redo_bau = nil _G.compiler_redo_bau_selection = nil + _G.compiler_redo_bau = nil end end