From 3d3f9bfcdfd2bd75dd194c5b95159539c4595387 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 18 Jan 2025 20:36:32 -0800 Subject: [PATCH] Auto reloader --- lua/argonaut/init.lua | 8 +++----- lua/argonaut/options.lua | 1 + plugin/argonaut.lua | 10 ++++++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lua/argonaut/init.lua b/lua/argonaut/init.lua index f5a1f5a..7b59e8a 100644 --- a/lua/argonaut/init.lua +++ b/lua/argonaut/init.lua @@ -33,6 +33,7 @@ local function reflow() builder:output(range.start_cursor.row, range.stop_cursor.row) local new_range = Range.find_at_cursor(range.start_cursor) + assert(new_range) new_range:hit_search(trace, 1):set_current() return true @@ -43,16 +44,13 @@ local function inspect() if range then local trace = range:hit_test(Cursor.get_current()) assert(trace) - print('--- range start ---') dump(trace) - print('--- range stop ---') - else - print('no range found!') end end return { inspect = inspect, reflow = reflow, - setup = Options.setup, + setup = Options.setup, + query = Options.query, } diff --git a/lua/argonaut/options.lua b/lua/argonaut/options.lua index a261c5f..7c7d1cb 100644 --- a/lua/argonaut/options.lua +++ b/lua/argonaut/options.lua @@ -1,5 +1,6 @@ local options_current = { default = { + auto_reload = false, brace_last_indent = false, brace_last_wrap = true, brace_pad = false, diff --git a/plugin/argonaut.lua b/plugin/argonaut.lua index 9b173bf..54550d3 100644 --- a/plugin/argonaut.lua +++ b/plugin/argonaut.lua @@ -7,13 +7,19 @@ if not vim.g.argonaut_loaded then end end + local function argonaut_auto_reload() + if require('argonaut').query('auto_reload') then + argonaut_reload() + end + end + local function argonaut_reflow() - argonaut_reload() + argonaut_auto_reload() require('argonaut').reflow() end local function argonaut_inspect() - argonaut_reload() + argonaut_auto_reload() require('argonaut').inspect() end