Skip to content

Commit

Permalink
♻️refactor: of the former.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeioth committed Nov 15, 2023
1 parent 345fa5c commit 1723110
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
17 changes: 9 additions & 8 deletions lua/compiler/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" })

Expand Down
16 changes: 9 additions & 7 deletions lua/compiler/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1723110

Please sign in to comment.