diff --git a/fnl/conjure-spec/client/fennel/aniseed_spec.fnl b/fnl/conjure-spec/client/fennel/aniseed_spec.fnl new file mode 100644 index 00000000..e947e226 --- /dev/null +++ b/fnl/conjure-spec/client/fennel/aniseed_spec.fnl @@ -0,0 +1,109 @@ +(local {: describe : it} (require :plenary.busted)) +(local assert (require :luassert.assert)) +(local a (require :nfnl.core)) +(local ani (require :conjure.client.fennel.aniseed)) + +(describe "client.fennel.aniseed" + (fn [] + (local ex-mod "test.foo.bar") + (local ex-file "/some-big/ol/path/test/foo/bar.fnl") + (local ex-file2 "/some-big/ol/path/test/foo/bar/init.fnl") + (local ex-no-file "/some-big/ol/path/test/foo/bar/no/init.fnl") + + (fn contains? [s substr] + (values + substr + (if (string.find s substr) + substr + s))) + + (describe "module-name" + (fn [] + (tset package.loaded ex-mod {:my :module}) + + (it "default name" + (fn [] + (assert.are.equals ani.default-module-name (ani.module-name nil nil)))) + (it "ex-mod and ex-file" + (fn [] + (assert.are.equals ex-mod (ani.module-name ex-mod ex-file)))) + (it "ex-file and no ex-mod" + (fn [] + (assert.are.equals ex-mod (ani.module-name nil ex-file)))) + (it "ex-file2 and no ex-mod" + (fn [] + (assert.are.equals ex-mod (ani.module-name nil ex-file2)))) + (it "default module name when no ex-file" + (fn [] + (assert.are.equals ani.default-module-name (ani.module-name nil ex-no-file)))) + + (tset package.loaded ex-mod nil) + )) + (describe "eval-str" + (fn [] + (fn eval! [code] + (var result nil) + (var raw nil) + (ani.eval-str + {:code code + :context "foo.bar" + :passive? true + :file-path "foo/bar.fnl" + :on-result #(set result $1) + :on-result-raw #(set raw $1)}) + {:result result + :raw raw}) + + (it "evaluates a form" + (fn [] + (assert.same {:raw [30] :result "30"} (eval! "(+ 10 20)")))) + (it "eval a function definition" + (fn [] + (let [{: raw : result} (eval! "(fn hi [] 10)")] + (assert.are.equals :function (type (a.first raw))) + (assert.are.equals :string (type result)) + (assert.is_not_nil (contains? result "#module-name file-path) default-module-name) default-module-name)) -(defn repl [opts] +(fn repl [opts] (let [filename (a.get opts :filename)] (or ;; Reuse an existing REPL. (and (not (a.get opts :fresh?)) (a.get repls filename)) @@ -120,7 +118,7 @@ ;; Return the new REPL! repl)))) -(defn display-result [opts] +(fn display-result [opts] (when opts (let [{: ok? : results} opts result-str (or @@ -140,7 +138,7 @@ (when opts.on-result (opts.on-result result-str))))) -(defn eval-str [opts] +(fn eval-str [opts] ((client.wrap (fn [] (let [out (anic :nu :with-out-str @@ -171,16 +169,16 @@ (log.append (text.prefixed-lines (text.trim-last-newline out) "; (out) "))) (display-result opts)))))) -(defn doc-str [opts] +(fn doc-str [opts] (a.assoc opts :code (.. ",doc " opts.code)) (eval-str opts)) -(defn eval-file [opts] +(fn eval-file [opts] (set opts.code (a.slurp opts.file-path)) (when opts.code (eval-str opts))) -(defn- wrapped-test [req-lines f] +(fn wrapped-test [req-lines f] (log.append req-lines {:break? true}) (let [res (anic :nu :with-out-str f)] (log.append @@ -189,17 +187,17 @@ res) (text.prefixed-lines "; "))))) -(defn run-buf-tests [] +(fn run-buf-tests [] (let [c (extract.context)] (when c (wrapped-test [(.. "; run-buf-tests (" c ")")] #(anic :test :run c))))) -(defn run-all-tests [] +(fn run-all-tests [] (wrapped-test ["; run-all-tests"] (ani :test :run-all))) -(defn on-filetype [] +(fn on-filetype [] (mapping.buf :FnlRunBufTests (cfg [:mapping :run_buf_tests]) #(run-buf-tests) @@ -220,7 +218,7 @@ #(reset-all-repls) {:desc "Reset all REPL states"})) -(defn value->completions [x] +(fn value->completions [x] (when (= :table (type x)) (->> (if (. x :aniseed/autoload-enabled?) (do @@ -238,7 +236,7 @@ :menu nil :info nil}))))) -(defn completions [opts] +(fn completions [opts] (let [code (when (not (str.blank? opts.prefix)) (let [prefix (string.gsub opts.prefix ".$" "")] (.. "((. (require :" *module-name* ") :value->completions) " prefix ")"))) @@ -276,4 +274,22 @@ (when (not ok?) (opts.cb locals)))) -*module* +{: buf-suffix + : comment-node? + : comment-prefix + : completions + : context-pattern + : default-module-name + : display-result + : doc-str + : eval-file + : eval-str + : form-node? + : module-name + : on-filetype + : repl + : reset-all-repls + : reset-repl + : run-all-tests + : run-buf-tests + : value->completions } diff --git a/fnl/conjure/client/racket/stdio.fnl b/fnl/conjure/client/racket/stdio.fnl index 1c32cd1e..192ae10e 100644 --- a/fnl/conjure/client/racket/stdio.fnl +++ b/fnl/conjure/client/racket/stdio.fnl @@ -102,7 +102,7 @@ (fn enter [] (let [repl (state :repl) - path (nvim.fn.expand "%:p")] + path (vim.fn.expand "%:p")] (when (and repl (not (log.log-buf? path))) (repl.send (prep-code (.. ",enter " path)) diff --git a/fnl/conjure/dynamic.fnl b/fnl/conjure/dynamic.fnl index 2264905c..67e65bd1 100644 --- a/fnl/conjure/dynamic.fnl +++ b/fnl/conjure/dynamic.fnl @@ -1,29 +1,27 @@ -(import-macros {: module : def : defn : defonce : def- : defn- : defonce- : wrap-last-expr : wrap-module-body : deftest} :nfnl.macros.aniseed) +(local {: autoload} (require :nfnl.module)) +(local a (autoload :conjure.aniseed.core)) -(module conjure.dynamic - {autoload {a conjure.aniseed.core}}) +(local get-stack-key :conjure.dynamic/get-stack) -(def- get-stack-key :conjure.dynamic/get-stack) - -(defn- assert-value-function! [value] +(fn assert-value-function! [value] (when (not= :function (type value)) (error "conjure.dynamic values must always be wrapped in a function"))) -(defn new [base-value] +(fn new [base-value] (assert-value-function! base-value) (var stack [base-value]) (fn [x ...] (if (= get-stack-key x) stack ((a.last stack) x ...)))) -(defn- run-binds! [f binds] +(fn run-binds! [f binds] (a.map-indexed (fn [[dyn new-value]] (assert-value-function! new-value) (f (dyn get-stack-key) new-value)) binds)) -(defn bind [binds f ...] +(fn bind [binds f ...] (run-binds! table.insert binds) (let [(ok? result) (pcall f ...)] (run-binds! #(table.remove $1) binds) @@ -31,16 +29,19 @@ result (error result)))) -(defn set! [dyn new-value] +(fn set! [dyn new-value] (assert-value-function! new-value) (let [stack (dyn get-stack-key) depth (a.count stack)] (a.assoc stack depth new-value)) nil) -(defn set-root! [dyn new-value] +(fn set-root! [dyn new-value] (assert-value-function! new-value) (a.assoc (dyn get-stack-key) 1 new-value) nil) -*module* +{: new + : bind + : set! + : set-root!} diff --git a/fnl/conjure/editor.fnl b/fnl/conjure/editor.fnl index b44c1be9..503c5fb7 100644 --- a/fnl/conjure/editor.fnl +++ b/fnl/conjure/editor.fnl @@ -1,31 +1,29 @@ -(import-macros {: module : def : defn : defonce : def- : defn- : defonce- : wrap-last-expr : wrap-module-body : deftest} :nfnl.macros.aniseed) +(local {: autoload} (require :nfnl.module)) +(local a (autoload :conjure.aniseed.core)) +(local fs (autoload :conjure.fs)) +(local nvim (autoload :conjure.aniseed.nvim)) +(local util (autoload :conjure.util)) -(module conjure.editor - {autoload {a conjure.aniseed.core - nvim conjure.aniseed.nvim - fs conjure.fs - util conjure.util}}) - -(defn- percent-fn [total-fn] +(fn percent-fn [total-fn] (fn [pc] (math.floor (* (/ (total-fn) 100) (* pc 100))))) -(defn width [] - nvim.o.columns) +(fn width [] + vim.o.columns) -(defn height [] - nvim.o.lines) +(fn height [] + vim.o.lines) -(def percent-width (percent-fn width)) -(def percent-height (percent-fn height)) +(local percent-width (percent-fn width)) +(local percent-height (percent-fn height)) -(defn cursor-left [] - (nvim.fn.screencol)) +(fn cursor-left [] + (vim.fn.screencol)) -(defn cursor-top [] - (nvim.fn.screenrow)) +(fn cursor-top [] + (vim.fn.screenrow)) -(defn go-to [path-or-win line column] +(fn go-to [path-or-win line column] (when (a.string? path-or-win) (nvim.ex.edit (fs.localise-path path-or-win))) @@ -35,13 +33,22 @@ 0) [line (a.dec column)])) -(defn go-to-mark [m] +(fn go-to-mark [m] (nvim.ex.normal_ (.. "`" m))) -(defn go-back [] +(fn go-back [] (nvim.ex.normal_ (util.replace-termcodes ""))) -(defn has-filetype? [ft] +(fn has-filetype? [ft] (a.some #(= ft $1) (nvim.fn.getcompletion ft :filetype))) -*module* +{: width + : height + : percent-width + : percent-height + : cursor-left + : cursor-top + : go-to + : go-to-mark + : go-back + : has-filetype?} diff --git a/fnl/conjure/extract/searchpair.fnl b/fnl/conjure/extract/searchpair.fnl index aebc55e5..ca2866ff 100644 --- a/fnl/conjure/extract/searchpair.fnl +++ b/fnl/conjure/extract/searchpair.fnl @@ -1,22 +1,20 @@ -(import-macros {: module : def : defn : defonce : def- : defn- : defonce- : wrap-last-expr : wrap-module-body : deftest} :nfnl.macros.aniseed) +(local {: autoload} (require :nfnl.module)) +(local a (autoload :conjure.aniseed.core)) -(module conjure.extract.searchpair - {autoload {a conjure.aniseed.core - nvim conjure.aniseed.nvim - str conjure.aniseed.string - config conjure.config}}) +(local str (autoload :conjure.aniseed.string)) +(local config (autoload :conjure.config)) ;; All of the code related to the searchpair / searchpairpos based form ;; extraction. If you use Tree Sitter for all of the languages you work ;; with Conjure will avoid loading this module. It's only loaded for ;; files that can't support Tree Sitter for some reason. -(defn- nil-pos? [pos] +(fn nil-pos? [pos] (or (not pos) (= 0 (unpack pos)))) -(defn- read-range [[srow scol] [erow ecol]] - (let [lines (nvim.buf_get_lines +(fn read-range [[srow scol] [erow ecol]] + (let [lines (vim.api.nvim_buf_get_lines 0 (- srow 1) erow false)] (-> lines (a.update @@ -29,36 +27,36 @@ (string.sub s scol))) (->> (str.join "\n"))))) -(defn skip-match? [] - (let [[row col] (nvim.win_get_cursor 0) - stack (nvim.fn.synstack row (a.inc col)) +(fn skip-match? [] + (let [[row col] (vim.api.nvim_win_get_cursor 0) + stack (vim.fn.synstack row (a.inc col)) stack-size (length stack)] (if (or ;; Are we in a comment, string or regular expression? (= :number (type (and (> stack-size 0) - (let [name (nvim.fn.synIDattr (. stack stack-size) :name)] + (let [name (vim.fn.synIDattr (. stack stack-size) :name)] (or (name:find "Comment$") (name:find "String$") (name:find "Regexp%?$")))))) ;; Is the character escaped? ;; https://github.com/Olical/conjure/issues/209 - (= "\\" (-> (nvim.buf_get_lines - (nvim.win_get_buf 0) (- row 1) row false) + (= "\\" (-> (vim.api.nvim_buf_get_lines + (vim.api.nvim_win_get_buf 0) (- row 1) row false) (a.first) (string.sub col col)))) 1 0))) -(defn- current-char [] - (let [[row col] (nvim.win_get_cursor 0) - [line] (nvim.buf_get_lines 0 (- row 1) row false) +(fn current-char [] + (let [[row col] (vim.api.nvim_win_get_cursor 0) + [line] (vim.api.nvim_buf_get_lines 0 (- row 1) row false) char (+ col 1)] (string.sub line char char))) -(defn- form* [[start-char end-char escape?] {: root?}] +(fn form* [[start-char end-char escape?] {: root?}] (let [;; 'W' don't Wrap around the end of the file ;; 'n' do Not move the cursor ;; 'z' start searching at the cursor column instead of Zero @@ -78,11 +76,11 @@ (.. "\\" end-char) end-char) - start (nvim.fn.searchpairpos + start (vim.fn.searchpairpos safe-start-char "" safe-end-char (.. flags "b" (if (= cursor-char start-char) "c" "")) skip-match?) - end (nvim.fn.searchpairpos + end (vim.fn.searchpairpos safe-start-char "" safe-end-char (.. flags (if (= cursor-char end-char) "c" "")) skip-match?)] @@ -93,16 +91,16 @@ :end [(a.first end) (a.dec (a.second end))]} :content (read-range start end)}))) -(defn- distance-gt [[al ac] [bl bc]] +(fn distance-gt [[al ac] [bl bc]] (or (> al bl) (and (= al bl) (> ac bc)))) -(defn- range-distance [range] +(fn range-distance [range] (let [[sl sc] range.start [el ec] range.end] [(- sl el) (- sc ec)])) -(defn form [opts] +(fn form [opts] (local forms (->> (config.get-in [:extract :form_pairs]) (a.map #(form* $1 opts)) @@ -118,4 +116,5 @@ (a.last forms) (a.first forms))) -*module* +{: skip-match? + : form} diff --git a/fnl/conjure/remote/stdio2.fnl b/fnl/conjure/remote/stdio2.fnl index 96bbcb06..7897c06b 100644 --- a/fnl/conjure/remote/stdio2.fnl +++ b/fnl/conjure/remote/stdio2.fnl @@ -1,15 +1,12 @@ -(import-macros {: module : def : defn : defonce : def- : defn- : defonce- : wrap-last-expr : wrap-module-body : deftest} :nfnl.macros.aniseed) +(local {: autoload} (require :nfnl.module)) +(local a (autoload :conjure.aniseed.core)) +(local str (autoload :conjure.aniseed.string)) +(local client (autoload :conjure.client)) +(local log (autoload :conjure.log)) -(module conjure.remote.stdio2 - {autoload {a conjure.aniseed.core - nvim conjure.aniseed.nvim - str conjure.aniseed.string - client conjure.client - log conjure.log}}) +(local uv vim.loop) -(def- uv vim.loop) - -(defn parse-cmd [x] +(fn parse-cmd [x] (if (a.table? x) {:cmd (a.first x) @@ -18,4 +15,4 @@ (a.string? x) (parse-cmd (str.split x "%s")))) -*module* +{: parse-cmd} diff --git a/fnl/conjure/remote/swank.fnl b/fnl/conjure/remote/swank.fnl index 86da06cd..4df05ece 100644 --- a/fnl/conjure/remote/swank.fnl +++ b/fnl/conjure/remote/swank.fnl @@ -1,21 +1,18 @@ -(import-macros {: module : def : defn : defonce : def- : defn- : defonce- : wrap-last-expr : wrap-module-body : deftest} :nfnl.macros.aniseed) - -(module conjure.remote.swank - {autoload {a conjure.aniseed.core - net conjure.net - log conjure.log - client conjure.client - trn conjure.remote.transport.swank - nvim conjure.aniseed.nvim}}) - -(defn send [conn msg cb] +(local {: autoload} (require :nfnl.module)) +(local a (autoload :conjure.aniseed.core)) +(local client (autoload :conjure.client)) +(local log (autoload :conjure.log)) +(local net (autoload :conjure.net)) +(local trn (autoload :conjure.remote.transport.swank)) + +(fn send [conn msg cb] "Send a message to the given connection, call the callback when a response is received." ; (log.dbg "send" msg) (table.insert conn.queue 1 (or cb false)) (conn.sock:write (trn.encode msg)) nil) -(defn connect [opts] +(fn connect [opts] "Connects to a remote swank server. * opts.host: The host string. * opts.port: Port as a string. @@ -57,5 +54,5 @@ ; (send conn (or opts.name "Conjure")) conn) - -*module* +{: send + : connect} diff --git a/fnl/conjure/remote/transport/swank.fnl b/fnl/conjure/remote/transport/swank.fnl index 8357de47..1a177645 100644 --- a/fnl/conjure/remote/transport/swank.fnl +++ b/fnl/conjure/remote/transport/swank.fnl @@ -1,17 +1,15 @@ -(import-macros {: module : def : defn : defonce : def- : defn- : defonce- : wrap-last-expr : wrap-module-body : deftest} :nfnl.macros.aniseed) +(local {: autoload} (require :nfnl.module)) +(local a (autoload :conjure.aniseed.core)) +(local log (autoload :conjure.log)) -(module conjure.remote.transport.swank - {autoload {a conjure.aniseed.core - log conjure.log}}) - -(defn encode [msg] +(fn encode [msg] (let [n (a.count msg) header (string.format "%06x" (+ 1 n))] ; Additional 1 for trailing newline (.. header msg "\n"))) -(defn decode [msg] +(fn decode [msg] (let [len (tonumber (string.sub msg 1 7) 16) cmd (string.sub msg 7 len)] cmd)) -*module* +{: encode : decode} diff --git a/lua/conjure-spec/client/fennel/aniseed_spec.lua b/lua/conjure-spec/client/fennel/aniseed_spec.lua new file mode 100644 index 00000000..0109d545 --- /dev/null +++ b/lua/conjure-spec/client/fennel/aniseed_spec.lua @@ -0,0 +1,125 @@ +-- [nfnl] Compiled from fnl/conjure-spec/client/fennel/aniseed_spec.fnl by https://github.com/Olical/nfnl, do not edit. +local _local_1_ = require("plenary.busted") +local describe = _local_1_["describe"] +local it = _local_1_["it"] +local assert = require("luassert.assert") +local a = require("nfnl.core") +local ani = require("conjure.client.fennel.aniseed") +local function _2_() + local ex_mod = "test.foo.bar" + local ex_file = "/some-big/ol/path/test/foo/bar.fnl" + local ex_file2 = "/some-big/ol/path/test/foo/bar/init.fnl" + local ex_no_file = "/some-big/ol/path/test/foo/bar/no/init.fnl" + local function contains_3f(s, substr) + local function _3_() + if string.find(s, substr) then + return substr + else + return s + end + end + return substr, _3_() + end + local function _4_() + package.loaded[ex_mod] = {my = "module"} + local function _5_() + return assert.are.equals(ani["default-module-name"], ani["module-name"](nil, nil)) + end + it("default name", _5_) + local function _6_() + return assert.are.equals(ex_mod, ani["module-name"](ex_mod, ex_file)) + end + it("ex-mod and ex-file", _6_) + local function _7_() + return assert.are.equals(ex_mod, ani["module-name"](nil, ex_file)) + end + it("ex-file and no ex-mod", _7_) + local function _8_() + return assert.are.equals(ex_mod, ani["module-name"](nil, ex_file2)) + end + it("ex-file2 and no ex-mod", _8_) + local function _9_() + return assert.are.equals(ani["default-module-name"], ani["module-name"](nil, ex_no_file)) + end + it("default module name when no ex-file", _9_) + package.loaded[ex_mod] = nil + return nil + end + describe("module-name", _4_) + local function _10_() + local function eval_21(code) + local result = nil + local raw = nil + local function _11_(_241) + result = _241 + return nil + end + local function _12_(_241) + raw = _241 + return nil + end + ani["eval-str"]({code = code, context = "foo.bar", ["passive?"] = true, ["file-path"] = "foo/bar.fnl", ["on-result"] = _11_, ["on-result-raw"] = _12_}) + return {result = result, raw = raw} + end + local function _13_() + return assert.same({raw = {30}, result = "30"}, eval_21("(+ 10 20)")) + end + it("evaluates a form", _13_) + local function _14_() + local _let_15_ = eval_21("(fn hi [] 10)") + local raw = _let_15_["raw"] + local result = _let_15_["result"] + assert.are.equals("function", type(a.first(raw))) + assert.are.equals("string", type(result)) + return assert.is_not_nil(contains_3f(result, "#completions"] = value__3ecompletions -do local _ = {value__3ecompletions, nil} end local function completions(opts) local code if not str["blank?"](opts.prefix) then local prefix = string.gsub(opts.prefix, ".$", "") - code = ("((. (require :" .. _2amodule_name_2a .. ") :value->completions) " .. prefix .. ")") + code = ("((. (require :" .. __fnl_global___2amodule_2dname_2a .. ") :value->completions) " .. prefix .. ")") else code = nil end @@ -368,6 +305,4 @@ local function completions(opts) return nil end end -_2amodule_2a["completions"] = completions -do local _ = {completions, nil} end -return _2amodule_2a +return {["buf-suffix"] = buf_suffix, ["comment-node?"] = comment_node_3f, ["comment-prefix"] = comment_prefix, completions = completions, ["context-pattern"] = context_pattern, ["default-module-name"] = default_module_name, ["display-result"] = display_result, ["doc-str"] = doc_str, ["eval-file"] = eval_file, ["eval-str"] = eval_str, ["form-node?"] = form_node_3f, ["module-name"] = module_name, ["on-filetype"] = on_filetype, repl = repl, ["reset-all-repls"] = reset_all_repls, ["reset-repl"] = reset_repl, ["run-all-tests"] = run_all_tests, ["run-buf-tests"] = run_buf_tests, ["value->completions"] = value__3ecompletions} diff --git a/lua/conjure/client/racket/stdio.lua b/lua/conjure/client/racket/stdio.lua index e28f1bec..a109a8a3 100644 --- a/lua/conjure/client/racket/stdio.lua +++ b/lua/conjure/client/racket/stdio.lua @@ -104,7 +104,7 @@ local function stop() end local function enter() local repl = state("repl") - local path = nvim.fn.expand("%:p") + local path = vim.fn.expand("%:p") if (repl and not log["log-buf?"](path)) then local function _14_() end diff --git a/lua/conjure/dynamic.lua b/lua/conjure/dynamic.lua index 86eb509a..3dd010a1 100644 --- a/lua/conjure/dynamic.lua +++ b/lua/conjure/dynamic.lua @@ -1,22 +1,8 @@ -- [nfnl] Compiled from fnl/conjure/dynamic.fnl by https://github.com/Olical/nfnl, do not edit. -local _2amodule_name_2a = "conjure.dynamic" -local _2amodule_2a -do - _G.package.loaded[_2amodule_name_2a] = {} - _2amodule_2a = _G.package.loaded[_2amodule_name_2a] -end -local _2amodule_locals_2a -do - _2amodule_2a["aniseed/locals"] = {} - _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] -end -local autoload = (require("aniseed.autoload")).autoload +local _local_1_ = require("nfnl.module") +local autoload = _local_1_["autoload"] local a = autoload("conjure.aniseed.core") -do end (_2amodule_locals_2a)["a"] = a -do local _ = {nil, nil, nil, nil, nil, nil} end local get_stack_key = "conjure.dynamic/get-stack" -_2amodule_locals_2a["get-stack-key"] = get_stack_key -do local _ = {nil, nil} end local function assert_value_function_21(value) if ("function" ~= type(value)) then return error("conjure.dynamic values must always be wrapped in a function") @@ -24,34 +10,27 @@ local function assert_value_function_21(value) return nil end end -_2amodule_locals_2a["assert-value-function!"] = assert_value_function_21 -do local _ = {assert_value_function_21, nil} end local function new(base_value) assert_value_function_21(base_value) local stack = {base_value} - local function _2_(x, ...) + local function _3_(x, ...) if (get_stack_key == x) then return stack else return a.last(stack)(x, ...) end end - return _2_ + return _3_ end -_2amodule_2a["new"] = new -do local _ = {new, nil} end local function run_binds_21(f, binds) - local function _6_(_4_) - local _arg_5_ = _4_ - local dyn = _arg_5_[1] - local new_value = _arg_5_[2] + local function _6_(_5_) + local dyn = _5_[1] + local new_value = _5_[2] assert_value_function_21(new_value) return f(dyn(get_stack_key), new_value) end return a["map-indexed"](_6_, binds) end -_2amodule_locals_2a["run-binds!"] = run_binds_21 -do local _ = {run_binds_21, nil} end local function bind(binds, f, ...) run_binds_21(table.insert, binds) local ok_3f, result = pcall(f, ...) @@ -65,8 +44,6 @@ local function bind(binds, f, ...) return error(result) end end -_2amodule_2a["bind"] = bind -do local _ = {bind, nil} end local function set_21(dyn, new_value) assert_value_function_21(new_value) do @@ -76,13 +53,9 @@ local function set_21(dyn, new_value) end return nil end -_2amodule_2a["set!"] = set_21 -do local _ = {set_21, nil} end local function set_root_21(dyn, new_value) assert_value_function_21(new_value) a.assoc(dyn(get_stack_key), 1, new_value) return nil end -_2amodule_2a["set-root!"] = set_root_21 -do local _ = {set_root_21, nil} end -return _2amodule_2a +return {new = new, bind = bind, ["set!"] = set_21, ["set-root!"] = set_root_21} diff --git a/lua/conjure/editor.lua b/lua/conjure/editor.lua index 7e97261b..695a5270 100644 --- a/lua/conjure/editor.lua +++ b/lua/conjure/editor.lua @@ -1,87 +1,53 @@ -- [nfnl] Compiled from fnl/conjure/editor.fnl by https://github.com/Olical/nfnl, do not edit. -local _2amodule_name_2a = "conjure.editor" -local _2amodule_2a -do - _G.package.loaded[_2amodule_name_2a] = {} - _2amodule_2a = _G.package.loaded[_2amodule_name_2a] -end -local _2amodule_locals_2a -do - _2amodule_2a["aniseed/locals"] = {} - _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] -end -local autoload = (require("aniseed.autoload")).autoload -local a, fs, nvim, util = autoload("conjure.aniseed.core"), autoload("conjure.fs"), autoload("conjure.aniseed.nvim"), autoload("conjure.util") -do end (_2amodule_locals_2a)["a"] = a -_2amodule_locals_2a["fs"] = fs -_2amodule_locals_2a["nvim"] = nvim -_2amodule_locals_2a["util"] = util -do local _ = {nil, nil, nil, nil, nil, nil, nil, nil, nil} end +local _local_1_ = require("nfnl.module") +local autoload = _local_1_["autoload"] +local a = autoload("conjure.aniseed.core") +local fs = autoload("conjure.fs") +local nvim = autoload("conjure.aniseed.nvim") +local util = autoload("conjure.util") local function percent_fn(total_fn) - local function _1_(pc) + local function _2_(pc) return math.floor(((total_fn() / 100) * (pc * 100))) end - return _1_ + return _2_ end -_2amodule_locals_2a["percent-fn"] = percent_fn -do local _ = {percent_fn, nil} end local function width() - return nvim.o.columns + return vim.o.columns end -_2amodule_2a["width"] = width -do local _ = {width, nil} end local function height() - return nvim.o.lines + return vim.o.lines end -_2amodule_2a["height"] = height -do local _ = {height, nil} end local percent_width = percent_fn(width) -do end (_2amodule_2a)["percent-width"] = percent_width -do local _ = {nil, nil} end local percent_height = percent_fn(height) -do end (_2amodule_2a)["percent-height"] = percent_height -do local _ = {nil, nil} end local function cursor_left() - return nvim.fn.screencol() + return vim.fn.screencol() end -_2amodule_2a["cursor-left"] = cursor_left -do local _ = {cursor_left, nil} end local function cursor_top() - return nvim.fn.screenrow() + return vim.fn.screenrow() end -_2amodule_2a["cursor-top"] = cursor_top -do local _ = {cursor_top, nil} end local function go_to(path_or_win, line, column) if a["string?"](path_or_win) then nvim.ex.edit(fs["localise-path"](path_or_win)) else end - local _3_ + local _4_ if ("number" == type(path_or_win)) then - _3_ = path_or_win + _4_ = path_or_win else - _3_ = 0 + _4_ = 0 end - return nvim.win_set_cursor(_3_, {line, a.dec(column)}) + return nvim.win_set_cursor(_4_, {line, a.dec(column)}) end -_2amodule_2a["go-to"] = go_to -do local _ = {go_to, nil} end local function go_to_mark(m) return nvim.ex.normal_(("`" .. m)) end -_2amodule_2a["go-to-mark"] = go_to_mark -do local _ = {go_to_mark, nil} end local function go_back() return nvim.ex.normal_(util["replace-termcodes"]("")) end -_2amodule_2a["go-back"] = go_back -do local _ = {go_back, nil} end local function has_filetype_3f(ft) - local function _5_(_241) + local function _6_(_241) return (ft == _241) end - return a.some(_5_, nvim.fn.getcompletion(ft, "filetype")) + return a.some(_6_, nvim.fn.getcompletion(ft, "filetype")) end -_2amodule_2a["has-filetype?"] = has_filetype_3f -do local _ = {has_filetype_3f, nil} end -return _2amodule_2a +return {width = width, height = height, ["percent-width"] = percent_width, ["percent-height"] = percent_height, ["cursor-left"] = cursor_left, ["cursor-top"] = cursor_top, ["go-to"] = go_to, ["go-to-mark"] = go_to_mark, ["go-back"] = go_back, ["has-filetype?"] = has_filetype_3f} diff --git a/lua/conjure/extract/searchpair.lua b/lua/conjure/extract/searchpair.lua index 7b4a544c..ad6f5aa2 100644 --- a/lua/conjure/extract/searchpair.lua +++ b/lua/conjure/extract/searchpair.lua @@ -1,90 +1,69 @@ -- [nfnl] Compiled from fnl/conjure/extract/searchpair.fnl by https://github.com/Olical/nfnl, do not edit. -local _2amodule_name_2a = "conjure.extract.searchpair" -local _2amodule_2a -do - _G.package.loaded[_2amodule_name_2a] = {} - _2amodule_2a = _G.package.loaded[_2amodule_name_2a] -end -local _2amodule_locals_2a -do - _2amodule_2a["aniseed/locals"] = {} - _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] -end -local autoload = (require("aniseed.autoload")).autoload -local a, config, nvim, str = autoload("conjure.aniseed.core"), autoload("conjure.config"), autoload("conjure.aniseed.nvim"), autoload("conjure.aniseed.string") -do end (_2amodule_locals_2a)["a"] = a -_2amodule_locals_2a["config"] = config -_2amodule_locals_2a["nvim"] = nvim -_2amodule_locals_2a["str"] = str -do local _ = {nil, nil, nil, nil, nil, nil, nil, nil, nil} end +local _local_1_ = require("nfnl.module") +local autoload = _local_1_["autoload"] +local a = autoload("conjure.aniseed.core") +local str = autoload("conjure.aniseed.string") +local config = autoload("conjure.config") local function nil_pos_3f(pos) return (not pos or (0 == unpack(pos))) end -_2amodule_locals_2a["nil-pos?"] = nil_pos_3f -do local _ = {nil_pos_3f, nil} end -local function read_range(_1_, _3_) - local _arg_2_ = _1_ - local srow = _arg_2_[1] - local scol = _arg_2_[2] - local _arg_4_ = _3_ - local erow = _arg_4_[1] - local ecol = _arg_4_[2] - local lines = nvim.buf_get_lines(0, (srow - 1), erow, false) - local function _5_(s) +local function read_range(_2_, _3_) + local srow = _2_[1] + local scol = _2_[2] + local erow = _3_[1] + local ecol = _3_[2] + local lines = vim.api.nvim_buf_get_lines(0, (srow - 1), erow, false) + local function _4_(s) return string.sub(s, 0, ecol) end - local function _6_(s) + local function _5_(s) return string.sub(s, scol) end - return str.join("\n", a.update(a.update(lines, #lines, _5_), 1, _6_)) + return str.join("\n", a.update(a.update(lines, #lines, _4_), 1, _5_)) end -_2amodule_locals_2a["read-range"] = read_range -do local _ = {read_range, nil} end local function skip_match_3f() - local _let_7_ = nvim.win_get_cursor(0) - local row = _let_7_[1] - local col = _let_7_[2] - local stack = nvim.fn.synstack(row, a.inc(col)) + local _let_6_ = vim.api.nvim_win_get_cursor(0) + local row = _let_6_[1] + local col = _let_6_[2] + local stack = vim.fn.synstack(row, a.inc(col)) local stack_size = #stack - local function _8_() - local name = nvim.fn.synIDattr(stack[stack_size], "name") - return (name:find("Comment$") or name:find("String$") or name:find("Regexp%?$")) + local and_7_ = (stack_size > 0) + if and_7_ then + local name = vim.fn.synIDattr(stack[stack_size], "name") + and_7_ = (name:find("Comment$") or name:find("String$") or name:find("Regexp%?$")) end - if (("number" == type(((stack_size > 0) and _8_()))) or ("\\" == string.sub(a.first(nvim.buf_get_lines(nvim.win_get_buf(0), (row - 1), row, false)), col, col))) then + local or_9_ = ("number" == type(and_7_)) + if not or_9_ then + or_9_ = ("\\" == string.sub(a.first(vim.api.nvim_buf_get_lines(vim.api.nvim_win_get_buf(0), (row - 1), row, false)), col, col)) + end + if or_9_ then return 1 else return 0 end end -_2amodule_2a["skip-match?"] = skip_match_3f -do local _ = {skip_match_3f, nil} end local function current_char() - local _let_10_ = nvim.win_get_cursor(0) - local row = _let_10_[1] - local col = _let_10_[2] - local _let_11_ = nvim.buf_get_lines(0, (row - 1), row, false) - local line = _let_11_[1] + local _let_11_ = vim.api.nvim_win_get_cursor(0) + local row = _let_11_[1] + local col = _let_11_[2] + local _let_12_ = vim.api.nvim_buf_get_lines(0, (row - 1), row, false) + local line = _let_12_[1] local char = (col + 1) return string.sub(line, char, char) end -_2amodule_locals_2a["current-char"] = current_char -do local _ = {current_char, nil} end -local function form_2a(_12_, _14_) - local _arg_13_ = _12_ - local start_char = _arg_13_[1] - local end_char = _arg_13_[2] - local escape_3f = _arg_13_[3] - local _arg_15_ = _14_ - local root_3f = _arg_15_["root?"] +local function form_2a(_13_, _14_) + local start_char = _13_[1] + local end_char = _13_[2] + local escape_3f = _13_[3] + local root_3f = _14_["root?"] local flags - local function _16_() - if root_3f then - return "r" - else - return "" - end + local _15_ + if root_3f then + _15_ = "r" + else + _15_ = "" end - flags = ("Wnz" .. _16_()) + flags = ("Wnz" .. _15_) local cursor_char = current_char() local safe_start_char if escape_3f then @@ -99,69 +78,55 @@ local function form_2a(_12_, _14_) safe_end_char = end_char end local start - local function _19_() - if (cursor_char == start_char) then - return "c" - else - return "" - end + local _19_ + if (cursor_char == start_char) then + _19_ = "c" + else + _19_ = "" end - start = nvim.fn.searchpairpos(safe_start_char, "", safe_end_char, (flags .. "b" .. _19_()), skip_match_3f) + start = vim.fn.searchpairpos(safe_start_char, "", safe_end_char, (flags .. "b" .. _19_), skip_match_3f) local _end - local function _20_() - if (cursor_char == end_char) then - return "c" - else - return "" - end + local _21_ + if (cursor_char == end_char) then + _21_ = "c" + else + _21_ = "" end - _end = nvim.fn.searchpairpos(safe_start_char, "", safe_end_char, (flags .. _20_()), skip_match_3f) + _end = vim.fn.searchpairpos(safe_start_char, "", safe_end_char, (flags .. _21_), skip_match_3f) if (not nil_pos_3f(start) and not nil_pos_3f(_end)) then return {range = {start = {a.first(start), a.dec(a.second(start))}, ["end"] = {a.first(_end), a.dec(a.second(_end))}}, content = read_range(start, _end)} else return nil end end -_2amodule_locals_2a["form*"] = form_2a -do local _ = {form_2a, nil} end -local function distance_gt(_22_, _24_) - local _arg_23_ = _22_ - local al = _arg_23_[1] - local ac = _arg_23_[2] - local _arg_25_ = _24_ - local bl = _arg_25_[1] - local bc = _arg_25_[2] +local function distance_gt(_24_, _25_) + local al = _24_[1] + local ac = _24_[2] + local bl = _25_[1] + local bc = _25_[2] return ((al > bl) or ((al == bl) and (ac > bc))) end -_2amodule_locals_2a["distance-gt"] = distance_gt -do local _ = {distance_gt, nil} end local function range_distance(range) - local _let_26_ = range.start - local sl = _let_26_[1] - local sc = _let_26_[2] - local _let_27_ = range["end"] - local el = _let_27_[1] - local ec = _let_27_[2] + local sl = range.start[1] + local sc = range.start[2] + local el = range["end"][1] + local ec = range["end"][2] return {(sl - el), (sc - ec)} end -_2amodule_locals_2a["range-distance"] = range_distance -do local _ = {range_distance, nil} end local function form(opts) local forms - local function _28_(_241) + local function _26_(_241) return form_2a(_241, opts) end - forms = a.filter(a["table?"], a.map(_28_, config["get-in"]({"extract", "form_pairs"}))) - local function _29_(_241, _242) + forms = a.filter(a["table?"], a.map(_26_, config["get-in"]({"extract", "form_pairs"}))) + local function _27_(_241, _242) return distance_gt(range_distance(_241.range), range_distance(_242.range)) end - table.sort(forms, _29_) + table.sort(forms, _27_) if opts["root?"] then return a.last(forms) else return a.first(forms) end end -_2amodule_2a["form"] = form -do local _ = {form, nil} end -return _2amodule_2a +return {["skip-match?"] = skip_match_3f, form = form} diff --git a/lua/conjure/remote/stdio2.lua b/lua/conjure/remote/stdio2.lua index dfb4061f..58dfac15 100644 --- a/lua/conjure/remote/stdio2.lua +++ b/lua/conjure/remote/stdio2.lua @@ -1,26 +1,11 @@ -- [nfnl] Compiled from fnl/conjure/remote/stdio2.fnl by https://github.com/Olical/nfnl, do not edit. -local _2amodule_name_2a = "conjure.remote.stdio2" -local _2amodule_2a -do - _G.package.loaded[_2amodule_name_2a] = {} - _2amodule_2a = _G.package.loaded[_2amodule_name_2a] -end -local _2amodule_locals_2a -do - _2amodule_2a["aniseed/locals"] = {} - _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] -end -local autoload = (require("aniseed.autoload")).autoload -local a, client, log, nvim, str = autoload("conjure.aniseed.core"), autoload("conjure.client"), autoload("conjure.log"), autoload("conjure.aniseed.nvim"), autoload("conjure.aniseed.string") -do end (_2amodule_locals_2a)["a"] = a -_2amodule_locals_2a["client"] = client -_2amodule_locals_2a["log"] = log -_2amodule_locals_2a["nvim"] = nvim -_2amodule_locals_2a["str"] = str -do local _ = {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil} end +local _local_1_ = require("nfnl.module") +local autoload = _local_1_["autoload"] +local a = autoload("conjure.aniseed.core") +local str = autoload("conjure.aniseed.string") +local client = autoload("conjure.client") +local log = autoload("conjure.log") local uv = vim.loop -_2amodule_locals_2a["uv"] = uv -do local _ = {nil, nil} end local function parse_cmd(x) if a["table?"](x) then return {cmd = a.first(x), args = a.rest(x)} @@ -30,6 +15,4 @@ local function parse_cmd(x) return nil end end -_2amodule_2a["parse-cmd"] = parse_cmd -do local _ = {parse_cmd, nil} end -return _2amodule_2a +return {["parse-cmd"] = parse_cmd} diff --git a/lua/conjure/remote/swank.lua b/lua/conjure/remote/swank.lua index 7205152e..104c46c9 100644 --- a/lua/conjure/remote/swank.lua +++ b/lua/conjure/remote/swank.lua @@ -1,38 +1,23 @@ -- [nfnl] Compiled from fnl/conjure/remote/swank.fnl by https://github.com/Olical/nfnl, do not edit. -local _2amodule_name_2a = "conjure.remote.swank" -local _2amodule_2a -do - _G.package.loaded[_2amodule_name_2a] = {} - _2amodule_2a = _G.package.loaded[_2amodule_name_2a] -end -local _2amodule_locals_2a -do - _2amodule_2a["aniseed/locals"] = {} - _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] -end -local autoload = (require("aniseed.autoload")).autoload -local a, client, log, net, nvim, trn = autoload("conjure.aniseed.core"), autoload("conjure.client"), autoload("conjure.log"), autoload("conjure.net"), autoload("conjure.aniseed.nvim"), autoload("conjure.remote.transport.swank") -do end (_2amodule_locals_2a)["a"] = a -_2amodule_locals_2a["client"] = client -_2amodule_locals_2a["log"] = log -_2amodule_locals_2a["net"] = net -_2amodule_locals_2a["nvim"] = nvim -_2amodule_locals_2a["trn"] = trn -do local _ = {nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil} end +local _local_1_ = require("nfnl.module") +local autoload = _local_1_["autoload"] +local a = autoload("conjure.aniseed.core") +local client = autoload("conjure.client") +local log = autoload("conjure.log") +local net = autoload("conjure.net") +local trn = autoload("conjure.remote.transport.swank") local function send(conn, msg, cb) table.insert(conn.queue, 1, (cb or false)) - do end (conn.sock):write(trn.encode(msg)) + conn.sock:write(trn.encode(msg)) return nil end -_2amodule_2a["send"] = send -do local _ = {send, nil} end local function connect(opts) local conn = {decode = trn.decode, queue = {}} local function handle_message(err, chunk) if (err or not chunk) then return opts["on-error"](err) else - local function _1_(msg) + local function _2_(msg) local cb = table.remove(conn.queue) if cb then return cb(msg) @@ -40,20 +25,18 @@ local function connect(opts) return nil end end - return _1_(conn.decode(chunk)) + return _2_(conn.decode(chunk)) end end - local function _4_(err) + local function _5_(err) if err then return opts["on-failure"](err) else - do end (conn.sock):read_start(client["schedule-wrap"](handle_message)) + conn.sock:read_start(client["schedule-wrap"](handle_message)) return opts["on-success"]() end end - conn = a.merge(conn, net.connect({host = opts.host, port = opts.port, cb = client["schedule-wrap"](_4_)})) + conn = a.merge(conn, net.connect({host = opts.host, port = opts.port, cb = client["schedule-wrap"](_5_)})) return conn end -_2amodule_2a["connect"] = connect -do local _ = {connect, nil} end -return _2amodule_2a +return {send = send, connect = connect} diff --git a/lua/conjure/remote/transport/swank.lua b/lua/conjure/remote/transport/swank.lua index 3f1a105a..c6e7fe76 100644 --- a/lua/conjure/remote/transport/swank.lua +++ b/lua/conjure/remote/transport/swank.lua @@ -1,32 +1,16 @@ -- [nfnl] Compiled from fnl/conjure/remote/transport/swank.fnl by https://github.com/Olical/nfnl, do not edit. -local _2amodule_name_2a = "conjure.remote.transport.swank" -local _2amodule_2a -do - _G.package.loaded[_2amodule_name_2a] = {} - _2amodule_2a = _G.package.loaded[_2amodule_name_2a] -end -local _2amodule_locals_2a -do - _2amodule_2a["aniseed/locals"] = {} - _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] -end -local autoload = (require("aniseed.autoload")).autoload -local a, log = autoload("conjure.aniseed.core"), autoload("conjure.log") -do end (_2amodule_locals_2a)["a"] = a -_2amodule_locals_2a["log"] = log -do local _ = {nil, nil, nil, nil, nil, nil, nil} end +local _local_1_ = require("nfnl.module") +local autoload = _local_1_["autoload"] +local a = autoload("conjure.aniseed.core") +local log = autoload("conjure.log") local function encode(msg) local n = a.count(msg) local header = string.format("%06x", (1 + n)) return (header .. msg .. "\n") end -_2amodule_2a["encode"] = encode -do local _ = {encode, nil} end local function decode(msg) local len = tonumber(string.sub(msg, 1, 7), 16) local cmd = string.sub(msg, 7, len) return cmd end -_2amodule_2a["decode"] = decode -do local _ = {decode, nil} end -return _2amodule_2a +return {encode = encode, decode = decode}