From 8002dfbd3628d9c216168bce4718ce1622fe54b6 Mon Sep 17 00:00:00 2001 From: Oliver Caldwell Date: Fri, 2 Feb 2024 12:03:09 +0000 Subject: [PATCH] Fix / improve localleader defaulting in the school --- fnl/conjure/school.fnl | 22 ++++++++++++---------- lua/conjure/school.lua | 23 ++++++++++++----------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/fnl/conjure/school.fnl b/fnl/conjure/school.fnl index 8d3b5f23..8c56577e 100644 --- a/fnl/conjure/school.fnl +++ b/fnl/conjure/school.fnl @@ -45,13 +45,19 @@ (nvim.ex.autocmd "BufNewFile,BufRead *.fnl setlocal filetype=clojure") (nvim.ex.augroup :END)) - (let [buf (upsert-buf)] + (let [maplocalleader-was-unset? + (when (and (= "" (config.get-in [:mapping :prefix])) + (a.empty? nvim.g.maplocalleader)) + (set nvim.g.maplocalleader ",") + true) + + buf (upsert-buf)] (nvim.ex.edit buf-name) (nvim.buf_set_lines buf 0 -1 false []) (append (a.concat ["(module user.conjure-school" - " {require {school conjure.school}})" + " {require {school conjure.school}})" "" ";; Welcome to Conjure school!" ";; Grab yourself a nice beverage and let's get evaluating. I hope you enjoy!" @@ -66,14 +72,10 @@ ";; You can learn how to change these mappings with :help conjure-mappings" "" (.. ";; Let's begin by evaluating the whole buffer using " (map-str :eval_buf))] - (when (= "" (config.get-in [:mapping :prefix])) - (if (a.empty? nvim.g.maplocalleader) - (do - (set nvim.g.maplocalleader ",") - (nvim.ex.edit) - [";; Your wasn't configured so I've defaulted it to comma (,) for now." - ";; See :help localleader for more information. (let maplocalleader=\",\")"]) - [(.. ";; Your is currently mapped to \"" nvim.g.maplocalleader "\"")])) + (if maplocalleader-was-unset? + [";; Your wasn't configured so I've defaulted it to comma (,) for now." + ";; See :help localleader for more information. (let maplocalleader=\",\")"] + [(.. ";; Your is currently mapped to \"" nvim.g.maplocalleader "\"")]) ["(school.lesson-1)"])))) (defn lesson-1 [] diff --git a/lua/conjure/school.lua b/lua/conjure/school.lua index c90f0ab5..a42b53a2 100644 --- a/lua/conjure/school.lua +++ b/lua/conjure/school.lua @@ -68,22 +68,23 @@ local function start() nvim.ex.augroup("END") else end + local maplocalleader_was_unset_3f + if (("" == config["get-in"]({"mapping", "prefix"})) and a["empty?"](nvim.g.maplocalleader)) then + nvim.g.maplocalleader = "," + maplocalleader_was_unset_3f = true + else + maplocalleader_was_unset_3f = nil + end local buf = upsert_buf() nvim.ex.edit(buf_name) nvim.buf_set_lines(buf, 0, -1, false, {}) - local _6_ - if ("" == config["get-in"]({"mapping", "prefix"})) then - if a["empty?"](nvim.g.maplocalleader) then - nvim.g.maplocalleader = "," - nvim.ex.edit() - _6_ = {";; Your wasn't configured so I've defaulted it to comma (,) for now.", ";; See :help localleader for more information. (let maplocalleader=\",\")"} - else - _6_ = {(";; Your is currently mapped to \"" .. nvim.g.maplocalleader .. "\"")} - end + local _7_ + if maplocalleader_was_unset_3f then + _7_ = {";; Your wasn't configured so I've defaulted it to comma (,) for now.", ";; See :help localleader for more information. (let maplocalleader=\",\")"} else - _6_ = nil + _7_ = {(";; Your is currently mapped to \"" .. nvim.g.maplocalleader .. "\"")} end - return append(a.concat({"(module user.conjure-school", " {require {school conjure.school}})", "", ";; Welcome to Conjure school!", ";; Grab yourself a nice beverage and let's get evaluating. I hope you enjoy!", "", ";; This language is Fennel, it's quite similar to Clojure.", ";; Conjure is written in Fennel, it's compiled to Lua and executed inside Neovim itself.", ";; This means we can work with a Lisp without installing or running anything else.", "", ";; Note: Some colorschemes will make the HUD unreadable, see here for more: https://git.io/JJ1Hl", "", ";; Let's learn how to evaluate it using Conjure's assortment of mappings.", ";; You can learn how to change these mappings with :help conjure-mappings", "", (";; Let's begin by evaluating the whole buffer using " .. map_str("eval_buf"))}, _6_, {"(school.lesson-1)"})) + return append(a.concat({"(module user.conjure-school", " {require {school conjure.school}})", "", ";; Welcome to Conjure school!", ";; Grab yourself a nice beverage and let's get evaluating. I hope you enjoy!", "", ";; This language is Fennel, it's quite similar to Clojure.", ";; Conjure is written in Fennel, it's compiled to Lua and executed inside Neovim itself.", ";; This means we can work with a Lisp without installing or running anything else.", "", ";; Note: Some colorschemes will make the HUD unreadable, see here for more: https://git.io/JJ1Hl", "", ";; Let's learn how to evaluate it using Conjure's assortment of mappings.", ";; You can learn how to change these mappings with :help conjure-mappings", "", (";; Let's begin by evaluating the whole buffer using " .. map_str("eval_buf"))}, _7_, {"(school.lesson-1)"})) end _2amodule_2a["start"] = start local function lesson_1()