From cc3ccf8f79463619f57ef79538b3d2e6d6e8cf77 Mon Sep 17 00:00:00 2001 From: Oliver Caldwell Date: Sat, 23 May 2020 18:12:10 +0100 Subject: [PATCH] Add an option to force botright for the log window --- doc/conjure.txt | 5 +++++ fnl/conjure/config.fnl | 1 + fnl/conjure/log.fnl | 23 +++++++++++++---------- lua/conjure/config.lua | 2 +- lua/conjure/log.lua | 21 ++++++++++++++------- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/doc/conjure.txt b/doc/conjure.txt index 9df93605..8ad35602 100644 --- a/doc/conjure.txt +++ b/doc/conjure.txt @@ -293,6 +293,11 @@ the `g:conjure_config` variable instead, as mention later in this section. Should the HUD be displayed at all. Default: `true` +`log.botright?` + Force the log to always open at the bottom or far right of the + editor, taking up the full width or height respectively. + Default: `false` + `log.break-length` Length of the break comment (`; ---------...`) between log results in characters. Used in trimming to avoid cutting forms in half. diff --git a/fnl/conjure/config.fnl b/fnl/conjure/config.fnl index 710b7b1d..4acd1c18 100644 --- a/fnl/conjure/config.fnl +++ b/fnl/conjure/config.fnl @@ -35,6 +35,7 @@ {:hud {:width 0.42 :height 0.3 :enabled? true} + :botright? false :break-length 80 :trim {:at 10000 :to 6000}}) diff --git a/fnl/conjure/log.fnl b/fnl/conjure/log.fnl index fa3bbb49..3fda43a9 100644 --- a/fnl/conjure/log.fnl +++ b/fnl/conjure/log.fnl @@ -169,23 +169,26 @@ (trim buf)))) -(defn- create-win [split-fn] - (let [buf (upsert-buf) - win (split-fn (log-buf-name))] - (nvim.win_set_cursor - win - [(nvim.buf_line_count buf) 0]) - (nvim.win_set_option win :wrap false) +(defn- create-win [cmd] + (let [buf (upsert-buf)] + (nvim.command + (.. (if (a.get-in config [:log :botright?]) + "botright " + "") + cmd " " + (log-buf-name))) + (nvim.win_set_cursor 0 [(nvim.buf_line_count buf) 0]) + (nvim.win_set_option 0 :wrap false) (buffer.unlist buf))) (defn split [] - (create-win nvim.ex.split)) + (create-win :split)) (defn vsplit [] - (create-win nvim.ex.vsplit)) + (create-win :vsplit)) (defn tab [] - (create-win nvim.ex.tabnew)) + (create-win :tabnew)) (defn close-visible [] (let [buf (upsert-buf)] diff --git a/lua/conjure/config.lua b/lua/conjure/config.lua index 6be7f26f..4f7ddb68 100644 --- a/lua/conjure/config.lua +++ b/lua/conjure/config.lua @@ -71,7 +71,7 @@ local log = nil do local v_23_0_ = nil do - local v_23_0_0 = {["break-length"] = 80, hud = {["enabled?"] = true, height = 0.29999999999999999, width = 0.41999999999999998}, trim = {at = 10000, to = 6000}} + local v_23_0_0 = {["botright?"] = false, ["break-length"] = 80, hud = {["enabled?"] = true, height = 0.29999999999999999, width = 0.41999999999999998}, trim = {at = 10000, to = 6000}} _0_0["log"] = v_23_0_0 v_23_0_ = v_23_0_0 end diff --git a/lua/conjure/log.lua b/lua/conjure/log.lua index 651ffdf9..6161e190 100644 --- a/lua/conjure/log.lua +++ b/lua/conjure/log.lua @@ -279,11 +279,18 @@ end local create_win = nil do local v_23_0_ = nil - local function create_win0(split_fn) + local function create_win0(cmd) local buf = upsert_buf() - local win = split_fn(log_buf_name()) - nvim.win_set_cursor(win, {nvim.buf_line_count(buf), 0}) - nvim.win_set_option(win, "wrap", false) + local function _3_() + if a["get-in"](config, {"log", "botright?"}) then + return "botright " + else + return "" + end + end + nvim.command((_3_() .. cmd .. " " .. log_buf_name())) + nvim.win_set_cursor(0, {nvim.buf_line_count(buf), 0}) + nvim.win_set_option(0, "wrap", false) return buffer.unlist(buf) end v_23_0_ = create_win0 @@ -296,7 +303,7 @@ do do local v_23_0_0 = nil local function split0() - return create_win(nvim.ex.split) + return create_win("split") end v_23_0_0 = split0 _0_0["split"] = v_23_0_0 @@ -311,7 +318,7 @@ do do local v_23_0_0 = nil local function vsplit0() - return create_win(nvim.ex.vsplit) + return create_win("vsplit") end v_23_0_0 = vsplit0 _0_0["vsplit"] = v_23_0_0 @@ -326,7 +333,7 @@ do do local v_23_0_0 = nil local function tab0() - return create_win(nvim.ex.tabnew) + return create_win("tabnew") end v_23_0_0 = tab0 _0_0["tab"] = v_23_0_0