From c5f427c33786a024c58d7105e2244f5f14c64fea Mon Sep 17 00:00:00 2001 From: Oliver Caldwell Date: Sat, 1 Mar 2025 12:47:46 +0000 Subject: [PATCH] Add log split width and height percentage config --- doc/conjure.txt | 12 ++++++++++++ fnl/conjure/config.fnl | 2 ++ fnl/conjure/log.fnl | 10 ++++++++-- lua/conjure/config.lua | 2 +- lua/conjure/log.lua | 24 ++++++++++++++++++------ 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/doc/conjure.txt b/doc/conjure.txt index 6abfac13..7430b966 100644 --- a/doc/conjure.txt +++ b/doc/conjure.txt @@ -590,6 +590,18 @@ configure the ones you care about one at a time you can set: How long should the highlight last in milliseconds. Default: `500` + *g:conjure#log#split#width* +`g:conjure#log#split#width` + Width of the log vsplit as a percentage of the editor width. + A float between 0.0 and 1.0. + Default: `nil` + + *g:conjure#log#split#height* +`g:conjure#log#split#height` + Height of the log split as a percentage of the editor height. + A float between 0.0 and 1.0. + Default: `nil` + *g:conjure#log#hud#width* `g:conjure#log#hud#width` Width of the HUD as a percentage of the editor width. diff --git a/fnl/conjure/config.fnl b/fnl/conjure/config.fnl index 0536de59..2168a4e1 100644 --- a/fnl/conjure/config.fnl +++ b/fnl/conjure/config.fnl @@ -96,6 +96,8 @@ {:wrap false :diagnostics false :treesitter true + :split {:width nil + :height nil} :hud {:width 0.42 :height 0.3 :zindex 1 diff --git a/fnl/conjure/log.fnl b/fnl/conjure/log.fnl index 68f3dda6..82340220 100644 --- a/fnl/conjure/log.fnl +++ b/fnl/conjure/log.fnl @@ -459,10 +459,16 @@ (buffer.unlist buf))) (fn split [] - (create-win :split)) + (create-win :split) + (let [height (config.get-in [:log :split :height])] + (when height + (vim.api.nvim_win_set_height 0 (editor.percent-height height))))) (fn vsplit [] - (create-win :vsplit)) + (create-win :vsplit) + (let [width (config.get-in [:log :split :width])] + (when width + (vim.api.nvim_win_set_width 0 (editor.percent-width width))))) (fn tab [] (create-win :tabnew)) diff --git a/lua/conjure/config.lua b/lua/conjure/config.lua index cefb8aba..1f226bd9 100644 --- a/lua/conjure/config.lua +++ b/lua/conjure/config.lua @@ -51,7 +51,7 @@ M.merge = function(tbl, opts, ks) core["run!"](_5_, core["kv-pairs"](tbl)) return nil end -M.merge({relative_file_root = nil, path_subs = nil, client_on_load = true, filetypes = {"clojure", "fennel", "janet", "hy", "julia", "racket", "scheme", "lua", "lisp", "python", "rust", "sql"}, filetype = {clojure = "conjure.client.clojure.nrepl", fennel = "conjure.client.fennel.nfnl", janet = "conjure.client.janet.netrepl", hy = "conjure.client.hy.stdio", julia = "conjure.client.julia.stdio", racket = "conjure.client.racket.stdio", scheme = "conjure.client.scheme.stdio", lua = "conjure.client.lua.neovim", lisp = "conjure.client.common-lisp.swank", python = "conjure.client.python.stdio", rust = "conjure.client.rust.evcxr", sql = "conjure.client.sql.stdio"}, filetype_suffixes = {racket = {"rkt"}, scheme = {"scm", "ss"}}, eval = {result_register = "c", inline_results = true, inline = {highlight = "comment", prefix = "=> "}, comment_prefix = nil, gsubs = {}}, mapping = {prefix = "", enable_ft_mappings = true, enable_defaults = true}, completion = {omnifunc = "ConjureOmnifunc", fallback = "syntaxcomplete#Complete"}, highlight = {group = "IncSearch", timeout = 500, enabled = false}, log = {treesitter = true, hud = {width = 0.42, height = 0.3, zindex = 1, enabled = true, passive_close_delay = 0, minimum_lifetime_ms = 250, overlap_padding = 0.1, border = "single", anchor = "NE", open_when = "last-log-line-not-visible", ignore_low_priority = false}, jump_to_latest = {cursor_scroll_position = "top", enabled = false}, break_length = 80, trim = {at = 10000, to = 6000}, strip_ansi_escape_sequences_line_limit = 1000, fold = {lines = 10, marker = {start = "~~~%{", ["end"] = "}%~~~"}, enabled = false}, botright = false, diagnostics = false, wrap = false}, extract = {context_header_lines = -1, form_pairs = {{"(", ")"}, {"{", "}"}, {"[", "]", true}}, tree_sitter = {enabled = true}}, preview = {sample_limit = 0.3}, debug = false}) +M.merge({relative_file_root = nil, path_subs = nil, client_on_load = true, filetypes = {"clojure", "fennel", "janet", "hy", "julia", "racket", "scheme", "lua", "lisp", "python", "rust", "sql"}, filetype = {clojure = "conjure.client.clojure.nrepl", fennel = "conjure.client.fennel.nfnl", janet = "conjure.client.janet.netrepl", hy = "conjure.client.hy.stdio", julia = "conjure.client.julia.stdio", racket = "conjure.client.racket.stdio", scheme = "conjure.client.scheme.stdio", lua = "conjure.client.lua.neovim", lisp = "conjure.client.common-lisp.swank", python = "conjure.client.python.stdio", rust = "conjure.client.rust.evcxr", sql = "conjure.client.sql.stdio"}, filetype_suffixes = {racket = {"rkt"}, scheme = {"scm", "ss"}}, eval = {result_register = "c", inline_results = true, inline = {highlight = "comment", prefix = "=> "}, comment_prefix = nil, gsubs = {}}, mapping = {prefix = "", enable_ft_mappings = true, enable_defaults = true}, completion = {omnifunc = "ConjureOmnifunc", fallback = "syntaxcomplete#Complete"}, highlight = {group = "IncSearch", timeout = 500, enabled = false}, log = {treesitter = true, split = {width = nil, height = nil}, hud = {width = 0.42, height = 0.3, zindex = 1, enabled = true, passive_close_delay = 0, minimum_lifetime_ms = 250, overlap_padding = 0.1, border = "single", anchor = "NE", open_when = "last-log-line-not-visible", ignore_low_priority = false}, jump_to_latest = {cursor_scroll_position = "top", enabled = false}, break_length = 80, trim = {at = 10000, to = 6000}, strip_ansi_escape_sequences_line_limit = 1000, fold = {lines = 10, marker = {start = "~~~%{", ["end"] = "}%~~~"}, enabled = false}, botright = false, diagnostics = false, wrap = false}, extract = {context_header_lines = -1, form_pairs = {{"(", ")"}, {"{", "}"}, {"[", "]", true}}, tree_sitter = {enabled = true}}, preview = {sample_limit = 0.3}, debug = false}) if M["get-in"]({"mapping", "enable_defaults"}) then M.merge({mapping = {log_split = "ls", log_vsplit = "lv", log_tab = "lt", log_buf = "le", log_toggle = "lg", log_close_visible = "lq", log_reset_soft = "lr", log_reset_hard = "lR", log_jump_to_latest = "ll", eval_current_form = "ee", eval_comment_current_form = "ece", eval_root_form = "er", eval_comment_root_form = "ecr", eval_word = "ew", eval_comment_word = "ecw", eval_replace_form = "e!", eval_marked_form = "em", eval_file = "ef", eval_buf = "eb", eval_visual = "E", eval_motion = "E", eval_previous = "ep", def_word = "gd", doc_word = {"K"}}}) else diff --git a/lua/conjure/log.lua b/lua/conjure/log.lua index 7bdba6e8..1132ef98 100644 --- a/lua/conjure/log.lua +++ b/lua/conjure/log.lua @@ -415,10 +415,22 @@ local function create_win(cmd) return buffer.unlist(buf) end local function split() - return create_win("split") + create_win("split") + local height = config["get-in"]({"log", "split", "height"}) + if height then + return vim.api.nvim_win_set_height(0, editor["percent-height"](height)) + else + return nil + end end local function vsplit() - return create_win("vsplit") + create_win("vsplit") + local width = config["get-in"]({"log", "split", "width"}) + if width then + return vim.api.nvim_win_set_width(0, editor["percent-width"](width)) + else + return nil + end end local function tab() return create_win("tabnew") @@ -428,16 +440,16 @@ local function buf() end local function find_windows() local buf0 = upsert_buf() - local function _65_(win) + local function _67_(win) return ((state.hud.id ~= win) and (buf0 == vim.api.nvim_win_get_buf(win))) end - return a.filter(_65_, vim.api.nvim_tabpage_list_wins(0)) + return a.filter(_67_, vim.api.nvim_tabpage_list_wins(0)) end local function close(windows) - local function _66_(_241) + local function _68_(_241) return vim.api.nvim_win_close(_241, true) end - return a["run!"](_66_, windows) + return a["run!"](_68_, windows) end local function close_visible() close_hud()