├── .gitattributes ├── .github ├── CODE_OF_CONDUCT.md └── FUNDING.yml ├── .gitignore ├── .lnvim.fnl ├── Makefile ├── README.adoc ├── UNLICENSE ├── fnl └── nvim-local-fennel │ └── init.fnl ├── lua └── nvim-local-fennel │ ├── aniseed │ ├── autoload.lua │ ├── compile.lua │ ├── core.lua │ ├── deps │ │ ├── fennel.lua │ │ └── nvim.lua │ ├── env.lua │ ├── eval.lua │ ├── fennel.lua │ ├── fs.lua │ ├── macros.fnl │ ├── nvim.lua │ ├── nvim │ │ └── util.lua │ ├── setup.lua │ ├── string.lua │ ├── test.lua │ └── view.lua │ └── init.lua ├── plugin └── nvim-local-fennel.vim └── scripts └── dep.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | lua/* linguist-generated 2 | lua/aniseed linguist-vendored 3 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at ollie@oli.me.uk. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: Olical 2 | ko_fi: olical 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /deps/ 2 | /.lnvim.lua 3 | -------------------------------------------------------------------------------- /.lnvim.fnl: -------------------------------------------------------------------------------- 1 | ;; You can give the module any name you want. 2 | (module my-local-fennel 3 | {require {a nvim-local-fennel.aniseed.core 4 | str nvim-local-fennel.aniseed.string 5 | nvim nvim-local-fennel.aniseed.nvim}}) 6 | 7 | ;; A hyphen suffix denotes a private function. 8 | (defn- do-some-things [numbers] 9 | (a.println 10 | (nvim.fn.getcwd) 11 | (a.map a.inc numbers) 12 | {:Hello :Fennel!})) 13 | 14 | ;; Public value. 15 | ;; You could require this module and access it. 16 | (def counting [1 2 3]) 17 | 18 | ;; Executed as the file is loaded. 19 | (do-some-things counting) 20 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deps compile 2 | 3 | default: deps compile 4 | 5 | deps: 6 | scripts/dep.sh Olical aniseed origin/develop 7 | 8 | compile: 9 | rm -rf lua 10 | deps/aniseed/scripts/compile.sh 11 | deps/aniseed/scripts/embed.sh aniseed nvim-local-fennel 12 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = nvim-local-fennel 2 | 3 | ____ 4 | This has been superseded! I now recommend installing https://github.com/Olical/nfnl[Olical/nfnl] and enabling the `exrc` option in order to have https://github.com/Olical/nfnl#directory-local-neovim-configuration-in-fennel[directory local Neovim configuration in Fennel]. 5 | 6 | Once you have nfnl and a `.nfnl.fnl` file at the root of your project you can write to `.nvim.fnl` and have `.nvim.lua` compiled for you automatically. This file is loaded by native Neovim with zero plugins provided you have `:set exrc` enabled. 7 | 8 | This means even colleagues that don't have nfnl installed can use your directory local configuration. Consider this repo as essentially archived and superseded by this much smoother approach. 9 | ____ 10 | 11 | Run https://github.com/bakpakin/Fennel[Fennel] inside Neovim on startup with https://github.com/Olical/aniseed[Aniseed]. 12 | 13 | Add some Fennel code such as `(print "Hello, World!")` to a file named `.lnvim.fnl` in your current directory or anywhere above it such as your home directory. A file will be created beside the `.fnl` called `.lnvim.lua` which will be executed upon startup. Files higher up in your directory hierarchy, such as the home directory, will be executed before those found lower down, such as in a project. 14 | 15 | Be sure to git ignore `.lnvim.fnl` _and_ `.lnvim.lua` if you don't want to share your local configuration with others. If you do want to share a `.lnvim.fnl` I'd recommend you ignore the `.lua` file to prevent duplicated changes in git commits. 16 | 17 | Aniseed will only re-compile the Fennel code if it's changed since last time you opened Neovim. If you delete the `.lnvim.fnl` file then the `.lnvim.lua` file will be deleted automatically next time you launch Neovim to ensure you don't accidentally leave Lua files laying around. 18 | 19 | == Installation 20 | 21 | If you want interactive evaluation of the forms in your `.lnvim.fnl` file you can install https://github.com/Olical/conjure[Conjure] too. 22 | 23 | === https://github.com/wbthomason/packer.nvim[packer.nvim] 24 | 25 | [source,lua] 26 | ---- 27 | use 'Olical/nvim-local-fennel' 28 | use 'Olical/aniseed' 29 | ---- 30 | 31 | === https://github.com/junegunn/vim-plug[vim-plug] 32 | 33 | [source,viml] 34 | ---- 35 | Plug 'Olical/nvim-local-fennel' 36 | Plug 'Olical/aniseed' 37 | ---- 38 | 39 | == Access to Aniseed 40 | 41 | Aniseed is embedded under the `nvim-local-fennel.aniseed.*` module prefix, this means you can use Aniseed's macros and functions in your `.lnvim.fnl` files! 42 | 43 | [source,clojure] 44 | ---- 45 | ;; .lnvim.fnl 46 | ;; You can give the module any name you want. 47 | (module my-local-fennel 48 | {autoload {a nvim-local-fennel.aniseed.core 49 | str nvim-local-fennel.aniseed.string 50 | nvim nvim-local-fennel.aniseed.nvim}}) 51 | 52 | ;; A hyphen suffix denotes a private function. 53 | (defn- do-some-things [numbers] 54 | (a.println 55 | (nvim.fn.getcwd) 56 | (a.map a.inc numbers) 57 | {:Hello :Fennel!})) 58 | 59 | ;; Public value. 60 | ;; You could require this module and access it. 61 | (def counting [1 2 3]) 62 | 63 | ;; Executed as the file is loaded. 64 | (do-some-things counting) 65 | ---- 66 | 67 | == Unlicenced 68 | 69 | Find the full http://unlicense.org/[unlicense] in the `UNLICENSE` file, but here's a snippet. 70 | 71 | ____ 72 | This is free and unencumbered software released into the public domain. 73 | 74 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. 75 | ____ 76 | -------------------------------------------------------------------------------- /UNLICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | 26 | -------------------------------------------------------------------------------- /fnl/nvim-local-fennel/init.fnl: -------------------------------------------------------------------------------- 1 | (module nvim-local-fennel.init 2 | {autoload {compile nvim-local-fennel.aniseed.compile 3 | nvim nvim-local-fennel.aniseed.nvim 4 | a nvim-local-fennel.aniseed.core}}) 5 | 6 | (defn- cwd [] 7 | "Current working directory of Neovim." 8 | (nvim.fn.getcwd)) 9 | 10 | (defn- parent [dir] 11 | "Parent of a directory or nil." 12 | (let [candidate (nvim.fn.fnamemodify dir ":h")] 13 | (when (and (not= dir candidate) 14 | (nvim.fn.isdirectory candidate)) 15 | candidate))) 16 | 17 | (defn- parents [dir] 18 | "All parents of a directory." 19 | (var result []) 20 | (var dir (parent dir)) 21 | (while dir 22 | (table.insert result 1 dir) 23 | (set dir (parent dir))) 24 | result) 25 | 26 | (defn- file-readable? [path] 27 | "Is the file readable?" 28 | (= 1 (nvim.fn.filereadable path))) 29 | 30 | (defn- file-newer? [a b] 31 | (> (nvim.fn.getftime a) (nvim.fn.getftime b))) 32 | 33 | ;; Iterate over all directories from the root to the cwd. 34 | ;; For every .lnvim.fnl, compile it to .lvim.lua (if required) and execute it. 35 | ;; If a .lua is found without a .fnl, delete the .lua to clean up. 36 | (let [cwd (cwd) 37 | dirs (parents cwd)] 38 | (table.insert dirs cwd) 39 | (a.run! 40 | (fn [dir] 41 | (let [src (.. dir "/.lnvim.fnl") 42 | dest (.. dir "/.lnvim.lua")] 43 | (if (file-readable? src) 44 | (do 45 | (when (file-newer? src dest) 46 | (compile.file src dest)) 47 | (nvim.ex.luafile dest)) 48 | (when (file-readable? dest) 49 | (nvim.fn.delete dest))))) 50 | dirs)) 51 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/autoload.lua: -------------------------------------------------------------------------------- 1 | local _2afile_2a = "fnl/aniseed/autoload.fnl" 2 | local _2amodule_name_2a = "nvim-local-fennel.aniseed.autoload" 3 | local _2amodule_2a 4 | do 5 | package.loaded[_2amodule_name_2a] = {} 6 | _2amodule_2a = package.loaded[_2amodule_name_2a] 7 | end 8 | local _2amodule_locals_2a 9 | do 10 | _2amodule_2a["aniseed/locals"] = {} 11 | _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] 12 | end 13 | local function autoload(name) 14 | local res = {["aniseed/autoload-enabled?"] = true, ["aniseed/autoload-module"] = false} 15 | local function ensure() 16 | if res["aniseed/autoload-module"] then 17 | return res["aniseed/autoload-module"] 18 | else 19 | local m = require(name) 20 | do end (res)["aniseed/autoload-module"] = m 21 | return m 22 | end 23 | end 24 | local function _2_(t, ...) 25 | return ensure()(...) 26 | end 27 | local function _3_(t, k) 28 | return ensure()[k] 29 | end 30 | local function _4_(t, k, v) 31 | ensure()[k] = v 32 | return nil 33 | end 34 | return setmetatable(res, {__call = _2_, __index = _3_, __newindex = _4_}) 35 | end 36 | _2amodule_2a["autoload"] = autoload 37 | return _2amodule_2a 38 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/compile.lua: -------------------------------------------------------------------------------- 1 | local _2afile_2a = "fnl/aniseed/compile.fnl" 2 | local _2amodule_name_2a = "nvim-local-fennel.aniseed.compile" 3 | local _2amodule_2a 4 | do 5 | package.loaded[_2amodule_name_2a] = {} 6 | _2amodule_2a = package.loaded[_2amodule_name_2a] 7 | end 8 | local _2amodule_locals_2a 9 | do 10 | _2amodule_2a["aniseed/locals"] = {} 11 | _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] 12 | end 13 | local autoload = (require("nvim-local-fennel.aniseed.autoload")).autoload 14 | local a, fennel, fs, nvim = autoload("nvim-local-fennel.aniseed.core"), autoload("nvim-local-fennel.aniseed.fennel"), autoload("nvim-local-fennel.aniseed.fs"), autoload("nvim-local-fennel.aniseed.nvim") 15 | do end (_2amodule_locals_2a)["a"] = a 16 | _2amodule_locals_2a["fennel"] = fennel 17 | _2amodule_locals_2a["fs"] = fs 18 | _2amodule_locals_2a["nvim"] = nvim 19 | local function wrap_macros(code, opts) 20 | local macros_module = "nvim-local-fennel.aniseed.macros" 21 | local filename 22 | do 23 | local _1_ = a.get(opts, "filename") 24 | if (nil ~= _1_) then 25 | filename = string.gsub(_1_, (nvim.fn.getcwd() .. fs["path-sep"]), "") 26 | else 27 | filename = _1_ 28 | end 29 | end 30 | local function _3_() 31 | if filename then 32 | return ("\"" .. string.gsub(filename, "\\", "\\\\") .. "\"") 33 | else 34 | return "nil" 35 | end 36 | end 37 | return ("(local *file* " .. _3_() .. ")" .. "(require-macros \"" .. macros_module .. "\")\n" .. "(wrap-module-body " .. (code or "") .. ")") 38 | end 39 | _2amodule_2a["wrap-macros"] = wrap_macros 40 | local marker_prefix = "ANISEED_" 41 | _2amodule_2a["marker-prefix"] = marker_prefix 42 | local delete_marker = (marker_prefix .. "DELETE_ME") 43 | do end (_2amodule_2a)["delete-marker"] = delete_marker 44 | local delete_marker_pat = ("\n[^\n]-\"" .. delete_marker .. "\".-") 45 | do end (_2amodule_locals_2a)["delete-marker-pat"] = delete_marker_pat 46 | local function str(code, opts) 47 | ANISEED_STATIC_MODULES = (true == a.get(opts, "static?")) 48 | local fnl = fennel.impl() 49 | local function _4_() 50 | return string.gsub(string.gsub(fnl.compileString(wrap_macros(code, opts), a["merge!"]({allowedGlobals = false, compilerEnv = _G}, opts)), (delete_marker_pat .. "\n"), "\n"), (delete_marker_pat .. "$"), "") 51 | end 52 | return xpcall(_4_, fnl.traceback) 53 | end 54 | _2amodule_2a["str"] = str 55 | local function file(src, dest, opts) 56 | local code = a.slurp(src) 57 | local _5_, _6_ = str(code, a["merge!"]({filename = src, ["static?"] = true}, opts)) 58 | if ((_5_ == false) and (nil ~= _6_)) then 59 | local err = _6_ 60 | return nvim.err_writeln(err) 61 | elseif ((_5_ == true) and (nil ~= _6_)) then 62 | local result = _6_ 63 | fs.mkdirp(fs.basename(dest)) 64 | return a.spit(dest, result) 65 | else 66 | return nil 67 | end 68 | end 69 | _2amodule_2a["file"] = file 70 | local function glob(src_expr, src_dir, dest_dir, opts) 71 | for _, path in ipairs(fs.relglob(src_dir, src_expr)) do 72 | if fs["macro-file-path?"](path) then 73 | a.spit((dest_dir .. path), a.slurp((src_dir .. path))) 74 | else 75 | file((src_dir .. path), string.gsub((dest_dir .. path), ".fnl$", ".lua"), opts) 76 | end 77 | end 78 | return nil 79 | end 80 | _2amodule_2a["glob"] = glob 81 | return _2amodule_2a 82 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/core.lua: -------------------------------------------------------------------------------- 1 | local _2afile_2a = "fnl/aniseed/core.fnl" 2 | local _2amodule_name_2a = "nvim-local-fennel.aniseed.core" 3 | local _2amodule_2a 4 | do 5 | package.loaded[_2amodule_name_2a] = {} 6 | _2amodule_2a = package.loaded[_2amodule_name_2a] 7 | end 8 | local _2amodule_locals_2a 9 | do 10 | _2amodule_2a["aniseed/locals"] = {} 11 | _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] 12 | end 13 | local autoload = (require("nvim-local-fennel.aniseed.autoload")).autoload 14 | local view = autoload("nvim-local-fennel.aniseed.view") 15 | do end (_2amodule_locals_2a)["view"] = view 16 | math.randomseed(os.time()) 17 | local function rand(n) 18 | return (math.random() * (n or 1)) 19 | end 20 | _2amodule_2a["rand"] = rand 21 | local function nil_3f(x) 22 | return (nil == x) 23 | end 24 | _2amodule_2a["nil?"] = nil_3f 25 | local function number_3f(x) 26 | return ("number" == type(x)) 27 | end 28 | _2amodule_2a["number?"] = number_3f 29 | local function boolean_3f(x) 30 | return ("boolean" == type(x)) 31 | end 32 | _2amodule_2a["boolean?"] = boolean_3f 33 | local function string_3f(x) 34 | return ("string" == type(x)) 35 | end 36 | _2amodule_2a["string?"] = string_3f 37 | local function table_3f(x) 38 | return ("table" == type(x)) 39 | end 40 | _2amodule_2a["table?"] = table_3f 41 | local function function_3f(value) 42 | return ("function" == type(value)) 43 | end 44 | _2amodule_2a["function?"] = function_3f 45 | local function count(xs) 46 | if table_3f(xs) then 47 | return table.maxn(xs) 48 | elseif not xs then 49 | return 0 50 | else 51 | return #xs 52 | end 53 | end 54 | _2amodule_2a["count"] = count 55 | local function empty_3f(xs) 56 | return (0 == count(xs)) 57 | end 58 | _2amodule_2a["empty?"] = empty_3f 59 | local function first(xs) 60 | if xs then 61 | return xs[1] 62 | else 63 | return nil 64 | end 65 | end 66 | _2amodule_2a["first"] = first 67 | local function second(xs) 68 | if xs then 69 | return xs[2] 70 | else 71 | return nil 72 | end 73 | end 74 | _2amodule_2a["second"] = second 75 | local function last(xs) 76 | if xs then 77 | return xs[count(xs)] 78 | else 79 | return nil 80 | end 81 | end 82 | _2amodule_2a["last"] = last 83 | local function inc(n) 84 | return (n + 1) 85 | end 86 | _2amodule_2a["inc"] = inc 87 | local function dec(n) 88 | return (n - 1) 89 | end 90 | _2amodule_2a["dec"] = dec 91 | local function even_3f(n) 92 | return ((n % 2) == 0) 93 | end 94 | _2amodule_2a["even?"] = even_3f 95 | local function odd_3f(n) 96 | return not even_3f(n) 97 | end 98 | _2amodule_2a["odd?"] = odd_3f 99 | local function keys(t) 100 | local result = {} 101 | if t then 102 | for k, _ in pairs(t) do 103 | table.insert(result, k) 104 | end 105 | else 106 | end 107 | return result 108 | end 109 | _2amodule_2a["keys"] = keys 110 | local function vals(t) 111 | local result = {} 112 | if t then 113 | for _, v in pairs(t) do 114 | table.insert(result, v) 115 | end 116 | else 117 | end 118 | return result 119 | end 120 | _2amodule_2a["vals"] = vals 121 | local function kv_pairs(t) 122 | local result = {} 123 | if t then 124 | for k, v in pairs(t) do 125 | table.insert(result, {k, v}) 126 | end 127 | else 128 | end 129 | return result 130 | end 131 | _2amodule_2a["kv-pairs"] = kv_pairs 132 | local function run_21(f, xs) 133 | if xs then 134 | local nxs = count(xs) 135 | if (nxs > 0) then 136 | for i = 1, nxs do 137 | f(xs[i]) 138 | end 139 | return nil 140 | else 141 | return nil 142 | end 143 | else 144 | return nil 145 | end 146 | end 147 | _2amodule_2a["run!"] = run_21 148 | local function filter(f, xs) 149 | local result = {} 150 | local function _10_(x) 151 | if f(x) then 152 | return table.insert(result, x) 153 | else 154 | return nil 155 | end 156 | end 157 | run_21(_10_, xs) 158 | return result 159 | end 160 | _2amodule_2a["filter"] = filter 161 | local function map(f, xs) 162 | local result = {} 163 | local function _12_(x) 164 | local mapped = f(x) 165 | local function _13_() 166 | if (0 == select("#", mapped)) then 167 | return nil 168 | else 169 | return mapped 170 | end 171 | end 172 | return table.insert(result, _13_()) 173 | end 174 | run_21(_12_, xs) 175 | return result 176 | end 177 | _2amodule_2a["map"] = map 178 | local function map_indexed(f, xs) 179 | return map(f, kv_pairs(xs)) 180 | end 181 | _2amodule_2a["map-indexed"] = map_indexed 182 | local function identity(x) 183 | return x 184 | end 185 | _2amodule_2a["identity"] = identity 186 | local function reduce(f, init, xs) 187 | local result = init 188 | local function _14_(x) 189 | result = f(result, x) 190 | return nil 191 | end 192 | run_21(_14_, xs) 193 | return result 194 | end 195 | _2amodule_2a["reduce"] = reduce 196 | local function some(f, xs) 197 | local result = nil 198 | local n = 1 199 | while (nil_3f(result) and (n <= count(xs))) do 200 | local candidate = f(xs[n]) 201 | if candidate then 202 | result = candidate 203 | else 204 | end 205 | n = inc(n) 206 | end 207 | return result 208 | end 209 | _2amodule_2a["some"] = some 210 | local function butlast(xs) 211 | local total = count(xs) 212 | local function _18_(_16_) 213 | local _arg_17_ = _16_ 214 | local n = _arg_17_[1] 215 | local v = _arg_17_[2] 216 | return (n ~= total) 217 | end 218 | return map(second, filter(_18_, kv_pairs(xs))) 219 | end 220 | _2amodule_2a["butlast"] = butlast 221 | local function rest(xs) 222 | local function _21_(_19_) 223 | local _arg_20_ = _19_ 224 | local n = _arg_20_[1] 225 | local v = _arg_20_[2] 226 | return (n ~= 1) 227 | end 228 | return map(second, filter(_21_, kv_pairs(xs))) 229 | end 230 | _2amodule_2a["rest"] = rest 231 | local function concat(...) 232 | local result = {} 233 | local function _22_(xs) 234 | local function _23_(x) 235 | return table.insert(result, x) 236 | end 237 | return run_21(_23_, xs) 238 | end 239 | run_21(_22_, {...}) 240 | return result 241 | end 242 | _2amodule_2a["concat"] = concat 243 | local function mapcat(f, xs) 244 | return concat(unpack(map(f, xs))) 245 | end 246 | _2amodule_2a["mapcat"] = mapcat 247 | local function pr_str(...) 248 | local s 249 | local function _24_(x) 250 | return view.serialise(x, {["one-line"] = true}) 251 | end 252 | s = table.concat(map(_24_, {...}), " ") 253 | if (nil_3f(s) or ("" == s)) then 254 | return "nil" 255 | else 256 | return s 257 | end 258 | end 259 | _2amodule_2a["pr-str"] = pr_str 260 | local function str(...) 261 | local function _26_(acc, s) 262 | return (acc .. s) 263 | end 264 | local function _27_(s) 265 | if string_3f(s) then 266 | return s 267 | else 268 | return pr_str(s) 269 | end 270 | end 271 | return reduce(_26_, "", map(_27_, {...})) 272 | end 273 | _2amodule_2a["str"] = str 274 | local function println(...) 275 | local function _29_(acc, s) 276 | return (acc .. s) 277 | end 278 | local function _32_(_30_) 279 | local _arg_31_ = _30_ 280 | local i = _arg_31_[1] 281 | local s = _arg_31_[2] 282 | if (1 == i) then 283 | return s 284 | else 285 | return (" " .. s) 286 | end 287 | end 288 | local function _34_(s) 289 | if string_3f(s) then 290 | return s 291 | else 292 | return pr_str(s) 293 | end 294 | end 295 | return print(reduce(_29_, "", map_indexed(_32_, map(_34_, {...})))) 296 | end 297 | _2amodule_2a["println"] = println 298 | local function pr(...) 299 | return println(pr_str(...)) 300 | end 301 | _2amodule_2a["pr"] = pr 302 | local function slurp(path, silent_3f) 303 | local _36_, _37_ = io.open(path, "r") 304 | if ((_36_ == nil) and (nil ~= _37_)) then 305 | local msg = _37_ 306 | return nil 307 | elseif (nil ~= _36_) then 308 | local f = _36_ 309 | local content = f:read("*all") 310 | f:close() 311 | return content 312 | else 313 | return nil 314 | end 315 | end 316 | _2amodule_2a["slurp"] = slurp 317 | local function spit(path, content) 318 | local _39_, _40_ = io.open(path, "w") 319 | if ((_39_ == nil) and (nil ~= _40_)) then 320 | local msg = _40_ 321 | return error(("Could not open file: " .. msg)) 322 | elseif (nil ~= _39_) then 323 | local f = _39_ 324 | f:write(content) 325 | f:close() 326 | return nil 327 | else 328 | return nil 329 | end 330 | end 331 | _2amodule_2a["spit"] = spit 332 | local function merge_21(base, ...) 333 | local function _42_(acc, m) 334 | if m then 335 | for k, v in pairs(m) do 336 | acc[k] = v 337 | end 338 | else 339 | end 340 | return acc 341 | end 342 | return reduce(_42_, (base or {}), {...}) 343 | end 344 | _2amodule_2a["merge!"] = merge_21 345 | local function merge(...) 346 | return merge_21({}, ...) 347 | end 348 | _2amodule_2a["merge"] = merge 349 | local function select_keys(t, ks) 350 | if (t and ks) then 351 | local function _44_(acc, k) 352 | if k then 353 | acc[k] = t[k] 354 | else 355 | end 356 | return acc 357 | end 358 | return reduce(_44_, {}, ks) 359 | else 360 | return {} 361 | end 362 | end 363 | _2amodule_2a["select-keys"] = select_keys 364 | local function get(t, k, d) 365 | local res 366 | if table_3f(t) then 367 | local val = t[k] 368 | if not nil_3f(val) then 369 | res = val 370 | else 371 | res = nil 372 | end 373 | else 374 | res = nil 375 | end 376 | if nil_3f(res) then 377 | return d 378 | else 379 | return res 380 | end 381 | end 382 | _2amodule_2a["get"] = get 383 | local function get_in(t, ks, d) 384 | local res 385 | local function _50_(acc, k) 386 | if table_3f(acc) then 387 | return get(acc, k) 388 | else 389 | return nil 390 | end 391 | end 392 | res = reduce(_50_, t, ks) 393 | if nil_3f(res) then 394 | return d 395 | else 396 | return res 397 | end 398 | end 399 | _2amodule_2a["get-in"] = get_in 400 | local function assoc(t, ...) 401 | local _let_53_ = {...} 402 | local k = _let_53_[1] 403 | local v = _let_53_[2] 404 | local xs = (function (t, k) local mt = getmetatable(t) if "table" == type(mt) and mt.__fennelrest then return mt.__fennelrest(t, k) else return {(table.unpack or unpack)(t, k)} end end)(_let_53_, 3) 405 | local rem = count(xs) 406 | local t0 = (t or {}) 407 | if odd_3f(rem) then 408 | error("assoc expects even number of arguments after table, found odd number") 409 | else 410 | end 411 | if not nil_3f(k) then 412 | t0[k] = v 413 | else 414 | end 415 | if (rem > 0) then 416 | assoc(t0, unpack(xs)) 417 | else 418 | end 419 | return t0 420 | end 421 | _2amodule_2a["assoc"] = assoc 422 | local function assoc_in(t, ks, v) 423 | local path = butlast(ks) 424 | local final = last(ks) 425 | local t0 = (t or {}) 426 | local function _57_(acc, k) 427 | local step = get(acc, k) 428 | if nil_3f(step) then 429 | return get(assoc(acc, k, {}), k) 430 | else 431 | return step 432 | end 433 | end 434 | assoc(reduce(_57_, t0, path), final, v) 435 | return t0 436 | end 437 | _2amodule_2a["assoc-in"] = assoc_in 438 | local function update(t, k, f) 439 | return assoc(t, k, f(get(t, k))) 440 | end 441 | _2amodule_2a["update"] = update 442 | local function update_in(t, ks, f) 443 | return assoc_in(t, ks, f(get_in(t, ks))) 444 | end 445 | _2amodule_2a["update-in"] = update_in 446 | local function constantly(v) 447 | local function _59_() 448 | return v 449 | end 450 | return _59_ 451 | end 452 | _2amodule_2a["constantly"] = constantly 453 | return _2amodule_2a 454 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/deps/nvim.lua: -------------------------------------------------------------------------------- 1 | -- Bring vim into local scope. 2 | local vim = vim 3 | local api = vim.api 4 | local inspect = vim.inspect 5 | 6 | local function extend(t, o) 7 | local mt = getmetatable(t) 8 | for k, v in pairs(o) do 9 | rawset(mt, k, v) 10 | end 11 | return t 12 | end 13 | 14 | -- Equivalent to `echo vim.inspect(...)` 15 | local function nvim_print(...) 16 | if select("#", ...) == 1 then 17 | api.nvim_out_write(inspect((...))) 18 | else 19 | api.nvim_out_write(inspect {...}) 20 | end 21 | api.nvim_out_write("\n") 22 | end 23 | 24 | --- Equivalent to `echo` EX command 25 | local function nvim_echo(...) 26 | for i = 1, select("#", ...) do 27 | local part = select(i, ...) 28 | api.nvim_out_write(tostring(part)) 29 | -- vim.api.nvim_out_write("\n") 30 | api.nvim_out_write(" ") 31 | end 32 | api.nvim_out_write("\n") 33 | end 34 | 35 | local window_options = { 36 | arab = true; arabic = true; breakindent = true; breakindentopt = true; 37 | bri = true; briopt = true; cc = true; cocu = true; 38 | cole = true; colorcolumn = true; concealcursor = true; conceallevel = true; 39 | crb = true; cuc = true; cul = true; cursorbind = true; 40 | cursorcolumn = true; cursorline = true; diff = true; fcs = true; 41 | fdc = true; fde = true; fdi = true; fdl = true; 42 | fdm = true; fdn = true; fdt = true; fen = true; 43 | fillchars = true; fml = true; fmr = true; foldcolumn = true; 44 | foldenable = true; foldexpr = true; foldignore = true; foldlevel = true; 45 | foldmarker = true; foldmethod = true; foldminlines = true; foldnestmax = true; 46 | foldtext = true; lbr = true; lcs = true; linebreak = true; 47 | list = true; listchars = true; nu = true; number = true; 48 | numberwidth = true; nuw = true; previewwindow = true; pvw = true; 49 | relativenumber = true; rightleft = true; rightleftcmd = true; rl = true; 50 | rlc = true; rnu = true; scb = true; scl = true; 51 | scr = true; scroll = true; scrollbind = true; signcolumn = true; 52 | spell = true; statusline = true; stl = true; wfh = true; 53 | wfw = true; winbl = true; winblend = true; winfixheight = true; 54 | winfixwidth = true; winhighlight = true; winhl = true; wrap = true; 55 | } 56 | 57 | local function validate(conf) 58 | assert(type(conf) == 'table') 59 | local type_names = { 60 | t='table', s='string', n='number', b='boolean', f='function', c='callable', 61 | ['table']='table', ['string']='string', ['number']='number', 62 | ['boolean']='boolean', ['function']='function', ['callable']='callable', 63 | ['nil']='nil', ['thread']='thread', ['userdata']='userdata', 64 | } 65 | for k, v in pairs(conf) do 66 | if not (v[3] and v[1] == nil) and type(v[1]) ~= type_names[v[2]] then 67 | error(string.format("validation_failed: %q: expected %s, received %s", k, type_names[v[2]], type(v[1]))) 68 | end 69 | end 70 | return true 71 | end 72 | 73 | local function make_meta_accessor(get, set, del) 74 | validate { 75 | get = {get, 'f'}; 76 | set = {set, 'f'}; 77 | del = {del, 'f', true}; 78 | } 79 | local mt = {} 80 | if del then 81 | function mt:__newindex(k, v) 82 | if v == nil then 83 | return del(k) 84 | end 85 | return set(k, v) 86 | end 87 | else 88 | function mt:__newindex(k, v) 89 | return set(k, v) 90 | end 91 | end 92 | function mt:__index(k) 93 | return get(k) 94 | end 95 | return setmetatable({}, mt) 96 | end 97 | 98 | local function pcall_ret(status, ...) 99 | if status then return ... end 100 | end 101 | 102 | local function nil_wrap(fn) 103 | return function(...) 104 | return pcall_ret(pcall(fn, ...)) 105 | end 106 | end 107 | 108 | local fn = setmetatable({}, { 109 | __index = function(t, k) 110 | local f = function(...) return api.nvim_call_function(k, {...}) end 111 | rawset(t, k, f) 112 | return f 113 | end 114 | }) 115 | 116 | local function getenv(k) 117 | local v = fn.getenv(k) 118 | if v == vim.NIL then 119 | return nil 120 | end 121 | return v 122 | end 123 | 124 | local function new_win_accessor(winnr) 125 | local function get(k) 126 | if winnr == nil and type(k) == 'number' then 127 | return new_win_accessor(k) 128 | end 129 | return api.nvim_win_get_var(winnr or 0, k) 130 | end 131 | local function set(k, v) return api.nvim_win_set_var(winnr or 0, k, v) end 132 | local function del(k) return api.nvim_win_del_var(winnr or 0, k) end 133 | return make_meta_accessor(nil_wrap(get), set, del) 134 | end 135 | 136 | local function new_win_opt_accessor(winnr) 137 | local function get(k) 138 | if winnr == nil and type(k) == 'number' then 139 | return new_win_opt_accessor(k) 140 | end 141 | return api.nvim_win_get_option(winnr or 0, k) 142 | end 143 | local function set(k, v) return api.nvim_win_set_option(winnr or 0, k, v) end 144 | return make_meta_accessor(nil_wrap(get), set) 145 | end 146 | 147 | local function new_buf_accessor(bufnr) 148 | local function get(k) 149 | if bufnr == nil and type(k) == 'number' then 150 | return new_buf_accessor(k) 151 | end 152 | return api.nvim_buf_get_var(bufnr or 0, k) 153 | end 154 | local function set(k, v) return api.nvim_buf_set_var(bufnr or 0, k, v) end 155 | local function del(k) return api.nvim_buf_del_var(bufnr or 0, k) end 156 | return make_meta_accessor(nil_wrap(get), set, del) 157 | end 158 | 159 | local function new_buf_opt_accessor(bufnr) 160 | local function get(k) 161 | if window_options[k] then 162 | return api.nvim_err_writeln(k.." is a window option, not a buffer option") 163 | end 164 | if bufnr == nil and type(k) == 'number' then 165 | return new_buf_opt_accessor(k) 166 | end 167 | return api.nvim_buf_get_option(bufnr or 0, k) 168 | end 169 | local function set(k, v) 170 | if window_options[k] then 171 | return api.nvim_err_writeln(k.." is a window option, not a buffer option") 172 | end 173 | return api.nvim_buf_set_option(bufnr or 0, k, v) 174 | end 175 | return make_meta_accessor(nil_wrap(get), set) 176 | end 177 | 178 | -- `nvim.$method(...)` redirects to `nvim.api.nvim_$method(...)` 179 | -- `nvim.fn.$method(...)` redirects to `vim.api.nvim_call_function($method, {...})` 180 | -- TODO `nvim.ex.$command(...)` is approximately `:$command {...}.join(" ")` 181 | -- `nvim.print(...)` is approximately `echo vim.inspect(...)` 182 | -- `nvim.echo(...)` is approximately `echo table.concat({...}, '\n')` 183 | -- Both methods cache the inital lookup in the metatable, but there is api small overhead regardless. 184 | return setmetatable({ 185 | print = nvim_print; 186 | echo = nvim_echo; 187 | fn = rawget(vim, "fn") or fn; 188 | validate = validate; 189 | g = rawget(vim, 'g') or make_meta_accessor(nil_wrap(api.nvim_get_var), api.nvim_set_var, api.nvim_del_var); 190 | v = rawget(vim, 'v') or make_meta_accessor(nil_wrap(api.nvim_get_vvar), api.nvim_set_vvar); 191 | o = rawget(vim, 'o') or make_meta_accessor(api.nvim_get_option, api.nvim_set_option); 192 | w = new_win_accessor(nil); 193 | b = new_buf_accessor(nil); 194 | env = rawget(vim, "env") or make_meta_accessor(getenv, fn.setenv); 195 | wo = rawget(vim, "wo") or new_win_opt_accessor(nil); 196 | bo = rawget(vim, "bo") or new_buf_opt_accessor(nil); 197 | buf = { 198 | line = api.nvim_get_current_line; 199 | nr = api.nvim_get_current_buf; 200 | }; 201 | ex = setmetatable({}, { 202 | __index = function(t, k) 203 | local command = k:gsub("_$", "!") 204 | local f = function(...) 205 | return api.nvim_command(table.concat(vim.tbl_flatten {command, ...}, " ")) 206 | end 207 | rawset(t, k, f) 208 | return f 209 | end 210 | }); 211 | }, { 212 | __index = function(t, k) 213 | local f = api['nvim_'..k] 214 | if f then 215 | rawset(t, k, f) 216 | end 217 | return f 218 | end 219 | }) 220 | -- vim:et ts=2 sw=2 221 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/env.lua: -------------------------------------------------------------------------------- 1 | local _2afile_2a = "fnl/aniseed/env.fnl" 2 | local _2amodule_name_2a = "nvim-local-fennel.aniseed.env" 3 | local _2amodule_2a 4 | do 5 | package.loaded[_2amodule_name_2a] = {} 6 | _2amodule_2a = package.loaded[_2amodule_name_2a] 7 | end 8 | local _2amodule_locals_2a 9 | do 10 | _2amodule_2a["aniseed/locals"] = {} 11 | _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] 12 | end 13 | local autoload = (require("nvim-local-fennel.aniseed.autoload")).autoload 14 | local compile, fennel, fs, nvim = autoload("nvim-local-fennel.aniseed.compile"), autoload("nvim-local-fennel.aniseed.fennel"), autoload("nvim-local-fennel.aniseed.fs"), autoload("nvim-local-fennel.aniseed.nvim") 15 | do end (_2amodule_locals_2a)["compile"] = compile 16 | _2amodule_locals_2a["fennel"] = fennel 17 | _2amodule_locals_2a["fs"] = fs 18 | _2amodule_locals_2a["nvim"] = nvim 19 | local config_dir = nvim.fn.stdpath("config") 20 | do end (_2amodule_locals_2a)["config-dir"] = config_dir 21 | local function quiet_require(m) 22 | local ok_3f, err = nil, nil 23 | local function _1_() 24 | return require(m) 25 | end 26 | ok_3f, err = pcall(_1_) 27 | if (not ok_3f and not err:find(("module '" .. m .. "' not found"))) then 28 | return nvim.ex.echoerr(err) 29 | else 30 | return nil 31 | end 32 | end 33 | _2amodule_locals_2a["quiet-require"] = quiet_require 34 | local function init(opts) 35 | local opts0 36 | if ("table" == type(opts)) then 37 | opts0 = opts 38 | else 39 | opts0 = {} 40 | end 41 | local glob_expr = "**/*.fnl" 42 | local fnl_dir = nvim.fn.expand((opts0.input or (config_dir .. fs["path-sep"] .. "fnl"))) 43 | local lua_dir = nvim.fn.expand((opts0.output or (config_dir .. fs["path-sep"] .. "lua"))) 44 | if opts0.output then 45 | package.path = (package.path .. ";" .. lua_dir .. fs["path-sep"] .. "?.lua") 46 | else 47 | end 48 | local function _5_(path) 49 | if fs["macro-file-path?"](path) then 50 | return path 51 | else 52 | return string.gsub(path, ".fnl$", ".lua") 53 | end 54 | end 55 | if (((false ~= opts0.compile) or os.getenv("ANISEED_ENV_COMPILE")) and fs["glob-dir-newer?"](fnl_dir, lua_dir, glob_expr, _5_)) then 56 | fennel["add-path"]((fnl_dir .. fs["path-sep"] .. "?.fnl")) 57 | compile.glob(glob_expr, fnl_dir, lua_dir, opts0) 58 | else 59 | end 60 | return quiet_require((opts0.module or "init")) 61 | end 62 | _2amodule_2a["init"] = init 63 | return _2amodule_2a 64 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/eval.lua: -------------------------------------------------------------------------------- 1 | local _2afile_2a = "fnl/aniseed/eval.fnl" 2 | local _2amodule_name_2a = "nvim-local-fennel.aniseed.eval" 3 | local _2amodule_2a 4 | do 5 | package.loaded[_2amodule_name_2a] = {} 6 | _2amodule_2a = package.loaded[_2amodule_name_2a] 7 | end 8 | local _2amodule_locals_2a 9 | do 10 | _2amodule_2a["aniseed/locals"] = {} 11 | _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] 12 | end 13 | local autoload = (require("nvim-local-fennel.aniseed.autoload")).autoload 14 | local a, compile, fennel, fs, nvim = autoload("nvim-local-fennel.aniseed.core"), autoload("nvim-local-fennel.aniseed.compile"), autoload("nvim-local-fennel.aniseed.fennel"), autoload("nvim-local-fennel.aniseed.fs"), autoload("nvim-local-fennel.aniseed.nvim") 15 | do end (_2amodule_locals_2a)["a"] = a 16 | _2amodule_locals_2a["compile"] = compile 17 | _2amodule_locals_2a["fennel"] = fennel 18 | _2amodule_locals_2a["fs"] = fs 19 | _2amodule_locals_2a["nvim"] = nvim 20 | local function str(code, opts) 21 | local fnl = fennel.impl() 22 | local function _1_() 23 | return fnl.eval(compile["wrap-macros"](code, opts), a.merge({compilerEnv = _G}, opts)) 24 | end 25 | return xpcall(_1_, fnl.traceback) 26 | end 27 | _2amodule_2a["str"] = str 28 | local function clean_values(vals) 29 | local function _2_(val) 30 | if a["table?"](val) then 31 | return (compile["delete-marker"] ~= a.first(val)) 32 | else 33 | return true 34 | end 35 | end 36 | return a.filter(_2_, vals) 37 | end 38 | _2amodule_locals_2a["clean-values"] = clean_values 39 | local function clean_error(err) 40 | return string.gsub(string.gsub(err, "^%b[string .-%b]:%d+: ", ""), "^Compile error in .-:%d+\n%s+", "") 41 | end 42 | _2amodule_2a["clean-error"] = clean_error 43 | local function repl(opts) 44 | local eval_values = nil 45 | local fnl = fennel.impl() 46 | local opts0 = (opts or {}) 47 | local co 48 | local function _4_() 49 | local function _5_(_241) 50 | eval_values = clean_values(_241) 51 | return nil 52 | end 53 | local function _6_(_241, _242) 54 | return (opts0["error-handler"] or nvim.err_writeln)(clean_error(_242)) 55 | end 56 | return fnl.repl(a.merge({compilerEnv = _G, pp = a.identity, readChunk = coroutine.yield, onValues = _5_, onError = _6_}, opts0)) 57 | end 58 | co = coroutine.create(_4_) 59 | coroutine.resume(co) 60 | coroutine.resume(co, compile["wrap-macros"](nil, opts0)) 61 | eval_values = nil 62 | local function _7_(code) 63 | ANISEED_STATIC_MODULES = false 64 | coroutine.resume(co, code) 65 | local prev_eval_values = eval_values 66 | eval_values = nil 67 | return prev_eval_values 68 | end 69 | return _7_ 70 | end 71 | _2amodule_2a["repl"] = repl 72 | return _2amodule_2a 73 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/fennel.lua: -------------------------------------------------------------------------------- 1 | local _2afile_2a = "fnl/aniseed/fennel.fnl" 2 | local _2amodule_name_2a = "nvim-local-fennel.aniseed.fennel" 3 | local _2amodule_2a 4 | do 5 | package.loaded[_2amodule_name_2a] = {} 6 | _2amodule_2a = package.loaded[_2amodule_name_2a] 7 | end 8 | local _2amodule_locals_2a 9 | do 10 | _2amodule_2a["aniseed/locals"] = {} 11 | _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] 12 | end 13 | local autoload = (require("nvim-local-fennel.aniseed.autoload")).autoload 14 | local a, fs, nvim, str = autoload("nvim-local-fennel.aniseed.core"), autoload("nvim-local-fennel.aniseed.fs"), autoload("nvim-local-fennel.aniseed.nvim"), autoload("nvim-local-fennel.aniseed.string") 15 | do end (_2amodule_locals_2a)["a"] = a 16 | _2amodule_locals_2a["fs"] = fs 17 | _2amodule_locals_2a["nvim"] = nvim 18 | _2amodule_locals_2a["str"] = str 19 | local function sync_rtp(compiler) 20 | local fnl_suffix = (fs["path-sep"] .. "fnl" .. fs["path-sep"] .. "?.fnl") 21 | local lua_suffix = (fs["path-sep"] .. "lua" .. fs["path-sep"] .. "?.fnl") 22 | local rtps = nvim.list_runtime_paths() 23 | local fnl_paths 24 | local function _1_(_241) 25 | return (_241 .. fnl_suffix) 26 | end 27 | fnl_paths = a.map(_1_, rtps) 28 | local lua_paths 29 | local function _2_(_241) 30 | return (_241 .. lua_suffix) 31 | end 32 | lua_paths = a.map(_2_, rtps) 33 | do end (compiler)["macro-path"] = str.join(";", a.concat(fnl_paths, lua_paths)) 34 | return nil 35 | end 36 | _2amodule_2a["sync-rtp"] = sync_rtp 37 | local state = {["compiler-loaded?"] = false} 38 | _2amodule_locals_2a["state"] = state 39 | local function impl() 40 | local compiler = require("nvim-local-fennel.aniseed.deps.fennel") 41 | if not state["compiler-loaded?"] then 42 | state["compiler-loaded?"] = true 43 | sync_rtp(compiler) 44 | else 45 | end 46 | return compiler 47 | end 48 | _2amodule_2a["impl"] = impl 49 | local function add_path(path) 50 | local fnl = impl() 51 | do end (fnl)["macro-path"] = (fnl["macro-path"] .. ";" .. path) 52 | return nil 53 | end 54 | _2amodule_2a["add-path"] = add_path 55 | return _2amodule_2a 56 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/fs.lua: -------------------------------------------------------------------------------- 1 | local _2afile_2a = "fnl/aniseed/fs.fnl" 2 | local _2amodule_name_2a = "nvim-local-fennel.aniseed.fs" 3 | local _2amodule_2a 4 | do 5 | package.loaded[_2amodule_name_2a] = {} 6 | _2amodule_2a = package.loaded[_2amodule_name_2a] 7 | end 8 | local _2amodule_locals_2a 9 | do 10 | _2amodule_2a["aniseed/locals"] = {} 11 | _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] 12 | end 13 | local autoload = (require("nvim-local-fennel.aniseed.autoload")).autoload 14 | local a, nvim = autoload("nvim-local-fennel.aniseed.core"), autoload("nvim-local-fennel.aniseed.nvim") 15 | do end (_2amodule_locals_2a)["a"] = a 16 | _2amodule_locals_2a["nvim"] = nvim 17 | local function basename(path) 18 | return nvim.fn.fnamemodify(path, ":h") 19 | end 20 | _2amodule_2a["basename"] = basename 21 | local function mkdirp(dir) 22 | return nvim.fn.mkdir(dir, "p") 23 | end 24 | _2amodule_2a["mkdirp"] = mkdirp 25 | local function relglob(dir, expr) 26 | local dir_len = a.inc(string.len(dir)) 27 | local function _1_(_241) 28 | return string.sub(_241, dir_len) 29 | end 30 | return a.map(_1_, nvim.fn.globpath(dir, expr, true, true)) 31 | end 32 | _2amodule_2a["relglob"] = relglob 33 | local function glob_dir_newer_3f(a_dir, b_dir, expr, b_dir_path_fn) 34 | local newer_3f = false 35 | for _, path in ipairs(relglob(a_dir, expr)) do 36 | if (nvim.fn.getftime((a_dir .. path)) > nvim.fn.getftime((b_dir .. b_dir_path_fn(path)))) then 37 | newer_3f = true 38 | else 39 | end 40 | end 41 | return newer_3f 42 | end 43 | _2amodule_2a["glob-dir-newer?"] = glob_dir_newer_3f 44 | local function macro_file_path_3f(path) 45 | return a["string?"](string.match(path, "macros?.fnl$")) 46 | end 47 | _2amodule_2a["macro-file-path?"] = macro_file_path_3f 48 | local path_sep 49 | do 50 | local os = string.lower(jit.os) 51 | if (("linux" == os) or ("osx" == os) or ("bsd" == os)) then 52 | path_sep = "/" 53 | else 54 | path_sep = "\\" 55 | end 56 | end 57 | _2amodule_2a["path-sep"] = path_sep 58 | return _2amodule_2a 59 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/macros.fnl: -------------------------------------------------------------------------------- 1 | ;; All of Aniseed's macros in one place. 2 | ;; Can't be compiled to Lua directly. 3 | 4 | ;; Automatically loaded through require-macros for all Aniseed based evaluations. 5 | 6 | (fn nil? [x] 7 | (= :nil (type x))) 8 | 9 | (fn seq? [x] 10 | (not (nil? (. x 1)))) 11 | 12 | (fn str [x] 13 | (if (= :string (type x)) 14 | x 15 | (tostring x))) 16 | 17 | (fn sorted-each [f x] 18 | (let [acc []] 19 | (each [k v (pairs x)] 20 | (table.insert acc [k v])) 21 | (table.sort 22 | acc 23 | (fn [a b] 24 | (< (str (. a 1)) (str (. b 1))))) 25 | (each [_ [k v] (ipairs acc)] 26 | (f k v)))) 27 | 28 | (fn contains? [t target] 29 | (var seen? false) 30 | (each [k v (pairs t)] 31 | (when (= k target) 32 | (set seen? true))) 33 | seen?) 34 | 35 | ;; This marker can be used by a post-processor to delete a useless byproduct line. 36 | (local delete-marker :ANISEED_DELETE_ME) 37 | 38 | ;; We store all locals under this for later splatting. 39 | (local locals-key :aniseed/locals) 40 | 41 | ;; Various symbols we want to use multiple times. 42 | ;; Avoids the compiler complaining that we're introducing locals without gensym. 43 | (local mod-name-sym (sym :*module-name*)) 44 | (local mod-sym (sym :*module*)) 45 | (local mod-locals-sym (sym :*module-locals*)) 46 | (local autoload-sym (sym :autoload)) 47 | 48 | ;; Upserts the existence of the module for subsequent def forms and expands the 49 | ;; bound function calls into the current context. 50 | ;; 51 | ;; On subsequent interactive calls it will expand the existing module into your 52 | ;; current context. This should be used by Conjure as you enter a buffer. 53 | ;; 54 | ;; (module foo 55 | ;; {require {nvim aniseed.nvim}} 56 | ;; {:some-optional-base :table-of-things 57 | ;; :to-base :the-module-off-of}) 58 | ;; 59 | ;; (module foo) ;; expands foo into your current context 60 | (fn module [mod-name mod-fns mod-base] 61 | (let [;; So we can check for existing values and know if we're in an interactive eval. 62 | ;; If the module doesn't exist we're compiling and can skip interactive tooling. 63 | existing-mod (. package.loaded (tostring mod-name)) 64 | 65 | ;; Determine if we're in an interactive eval or not. 66 | 67 | ;; We don't count userdata / other types as an existing module since we 68 | ;; can't really work with anything other than a table. If it's not a 69 | ;; table it's probably not a module Aniseed can work with in general 70 | ;; since it's assumed all Aniseed modules are table based. 71 | 72 | ;; We can also completely disable the interactive mode which is used by 73 | ;; `aniseed.env` but can also be enabled by others. Sadly this works 74 | ;; through global variables but still! 75 | interactive? (and (= :table (type existing-mod)) 76 | (not _G.ANISEED_STATIC_MODULES)) 77 | 78 | ;; The final result table that gets returned from the macro. 79 | ;; This is the best way I've found to introduce many (local ...) forms from one macro. 80 | result `[,delete-marker 81 | 82 | ;; We can't refer to things like (local (foo bar) (10 foo)). 83 | ;; So we need to define them in an earlier local. 84 | (local ,mod-name-sym ,(tostring mod-name)) 85 | 86 | ;; Only expose the module table if it doesn't exist yet. 87 | (local ,mod-sym ,(if interactive? 88 | `(. package.loaded ,mod-name-sym) 89 | `(do 90 | (tset package.loaded ,mod-name-sym ,(or mod-base {})) 91 | (. package.loaded ,mod-name-sym)))) 92 | 93 | ;; As we def values we insert them into locals. 94 | ;; This table is then expanded in subsequent interactive evals. 95 | (local ,mod-locals-sym ,(if interactive? 96 | `(. ,mod-sym ,locals-key) 97 | `(do 98 | (tset ,mod-sym ,locals-key {}) 99 | (. ,mod-sym ,locals-key))))] 100 | 101 | ;; Bindings that are returned from the macro. 102 | ;; (=> :some-symbol :some-value) 103 | keys [] 104 | vals [] 105 | => (fn [k v] 106 | (table.insert keys k) 107 | (table.insert vals v))] 108 | 109 | ;; For each function / value pair... 110 | (when mod-fns 111 | (sorted-each 112 | (fn [mod-fn args] 113 | (if (seq? args) 114 | ;; If it's sequential, we execute the fn for side effects. 115 | (each [_ arg (ipairs args)] 116 | (=> (sym :_) `(,mod-fn ,(tostring arg)))) 117 | 118 | ;; Otherwise we need to bind the execution to a name. 119 | (sorted-each 120 | (fn [bind arg] 121 | (=> bind `(,mod-fn ,(tostring arg)))) 122 | args))) 123 | mod-fns) 124 | 125 | ;; Only require autoload if it's used. 126 | (when (contains? mod-fns autoload-sym) 127 | (table.insert result `(local ,autoload-sym (. (require "nvim-local-fennel.aniseed.autoload") :autoload))))) 128 | 129 | ;; When we have some keys insert the key/vals pairs locals. 130 | ;; If this is empty we end up generating invalid Lua. 131 | (when (seq? keys) 132 | (table.insert result `(local ,(list (unpack keys)) (values ,(unpack vals)))) 133 | 134 | ;; We also bind these exposed locals into *module-locals* for future splatting. 135 | (each [_ k (ipairs keys)] 136 | (table.insert result `(tset ,mod-locals-sym ,(tostring k) ,k)))) 137 | 138 | ;; Now we can expand any existing locals into the current scope. 139 | ;; Since this will only happen in interactive evals we can generate messy code. 140 | (when interactive? 141 | ;; Expand exported values into the current scope, except aniseed/locals. 142 | (sorted-each 143 | (fn [k v] 144 | (when (not= k locals-key) 145 | (table.insert result `(local ,(sym k) (. ,mod-sym ,k))))) 146 | existing-mod) 147 | 148 | ;; Expand locals into the current scope. 149 | (when (. existing-mod locals-key) 150 | (sorted-each 151 | (fn [k v] 152 | (table.insert result `(local ,(sym k) (. ,mod-locals-sym ,k)))) 153 | (. existing-mod locals-key)))) 154 | 155 | result)) 156 | 157 | (fn def- [name value] 158 | `[,delete-marker 159 | (local ,name ,value) 160 | (tset ,mod-locals-sym ,(tostring name) ,name)]) 161 | 162 | (fn def [name value] 163 | `[,delete-marker 164 | (local ,name ,value) 165 | (tset ,mod-sym ,(tostring name) ,name)]) 166 | 167 | (fn defn- [name ...] 168 | `[,delete-marker 169 | (fn ,name ,...) 170 | (tset ,mod-locals-sym ,(tostring name) ,name)]) 171 | 172 | (fn defn [name ...] 173 | `[,delete-marker 174 | (fn ,name ,...) 175 | (tset ,mod-sym ,(tostring name) ,name)]) 176 | 177 | (fn defonce- [name value] 178 | `(def- ,name (or (. ,mod-sym ,(tostring name)) ,value))) 179 | 180 | (fn defonce [name value] 181 | `(def ,name (or (. ,mod-sym ,(tostring name)) ,value))) 182 | 183 | (fn deftest [name ...] 184 | `(let [tests# (or (. ,mod-sym :aniseed/tests 185 | ) {})] 186 | (tset tests# ,(tostring name) (fn [,(sym :t)] ,...)) 187 | (tset ,mod-sym :aniseed/tests tests#))) 188 | 189 | (fn time [...] 190 | `(let [start# (vim.loop.hrtime) 191 | result# (do ,...) 192 | end# (vim.loop.hrtime)] 193 | (print (.. "Elapsed time: " (/ (- end# start#) 1000000) " msecs")) 194 | result#)) 195 | 196 | ;; Checks surrounding scope for *module* and, if found, makes sure *module* is 197 | ;; inserted after `last-expr` (and therefore *module* is returned) 198 | (fn wrap-last-expr [last-expr] 199 | (if (in-scope? mod-sym) 200 | `(do ,last-expr ,mod-sym) 201 | last-expr)) 202 | 203 | ;; Used by aniseed.compile to wrap the entire body of a file, replacing the 204 | ;; last expression with another wrapper; `wrap-last-expr` which handles the 205 | ;; module's return value. 206 | ;; 207 | ;; i.e. 208 | ;; (wrap-module-body 209 | ;; (module foo) 210 | ;; (def x 1) 211 | ;; (vim.cmd "...")) ; vim.cmd returns a string which becomes the returned value 212 | ;; ; for the entire file once compiled 213 | ;; --> expands to: 214 | ;; (do 215 | ;; (module foo) 216 | ;; (def x 1) 217 | ;; (wrap-last-expr (vim.cmd "..."))) 218 | ;; --> expands to: 219 | ;; (do 220 | ;; (module foo) 221 | ;; (def x 1) 222 | ;; (do 223 | ;; (vim.cmd "...") 224 | ;; *module*)) 225 | (fn wrap-module-body [...] 226 | (let [body# [...] 227 | last-expr# (table.remove body#)] 228 | (table.insert body# `(wrap-last-expr ,last-expr#)) 229 | `(do ,(unpack body#)))) 230 | 231 | {:module module 232 | :def- def- :def def 233 | :defn- defn- :defn defn 234 | :defonce- defonce- :defonce defonce 235 | :wrap-last-expr wrap-last-expr 236 | :wrap-module-body wrap-module-body 237 | :deftest deftest 238 | :time time} 239 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/nvim.lua: -------------------------------------------------------------------------------- 1 | local _2afile_2a = "fnl/aniseed/nvim.fnl" 2 | local _2amodule_name_2a = "nvim-local-fennel.aniseed.nvim" 3 | local _2amodule_2a 4 | do 5 | package.loaded[_2amodule_name_2a] = require("nvim-local-fennel.aniseed.deps.nvim") 6 | _2amodule_2a = package.loaded[_2amodule_name_2a] 7 | end 8 | local _2amodule_locals_2a 9 | do 10 | _2amodule_2a["aniseed/locals"] = {} 11 | _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] 12 | end 13 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/nvim/util.lua: -------------------------------------------------------------------------------- 1 | local _2afile_2a = "fnl/aniseed/nvim/util.fnl" 2 | local _2amodule_name_2a = "nvim-local-fennel.aniseed.nvim.util" 3 | local _2amodule_2a 4 | do 5 | package.loaded[_2amodule_name_2a] = {} 6 | _2amodule_2a = package.loaded[_2amodule_name_2a] 7 | end 8 | local _2amodule_locals_2a 9 | do 10 | _2amodule_2a["aniseed/locals"] = {} 11 | _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] 12 | end 13 | local autoload = (require("nvim-local-fennel.aniseed.autoload")).autoload 14 | local nvim = autoload("nvim-local-fennel.aniseed.nvim") 15 | do end (_2amodule_locals_2a)["nvim"] = nvim 16 | local function normal(keys) 17 | return nvim.ex.silent(("exe \"normal! " .. keys .. "\"")) 18 | end 19 | _2amodule_2a["normal"] = normal 20 | local function fn_bridge(viml_name, mod, lua_name, opts) 21 | local _let_1_ = (opts or {}) 22 | local range = _let_1_["range"] 23 | local _return = _let_1_["return"] 24 | local function _2_() 25 | if range then 26 | return " range" 27 | else 28 | return "" 29 | end 30 | end 31 | local function _3_() 32 | if (_return ~= false) then 33 | return "return" 34 | else 35 | return "call" 36 | end 37 | end 38 | local function _4_() 39 | if range then 40 | return "\" . a:firstline . \", \" . a:lastline . \", " 41 | else 42 | return "" 43 | end 44 | end 45 | return nvim.ex.function_((viml_name .. "(...)" .. _2_() .. "\n " .. _3_() .. " luaeval(\"require('" .. mod .. "')['" .. lua_name .. "'](" .. _4_() .. "unpack(_A))\", a:000)\n endfunction")) 46 | end 47 | _2amodule_2a["fn-bridge"] = fn_bridge 48 | local function with_out_str(f) 49 | nvim.ex.redir("=> g:aniseed_nvim_util_out_str") 50 | do 51 | local ok_3f, err = pcall(f) 52 | nvim.ex.redir("END") 53 | nvim.ex.echon("") 54 | nvim.ex.redraw() 55 | if not ok_3f then 56 | error(err) 57 | else 58 | end 59 | end 60 | return string.gsub(nvim.g.aniseed_nvim_util_out_str, "^(\n?)(.*)$", "%2%1") 61 | end 62 | _2amodule_2a["with-out-str"] = with_out_str 63 | return _2amodule_2a 64 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/setup.lua: -------------------------------------------------------------------------------- 1 | local _2afile_2a = "fnl/aniseed/setup.fnl" 2 | local _2amodule_name_2a = "nvim-local-fennel.aniseed.setup" 3 | local _2amodule_2a 4 | do 5 | package.loaded[_2amodule_name_2a] = {} 6 | _2amodule_2a = package.loaded[_2amodule_name_2a] 7 | end 8 | local _2amodule_locals_2a 9 | do 10 | _2amodule_2a["aniseed/locals"] = {} 11 | _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] 12 | end 13 | local autoload = (require("nvim-local-fennel.aniseed.autoload")).autoload 14 | local a, env, eval, nvim = autoload("nvim-local-fennel.aniseed.core"), autoload("nvim-local-fennel.aniseed.env"), autoload("nvim-local-fennel.aniseed.eval"), autoload("nvim-local-fennel.aniseed.nvim") 15 | do end (_2amodule_locals_2a)["a"] = a 16 | _2amodule_locals_2a["env"] = env 17 | _2amodule_locals_2a["eval"] = eval 18 | _2amodule_locals_2a["nvim"] = nvim 19 | local function init() 20 | if (1 == nvim.fn.has("nvim-0.7")) then 21 | local function _1_(cmd) 22 | local ok_3f, res = eval.str(cmd.args, {}) 23 | if ok_3f then 24 | return nvim.echo(res) 25 | else 26 | return nvim.err_writeln(res) 27 | end 28 | end 29 | nvim.create_user_command("AniseedEval", _1_, {nargs = 1}) 30 | local function _3_(cmd) 31 | local code 32 | local function _4_() 33 | if ("" == cmd.args) then 34 | return nvim.buf_get_name(nvim.get_current_buf()) 35 | else 36 | return cmd.args 37 | end 38 | end 39 | code = a.slurp(_4_()) 40 | if code then 41 | local ok_3f, res = eval.str(code, {}) 42 | if ok_3f then 43 | return nvim.echo(res) 44 | else 45 | return nvim.err_writeln(res) 46 | end 47 | else 48 | return nvim.err_writeln(("File '" .. (cmd.args or "nil") .. "' not found")) 49 | end 50 | end 51 | nvim.create_user_command("AniseedEvalFile", _3_, {nargs = "?", complete = "file"}) 52 | else 53 | end 54 | if nvim.g["aniseed#env"] then 55 | return env.init(nvim.g["aniseed#env"]) 56 | else 57 | return nil 58 | end 59 | end 60 | _2amodule_2a["init"] = init 61 | return _2amodule_2a 62 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/string.lua: -------------------------------------------------------------------------------- 1 | local _2afile_2a = "fnl/aniseed/string.fnl" 2 | local _2amodule_name_2a = "nvim-local-fennel.aniseed.string" 3 | local _2amodule_2a 4 | do 5 | package.loaded[_2amodule_name_2a] = {} 6 | _2amodule_2a = package.loaded[_2amodule_name_2a] 7 | end 8 | local _2amodule_locals_2a 9 | do 10 | _2amodule_2a["aniseed/locals"] = {} 11 | _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] 12 | end 13 | local autoload = (require("nvim-local-fennel.aniseed.autoload")).autoload 14 | local a = autoload("nvim-local-fennel.aniseed.core") 15 | do end (_2amodule_locals_2a)["a"] = a 16 | local function join(...) 17 | local args = {...} 18 | local function _2_(...) 19 | if (2 == a.count(args)) then 20 | return args 21 | else 22 | return {"", a.first(args)} 23 | end 24 | end 25 | local _let_1_ = _2_(...) 26 | local sep = _let_1_[1] 27 | local xs = _let_1_[2] 28 | local len = a.count(xs) 29 | local result = {} 30 | if (len > 0) then 31 | for i = 1, len do 32 | local x = xs[i] 33 | local _3_ 34 | if ("string" == type(x)) then 35 | _3_ = x 36 | elseif (nil == x) then 37 | _3_ = x 38 | else 39 | _3_ = a["pr-str"](x) 40 | end 41 | if (_3_ ~= nil) then 42 | table.insert(result, _3_) 43 | else 44 | end 45 | end 46 | else 47 | end 48 | return table.concat(result, sep) 49 | end 50 | _2amodule_2a["join"] = join 51 | local function split(s, pat) 52 | local done_3f = false 53 | local acc = {} 54 | local index = 1 55 | while not done_3f do 56 | local start, _end = string.find(s, pat, index) 57 | if ("nil" == type(start)) then 58 | table.insert(acc, string.sub(s, index)) 59 | done_3f = true 60 | else 61 | table.insert(acc, string.sub(s, index, (start - 1))) 62 | index = (_end + 1) 63 | end 64 | end 65 | return acc 66 | end 67 | _2amodule_2a["split"] = split 68 | local function blank_3f(s) 69 | return (a["empty?"](s) or not string.find(s, "[^%s]")) 70 | end 71 | _2amodule_2a["blank?"] = blank_3f 72 | local function triml(s) 73 | return string.gsub(s, "^%s*(.-)", "%1") 74 | end 75 | _2amodule_2a["triml"] = triml 76 | local function trimr(s) 77 | return string.gsub(s, "(.-)%s*$", "%1") 78 | end 79 | _2amodule_2a["trimr"] = trimr 80 | local function trim(s) 81 | return string.gsub(s, "^%s*(.-)%s*$", "%1") 82 | end 83 | _2amodule_2a["trim"] = trim 84 | return _2amodule_2a 85 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/test.lua: -------------------------------------------------------------------------------- 1 | local _2afile_2a = "fnl/aniseed/test.fnl" 2 | local _2amodule_name_2a = "nvim-local-fennel.aniseed.test" 3 | local _2amodule_2a 4 | do 5 | package.loaded[_2amodule_name_2a] = {} 6 | _2amodule_2a = package.loaded[_2amodule_name_2a] 7 | end 8 | local _2amodule_locals_2a 9 | do 10 | _2amodule_2a["aniseed/locals"] = {} 11 | _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] 12 | end 13 | local autoload = (require("nvim-local-fennel.aniseed.autoload")).autoload 14 | local a, fs, nvim, str = autoload("nvim-local-fennel.aniseed.core"), autoload("nvim-local-fennel.aniseed.fs"), autoload("nvim-local-fennel.aniseed.nvim"), autoload("nvim-local-fennel.aniseed.string") 15 | do end (_2amodule_locals_2a)["a"] = a 16 | _2amodule_locals_2a["fs"] = fs 17 | _2amodule_locals_2a["nvim"] = nvim 18 | _2amodule_locals_2a["str"] = str 19 | local function ok_3f(_1_) 20 | local _arg_2_ = _1_ 21 | local tests = _arg_2_["tests"] 22 | local tests_passed = _arg_2_["tests-passed"] 23 | return (tests == tests_passed) 24 | end 25 | _2amodule_2a["ok?"] = ok_3f 26 | local function display_results(results, prefix) 27 | do 28 | local _let_3_ = results 29 | local tests = _let_3_["tests"] 30 | local tests_passed = _let_3_["tests-passed"] 31 | local assertions = _let_3_["assertions"] 32 | local assertions_passed = _let_3_["assertions-passed"] 33 | local function _4_() 34 | if ok_3f(results) then 35 | return "OK" 36 | else 37 | return "FAILED" 38 | end 39 | end 40 | a.println((prefix .. " " .. _4_() .. " " .. tests_passed .. "/" .. tests .. " tests and " .. assertions_passed .. "/" .. assertions .. " assertions passed")) 41 | end 42 | return results 43 | end 44 | _2amodule_2a["display-results"] = display_results 45 | local function run(mod_name) 46 | local mod = _G.package.loaded[mod_name] 47 | local tests = (a["table?"](mod) and mod["aniseed/tests"]) 48 | if a["table?"](tests) then 49 | local results = {tests = #tests, ["tests-passed"] = 0, assertions = 0, ["assertions-passed"] = 0} 50 | for label, f in pairs(tests) do 51 | local test_failed = false 52 | a.update(results, "tests", a.inc) 53 | do 54 | local prefix = ("[" .. mod_name .. "/" .. label .. "]") 55 | local fail 56 | local function _5_(desc, ...) 57 | test_failed = true 58 | local function _6_(...) 59 | if desc then 60 | return (" (" .. desc .. ")") 61 | else 62 | return "" 63 | end 64 | end 65 | return a.println((str.join({prefix, " ", ...}) .. _6_(...))) 66 | end 67 | fail = _5_ 68 | local begin 69 | local function _7_() 70 | return a.update(results, "assertions", a.inc) 71 | end 72 | begin = _7_ 73 | local pass 74 | local function _8_() 75 | return a.update(results, "assertions-passed", a.inc) 76 | end 77 | pass = _8_ 78 | local t 79 | local function _9_(e, r, desc) 80 | begin() 81 | if (e == r) then 82 | return pass() 83 | else 84 | return fail(desc, "Expected '", a["pr-str"](e), "' but received '", a["pr-str"](r), "'") 85 | end 86 | end 87 | local function _11_(e, r, desc) 88 | begin() 89 | local se = a["pr-str"](e) 90 | local sr = a["pr-str"](r) 91 | if (se == sr) then 92 | return pass() 93 | else 94 | return fail(desc, "Expected (with pr) '", se, "' but received '", sr, "'") 95 | end 96 | end 97 | local function _13_(r, desc) 98 | begin() 99 | if r then 100 | return pass() 101 | else 102 | return fail(desc, "Expected truthy result but received '", a["pr-str"](r), "'") 103 | end 104 | end 105 | t = {["="] = _9_, ["pr="] = _11_, ["ok?"] = _13_} 106 | local _15_, _16_ = nil, nil 107 | local function _17_() 108 | return f(t) 109 | end 110 | _15_, _16_ = pcall(_17_) 111 | if ((_15_ == false) and (nil ~= _16_)) then 112 | local err = _16_ 113 | fail("Exception: ", err) 114 | else 115 | end 116 | end 117 | if not test_failed then 118 | a.update(results, "tests-passed", a.inc) 119 | else 120 | end 121 | end 122 | return display_results(results, ("[" .. mod_name .. "]")) 123 | else 124 | return nil 125 | end 126 | end 127 | _2amodule_2a["run"] = run 128 | local function run_all() 129 | local function _21_(totals, results) 130 | for k, v in pairs(results) do 131 | totals[k] = (v + totals[k]) 132 | end 133 | return totals 134 | end 135 | return display_results(a.reduce(_21_, {tests = 0, ["tests-passed"] = 0, assertions = 0, ["assertions-passed"] = 0}, a.filter(a["table?"], a.map(run, a.keys(_G.package.loaded)))), "[total]") 136 | end 137 | _2amodule_2a["run-all"] = run_all 138 | local function suite() 139 | do 140 | local sep = fs["path-sep"] 141 | local function _22_(path) 142 | return require(string.gsub(string.match(path, ("^test" .. sep .. "fnl" .. sep .. "(.-).fnl$")), sep, ".")) 143 | end 144 | a["run!"](_22_, nvim.fn.globpath(("test" .. sep .. "fnl"), "**/*-test.fnl", false, true)) 145 | end 146 | if ok_3f(run_all()) then 147 | return nvim.ex.q() 148 | else 149 | return nvim.ex.cq() 150 | end 151 | end 152 | _2amodule_2a["suite"] = suite 153 | return _2amodule_2a 154 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/aniseed/view.lua: -------------------------------------------------------------------------------- 1 | local _2afile_2a = "fnl/aniseed/view.fnl" 2 | local _2amodule_name_2a = "nvim-local-fennel.aniseed.view" 3 | local _2amodule_2a 4 | do 5 | package.loaded[_2amodule_name_2a] = {} 6 | _2amodule_2a = package.loaded[_2amodule_name_2a] 7 | end 8 | local _2amodule_locals_2a 9 | do 10 | _2amodule_2a["aniseed/locals"] = {} 11 | _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] 12 | end 13 | local fnl = require("nvim-local-fennel.aniseed.fennel") 14 | do end (_2amodule_locals_2a)["fnl"] = fnl 15 | local function serialise(...) 16 | return fnl.impl().view(...) 17 | end 18 | _2amodule_2a["serialise"] = serialise 19 | return _2amodule_2a 20 | -------------------------------------------------------------------------------- /lua/nvim-local-fennel/init.lua: -------------------------------------------------------------------------------- 1 | local _2afile_2a = "fnl/nvim-local-fennel/init.fnl" 2 | local _2amodule_name_2a = "nvim-local-fennel.init" 3 | local _2amodule_2a 4 | do 5 | package.loaded[_2amodule_name_2a] = {} 6 | _2amodule_2a = package.loaded[_2amodule_name_2a] 7 | end 8 | local _2amodule_locals_2a 9 | do 10 | _2amodule_2a["aniseed/locals"] = {} 11 | _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"] 12 | end 13 | local autoload = (require("nvim-local-fennel.aniseed.autoload")).autoload 14 | local a, compile, nvim = autoload("nvim-local-fennel.aniseed.core"), autoload("nvim-local-fennel.aniseed.compile"), autoload("nvim-local-fennel.aniseed.nvim") 15 | do end (_2amodule_locals_2a)["a"] = a 16 | _2amodule_locals_2a["compile"] = compile 17 | _2amodule_locals_2a["nvim"] = nvim 18 | local function cwd() 19 | return nvim.fn.getcwd() 20 | end 21 | _2amodule_locals_2a["cwd"] = cwd 22 | local function parent(dir) 23 | local candidate = nvim.fn.fnamemodify(dir, ":h") 24 | if ((dir ~= candidate) and nvim.fn.isdirectory(candidate)) then 25 | return candidate 26 | else 27 | return nil 28 | end 29 | end 30 | _2amodule_locals_2a["parent"] = parent 31 | local function parents(dir) 32 | local result = {} 33 | local dir0 = parent(dir) 34 | while dir0 do 35 | table.insert(result, 1, dir0) 36 | dir0 = parent(dir0) 37 | end 38 | return result 39 | end 40 | _2amodule_locals_2a["parents"] = parents 41 | local function file_readable_3f(path) 42 | return (1 == nvim.fn.filereadable(path)) 43 | end 44 | _2amodule_locals_2a["file-readable?"] = file_readable_3f 45 | local function file_newer_3f(a0, b) 46 | return (nvim.fn.getftime(a0) > nvim.fn.getftime(b)) 47 | end 48 | _2amodule_locals_2a["file-newer?"] = file_newer_3f 49 | do 50 | local cwd0 = cwd() 51 | local dirs = parents(cwd0) 52 | table.insert(dirs, cwd0) 53 | local function _2_(dir) 54 | local src = (dir .. "/.lnvim.fnl") 55 | local dest = (dir .. "/.lnvim.lua") 56 | if file_readable_3f(src) then 57 | if file_newer_3f(src, dest) then 58 | compile.file(src, dest) 59 | else 60 | end 61 | return nvim.ex.luafile(dest) 62 | else 63 | if file_readable_3f(dest) then 64 | return nvim.fn.delete(dest) 65 | else 66 | return nil 67 | end 68 | end 69 | end 70 | a["run!"](_2_, dirs) 71 | end 72 | return _2amodule_2a -------------------------------------------------------------------------------- /plugin/nvim-local-fennel.vim: -------------------------------------------------------------------------------- 1 | lua require("nvim-local-fennel") 2 | -------------------------------------------------------------------------------- /scripts/dep.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Clones a GitHub repo into deps/{name} if it's not there already. 4 | # Will update the repository each time and ensure the right commit is checked out. 5 | # Args: GitHub user, repository name, checkout target. 6 | # Usage (after copying to your scripts directory): scripts/dep.sh Olical aniseed vX.Y.Z 7 | 8 | mkdir -p deps 9 | 10 | if [ ! -d "deps/$2" ]; then 11 | git clone "https://github.com/$1/$2.git" "deps/$2" 12 | fi 13 | 14 | cd "deps/$2" && git fetch && git checkout "$3" 15 | 16 | --------------------------------------------------------------------------------