Giter Site home page Giter Site logo

olical / aniseed Goto Github PK

View Code? Open in Web Editor NEW
598.0 5.0 28.0 1.15 MB

Neovim configuration and plugins in Fennel (Lisp compiled to Lua)

Home Page: https://conjure.fun/discord

License: The Unlicense

Makefile 0.98% Shell 3.21% Dockerfile 0.21% Lua 40.82% Fennel 41.14% Vim Script 13.64%
neovim lisp fennel lua

aniseed's Introduction

Aniseed Discord

Aniseed bridges the gap between Fennel (a Lisp that compiles to Lua) and Neovim. Allowing you to easily write plugins or configuration in a Clojure-like Lisp with great runtime performance.

Note: You may be interested in my new project that attempts to be a successor to Aniseed, nfnl.

It does away with a bunch of decisions I regretted and builds upon the parts I really liked. I think you might like it too!

Future development efforts will center around nfnl instead of Aniseed and things like Conjure will almost certainly transition over to being based on it instead over time.

asciicast

Further documentation can be found in :help aniseed. There you can learn about the scripts, macros, functions and use cases of Aniseed.

Installation

For interactive evaluation you need to install Conjure as well. It’ll allow you to send portions of your code off for evaluation as well as see the results in an interactive log buffer. You may also use the, far more minimal, :AniseedEval {code} and :AniseedEvalFile {path} commands to execute Fennel if you require.

You may be interested in nvim-local-fennel which is essentially a Fennel based version of localvimrc.

Alternatively you can use Magic Kit, an opinionated starter kit that includes all sorts of essential tools.

use 'Olical/aniseed'
Plug 'Olical/aniseed'

Module macros

Aniseed ships with a set of module macros that make interactive evaluation not only possible, but rich and intuitive. You should read :h aniseed to learn the details but it’s worth mentioning that you opt in by starting your file with a (module …​) block, you then export values from your module with the (def…​) macros.

Once you opt in your module will no longer operate like a regular Fennel module in the sense that you can’t just return a table from the bottom of your file to export it like so.

(local somemod {})
(set somemod.foo 25)
somemod

In vanilla Fennel, this will build and return a table from your module. If you use Aniseed’s macro system your file must look like this instead.

(module somemod)
(def foo 25)

Loading Fennel Neovim configuration

Aniseed has a module called aniseed.env which will automatically compile and load Fennel code from your Neovim configuration directory as if it were natively supported by the editor, like Lua and VimL.

See Olical/dotfiles for a detailed example configuration. To enable this same automatic loading of your Fennel configuration you need to install Aniseed and add the following option. This is documented further within :help aniseed.

let g:aniseed#env = v:true

Now the following code in ~/.config/nvim/fnl/init.fnl will be compiled and executed when you open Neovim.

;; The name is up to you.
(module nvim-config
  {;; You can use Lua's regular require or Aniseed's autoload.
   require {xyz some.cool.tool.xyz

            ;; Fennel destructuring syntax works but defeats the point of autoload.
            ;; Because a lookup is instantly invoked which triggers autoload at
            ;; module load time instead of when you need it in your code.
            {: some-fn} some-module}

   ;; Autoload lazily loads the module when you try to use the module methods or values at runtime.
   autoload {a aniseed.core

             ;; Shorthand syntax for requiring under the same name.
             : packer}})

(a.println "Hello, World!")

Setting up a plugin project

scripts/seed.sh is provided to make it a little easier to get a plugin up and running. In a new directory (because it will overwrite your .gitignore and Makefile etc) run the following command.

It will name the plugin after the directory you’re currently running it from. Make sure the directory name doesn’t include any spaces or special characters because it will be inserted at some points in the seed code for you.

curl -fL https://raw.githubusercontent.com/Olical/aniseed/master/scripts/seed.sh | sh

This will create some example Fennel source and tests as well as a Makefile to help you compile and run it all. This should be enough to get you started without being overly opinionated.

Unlicenced

The following files are excluded from my license and ownership:

  • lua/aniseed/deps/fennel.lua

  • lua/aniseed/deps/nvim.lua

These files come from Fennel and nvim.lua, I did not write them, all other files are from me and unlicenced. The aforementioned files should be considered under their respective project licences. They are copied into this repo to allow the plugin to work with systems that don’t support symlinks correctly.

Find the full unlicense in the UNLICENSE file, but here’s a snippet.

This is free and unencumbered software released into the public domain.

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.

aniseed's People

Contributors

alloy-d avatar berkeleytrue avatar d00mch avatar davidwilemski avatar gwerbin avatar harrygallagher4 avatar mhanberg avatar monkoose avatar noahtheduke avatar olical avatar semperos avatar sotte avatar tami5 avatar tssm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aniseed's Issues

[Bug] Aniseed compile potentially conflicts with `impatient.nvim`

Using impatient.nvim give me significant startup improvement, however this also give me a weird and/or unknow bug as shown in the following

Screen_Recording_2021-09-25_at_3.12.28_pm.mov

Actual behavior: a same file was loaded 4 times

Expected behavior: file is loaded normally

The config which caused the issue

;; core/macros.fnl
(fn fn? [obj]
  "Returns true if the object is a function
  This only works at compilation time"
  (and (list? obj) (or (= (->str (first obj)) :hashfn)
                       (= (->str (first obj)) :fn))))

(fn pug [val prefix?]
  (let [inter-compile-uid (_G.os.date "%s")
        name (if prefix?
                  (.. (->str (gensym prefix?)) inter-compile-uid)
                  (.. (->str (gensym :pug)) inter-compile-uid))]
  `(do
     (tset _G ,name ,val)
     ,name)))

(fn vlua [what prefix?]
  `(.. "v:lua." ,(pug what prefix?) "()"))

(fn command! [name expr]
  (let [name (->str name)]
     (if (fn? expr)
       `(vim.cmd (string.format "command! %s call %s" ,name ,(vlua expr)))
       `(vim.cmd (string.format "command! %s %s" ,name ,expr)))))

;; lsp/init.fnl
(import-macros {: nmap! : noremap! : buf-noremap!
                : augroup! : buf-augroup! : autocmd! : buf-autocmd!
                : command! : buf-command! : lua-buf-command!
                : pug : vlua} :core.macros)
(fn reload-lsp []
  (lsp.stop_client (vim.lsp.get_active_clients))
  (vim.cmd :edit))

(fn open-lsp-log []
  (let [path (vim.lsp.get_log_path)]
    (vim.cmd (.. "edit " path))))

(command! :LspLog #(open-lsp-log))
(command! :LspRestart #(reload-lsp))

Remove impatient.nvim plugin, the configuration works as normal

Quote from Aniseed creator:

... that sounds like that's going to introduce a bunch of breaking changes for aniseed since I was in charge of loading your lua before 😦
If that's doing some -> bytecode stuff and loading it automatically weird things might start happening (like what you're seeing) but I'm not sure yet ...

How to access stuff in nvim aside from aniseed.nvim

Hay, I'm trying to configure lsp using nvim-lsp . So after a while I managed to know how to import a plugin I installed with

(module dotfiles.module.lsp 
  {require 
   {nvim aniseed.nvim 
    nvim_lsp "nvim_lsp"
    }})

Now, I'm trying to access vim.lsp.get_log_path().

Thanks,

Don't know how to access environment variable from within fennel/aniseed

I basically need to use a environment variable on object to set an global variable for a plugin that I use a lot: https://github.com/romgrk/todoist.nvim

Basically what I'm doing (and is working greatly) is insert the api key inside code, but with this I can't publish to GitHub and etc...

(module dotfiles.module.plugin.todoist
  {require { nvim aniseed.nvim }})

(set nvim.g.todoist { "key" "api-key" })

Can you help me with that? Thank you so much for you great work with conjure and aniseed, I'm literally addicted to this setup right now.

Assess forking, maintaining and incorporating luafun

So luafun looks very unmaintained but REALLY cool. I'd love to slowly replace aniseed.core with it, maybe shim to it for the time being while also providing aniseed.fun as another optional module you can require...

I think it'll be a GREAT building block to ship with Aniseed, I'd love to rely on it within Conjure too. My current implementations in aniseed.core are pretty inefficient, but I haven't had to worry, I've never hit any performance issues. Now I'm thinking this could help remove any issues before they even pop up.

Exciting! I could also use a maintained fork for other things at work too, so it could help me in my day to day work.

Would probably want to convert it to Fennel too 🤔 but probably still a separate repo?

Error in syntax highlighting

Hey, trying out using a init.fnl file. Running in to syntax highlighting not working. If I run :e! I get

Error detected while processing /home/<home>/.config/nvim/plugged/aniseed/syntax/fennel.vim:
line  258:
E945: Range too large in character class
E475: Invalid argument: FennelSymbol "\v<%([\!\$%\&\#\*\+\-./:<=>?A-Z^_a-z|\x80-\U10FFFF])%([0-9\!\$%\&\#\*\+\-./:<=>?A-Z^_a-z|\x80
-\U10FFFF])*>"
line  259:
E945: Range too large in character class
E475: Invalid argument: FennelKeyword "\v<:%([0-9\!\$%\&\#\*\+\-./:<=>?A-Z^_a-z|\x80-\U10FFFF])*>"

and then the syntax highlighting works.

aniseedbug1

I thought the error might be in https://github.com/bakpakin/fennel.vim, but it says its in ../plugged/aniseed/syntax/fennel.vim

Checkhealth


health#nvim_treesitter#check
========================================================================
## Installation
  - WARNING: `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
  - OK: `node` found v12.18.0 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
  - OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

## Parser/Features H L F I
  - ocaml_interface✓ ✓ ✓ . 
  - cpp            ✓ ✓ ✓ ✓ 
  - regex          ✓ . . . 
  - sparql         ✓ ✓ ✓ ✓ 
  - rust           ✓ ✓ ✓ ✓ 
  - lua            ✓ ✓ ✓ ✓ 
  - typescript     ✓ ✓ ✓ ✓ 
  - python         ✓ ✓ ✓ ✓ 
  - tsx            ✓ ✓ ✓ ✓ 
  - css            ✓ . ✓ ✓ 
  - go             ✓ ✓ ✓ ✓ 
  - svelte         ✓ . ✓ ✓ 
  - gomod          ✓ . . . 
  - zig            ✓ ✓ ✓ ✓ 
  - bibtex         ✓ . ✓ ✓ 
  - graphql        ✓ . . ✓ 
  - toml           ✓ ✓ ✓ ✓ 
  - latex          ✓ . ✓ . 
  - ruby           ✓ ✓ ✓ ✓ 
  - beancount      ✓ . ✓ . 
  - r              ✓ ✓ . . 
  - bash           ✓ ✓ ✓ . 
  - c              ✓ ✓ ✓ ✓ 
  - vue            ✓ . ✓ . 
  - turtle         ✓ ✓ ✓ ✓ 
  - php            ✓ ✓ ✓ ✓ 
  - jsonc          ✓ ✓ ✓ ✓ 
  - java           ✓ ✓ . ✓ 
  - query          ✓ ✓ ✓ ✓ 
  - kotlin         ✓ . . . 
  - fennel         ✓ ✓ . . 
  - nix            ✓ ✓ ✓ . 
  - html           ✓ ✓ ✓ ✓ 
  - jsdoc          ✓ . . . 
  - julia          ✓ ✓ . . 
  - comment        ✓ . . . 
  - glimmer        ✓ . . . 
  - json           ✓ ✓ ✓ ✓ 
  - ql             ✓ ✓ . ✓ 
  - javascript     ✓ ✓ ✓ ✓ 
  - teal           ✓ ✓ ✓ ✓ 
  - rst            ✓ ✓ . . 
  - dart           ✓ ✓ . ✓ 
  - yaml           ✓ ✓ ✓ ✓ 
  - verilog        ✓ ✓ ✓ . 
  - ocaml          ✓ ✓ ✓ . 
  - ledger         ✓ . ✓ ✓ 
  - clojure        ✓ ✓ . . 
  - c_sharp        ✓ . . . 

 Legend: H[ighlight], L[ocals], F[olds], I[ndents]
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

health#mkdp#check
========================================================================
  - INFO: Platform: linux
  - INFO: Nvim Version: NVIM v0.5.0-dev+1293-ga0da4c3a4
  - INFO: Pre build: /home/avraham/.config/nvim/plugged/markdown-preview.nvim/app/bin/markdown-preview-linux
  - INFO: Pre build version: 0.0.9
  - OK: Using pre build

health#coc#check
========================================================================
  - OK: Environment check passed

  - OK: Javascript bundle build/index.js found
  - OK: Service started

health#targets#check
========================================================================
  - OK: No conflicting mappings found

health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: RelWithDebInfo
    LuaJIT

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $COLORTERM='truecolor'

## tmux
  - OK: escape-time: 0
  - INFO: Checking stuff
  - OK: focus-events: on
  - INFO: $TERM: xterm-256color
  - INFO: default-terminal: tmux-256color
  - ERROR: $TERM differs from the tmux `default-terminal` setting. Colors might look wrong.
    - ADVICE:
      - $TERM may have been set by some rc (.bashrc, .zshrc, ...).

health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: xclip

## Python 2 provider (optional)
  - INFO: `g:python_host_prog` is not set.  Searching for python2 in the environment.
  - INFO: Executable: /usr/bin/python2
  - INFO: Python version: 2.7.18
  - INFO: pynvim version: 0.4.1 (outdated; from ~/.local/lib/python2.7/site-packages/neovim)
  - WARNING: Latest pynvim is NOT installed: 0.4.3

## Python 3 provider (optional)
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - INFO: Executable: /usr/bin/python3
  - INFO: Python version: 3.8.5
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - INFO: Ruby: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
  - WARNING: `neovim-ruby-host` not found.
    - ADVICE:
      - Run `gem install neovim` to ensure the neovim RubyGem is installed.
      - Run `gem environment` to ensure the gem bin directory is in $PATH.
      - If you are using rvm/rbenv/chruby, try "rehashing".
      - See :help |g:ruby_host_prog| for non-standard gem installations.

## Node.js provider (optional)
  - INFO: Node.js: v12.18.0
  - INFO: Nvim node.js host: /home/avraham/.config/yarn/global//node_modules/neovim/bin/cli.js
  - WARNING: Package "neovim" is out-of-date. Installed: 4.8.0, latest: 4.10.0
    - ADVICE:
      - Run in shell: npm install -g neovim
      - Run in shell (if you use yarn): yarn global add neovim

## Perl provider (optional)
  - ERROR: perl provider error:
    - ADVICE:
      - "Neovim::Ext" cpan module is not installed

health#treesitter#check
========================================================================
## Checking treesitter configuration
  - INFO: Runtime ABI version : 13
  - OK: Loaded parser for bash: ABI version 13
  - OK: Loaded parser for beancount: ABI version 13
  - OK: Loaded parser for bibtex: ABI version 13
  - OK: Loaded parser for c: ABI version 13
  - OK: Loaded parser for c_sharp: ABI version 13
  - OK: Loaded parser for clojure: ABI version 13
  - OK: Loaded parser for comment: ABI version 13
  - OK: Loaded parser for cpp: ABI version 13
  - OK: Loaded parser for css: ABI version 13
  - OK: Loaded parser for dart: ABI version 13
  - ERROR: Impossible to load parser for devicetree: ...s/usr/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /home/avraham/.config/nvim/plugged/nvim-treesitter/parser/devicetree.so: supported between 13 and 13, found 12
  - ERROR: Impossible to load parser for erlang: ...s/usr/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /home/avraham/.config/nvim/plugged/nvim-treesitter/parser/erlang.so: supported between 13 and 13, found 12
  - OK: Loaded parser for fennel: ABI version 13
  - ERROR: Impossible to load parser for gdscript: ...s/usr/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /home/avraham/.config/nvim/plugged/nvim-treesitter/parser/gdscript.so: supported between 13 and 13, found 12
  - OK: Loaded parser for glimmer: ABI version 13
  - OK: Loaded parser for go: ABI version 13
  - OK: Loaded parser for gomod: ABI version 13
  - OK: Loaded parser for graphql: ABI version 13
  - OK: Loaded parser for html: ABI version 13
  - OK: Loaded parser for java: ABI version 13
  - OK: Loaded parser for javascript: ABI version 13
  - OK: Loaded parser for jsdoc: ABI version 13
  - OK: Loaded parser for json: ABI version 13
  - OK: Loaded parser for jsonc: ABI version 13
  - OK: Loaded parser for julia: ABI version 13
  - OK: Loaded parser for kotlin: ABI version 13
  - OK: Loaded parser for latex: ABI version 13
  - OK: Loaded parser for ledger: ABI version 13
  - OK: Loaded parser for lua: ABI version 13
  - OK: Loaded parser for nix: ABI version 13
  - OK: Loaded parser for ocaml: ABI version 13
  - OK: Loaded parser for ocaml_interface: ABI version 13
  - ERROR: Impossible to load parser for ocamllex: ...s/usr/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /home/avraham/.config/nvim/plugged/nvim-treesitter/parser/ocamllex.so: supported between 13 and 13, found 11
  - OK: Loaded parser for php: ABI version 13
  - OK: Loaded parser for python: ABI version 13
  - OK: Loaded parser for ql: ABI version 13
  - OK: Loaded parser for query: ABI version 13
  - OK: Loaded parser for r: ABI version 13
  - OK: Loaded parser for regex: ABI version 13
  - OK: Loaded parser for rst: ABI version 13
  - OK: Loaded parser for ruby: ABI version 13
  - OK: Loaded parser for rust: ABI version 13
  - OK: Loaded parser for sparql: ABI version 13
  - ERROR: Impossible to load parser for supercollider: ...s/usr/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /home/avraham/.config/nvim/plugged/nvim-treesitter/parser/supercollider.so: supported between 13 and 13, found 12
  - OK: Loaded parser for svelte: ABI version 13
  - OK: Loaded parser for teal: ABI version 13
  - OK: Loaded parser for toml: ABI version 13
  - OK: Loaded parser for tsx: ABI version 13
  - OK: Loaded parser for turtle: ABI version 13
  - OK: Loaded parser for typescript: ABI version 13
  - OK: Loaded parser for verilog: ABI version 13
  - OK: Loaded parser for vue: ABI version 13
  - OK: Loaded parser for yaml: ABI version 13
  - OK: Loaded parser for zig: ABI version 13
  - OK: Loaded parser for c: ABI version 13

Rewrite module system as a compiler plugin

I don't think compiler plugins were a thing when I first attempted the module system, so I think it's about time I rewrote it. A compiler plugin is far more suitable I think? Should be able to produce MUCH nicer code and actually be able to maintain it. So consider the current module macros EOL and in maintenance mode until I tackle a rewrite.

I don't think it'll change anything for the users other than their compiled Lua should be far simpler and I'll actually be able to work on the module system without losing my hair :D

Requiring a module that cannot be found results in opaque error on windows

I have an aniseed config which works on windows. However when I tried to move to packer.nvim (by reading and emulating the magic-kit system) I started getting opaque errors like this:
image

I came to realize that the errors are due to not a module (in this case foobar). But I was really struggling to understand what was going on because of the Undefined Variable C

I think that this has something to do with windows, but I'm not sure. C seems suspiciously like c:/ drive name. But that really is just a hunch.

THIS IS INCREDIBLE

I just wanted to say this project is amazing. Fantastic work. Carry on

Compiling with macros

This is more of a help request than an issue. I'm using aniseed for a plugin written in fennel. It's for using nvim-treesitter to generate documentation for various languages. I'm using macros (I'm new to them) for the templating language. Anyways, I tried "requireing" or importing the macros, but I don't get any lua output when using the compile script (for the file using the macros). I get an error when trying to evaluate the file locally, saying it couldn't find the macro module.

Here is the branch I'm working with for a more in depth look https://github.com/nvim-treesitter/nvim-tree-docs/tree/rewrite-in-fennel

File using the macros: fnl/nvim-tree-docs/specs/javascript/jsdoc.fnl

(require-macros "nvim-tree-docs.macros")

(doc-spec {:spec "jsdoc" :lang "javascript"})

(fn get-param-name [ctx param]
  (if param.default_value
    (string.format "%s=%s"
                   (ctx.get-text param.name)
                   (ctx.get-text param.default_value))
    (ctx.get-text param.name)))

(template function
  "/**"
  [" *" (%= name) "description"]
  #(when $.export
     " * @export")
  #(each [i param $.parameters]
    [" * @param" #(get-param-name $ param) "{any} - The" (%= name param)])
  #(when $.return_statement
     " * returns {any} The result")
  " */")

(template variable
  "/**"
  " * Description"
  #(when $.export " * @export")
  " * @type {any}"
  " */")

Macro file: fnl/nvim-tree-docs/macros.fnl

(local modsym (gensym))

(fn doc-spec [config module]
  `(local ,modsym {:get-spec #(-> ,(tostring config.spec))})
   (tset (. (require "nvim-tree-docs.template") :loaded-specs)
         (.. config.lang "_" config.spec)
         ,modsym))

(fn template [kind ...]
  `(tset ,modsym ,(tostring kind)
     (fn [context#]
       (local output# [])
       (each [_# line# (ipairs ,[...])]
         (table.insert output# (context#.eval-line line# context#)))
       output#)))

(fn %= [key tbl default]
  `#(let [tbl# (or ,tbl $)]
      (or ($.get-text (. tbl# ,(tostring key)) default)))

(fn %? [key]
  `#(. $1 ,(tostring key)))

{: template
 : %=
 : %?}

Harden the `module` macro

Steps to reproduce bad things:

  • Had a Lua file on disk with bad code in it that won't compile etc under the module path foo.bar.
  • Start or edit a Fennel file with (module foo.bar) inside.
  • Get errors as Aniseed's module macro tries to require the bad module.

You can fix this by deleting the bad Lua and restarting or (tset package.loaded :foo.bar nil) I think? Possibly other things to work around this too. I want to make it so a bad pre-existing module that won't require / throws errors will be caught and ignored. If the existing module is borked, let's just pretend it doesn't exist.

macro requires in module macro

Would it make sense to somehow add macro import support to the module macro? It would be awesome to just add a tag to an import banding or something similar to trigger importing macros at the same time.

Add force option to aniseed.env.init that forces compile

I've had this issue several times now were I'm making changes to macros and I'm trying to re-compile my whole project so I can see the result.

There is a check to see if the last modified timestamp has changed which prevents compilation of files when no changes have happened, which means I either need to blow away the lua file, or add useless comments to change timestamps.

I've got a branch of aniseed that allows me to pass force to compile the code while I'm editing for those cases where REPL won't due. Is this something you'd be ok with in the this project?

i.e.

lua require("aniseed.env").init({ force = true })

Question: How to test local function?

Hello, sorry to disturb without an actual issue. But i don't have a discord account to ask there.

Is there any way to make local functions defined with defn- in some other module available in test module?
Or just how to test local functions?

Improve error messages and handling

This will have two sides, at Conjure eval time as well as pure lua runtime, where we don't have the fennel compiler.

Maybe we can load it on error just to manage stack traces 🤔

On windows, config path contains mixed file separators

Seems like something broke since I last tried to compile my vim config with aniseed.

When I recompiled my config I got:

runtime error: attempt to call local 'load_fn' (a nil value)
stack traceback:
  ...te\pack\packer\start\aniseed\lua\aniseed\deps\fennel.lua:3267: in function 'parse_string'
  ...te\pack\packer\start\aniseed\lua\aniseed\deps\fennel.lua:3346: in function '(for generator)'
  ...te\pack\packer\start\aniseed\lua\aniseed\deps\fennel.lua:2685: in function ?
  [C]: in function 'str'
  ...a\site\pack\packer\start\aniseed\lua\aniseed\compile.lua:101: in function 'file'
  ...a\site\pack\packer\start\aniseed\lua\aniseed\compile.lua:129: in function 'glob'
  ...-data\site\pack\packer\start\aniseed\lua\aniseed\env.lua:92: in function 'init'
  [string "luaeval()"]:1: in main chunk
"C:\Users\keith\AppData\Local\nvim/fnl\module\bindings.fnl"
runtime error: attempt to call local 'load_fn' (a nil value)
stack traceback:
  ...te\pack\packer\start\aniseed\lua\aniseed\deps\fennel.lua:3267: in function 'parse_string'
  ...te\pack\packer\start\aniseed\lua\aniseed\deps\fennel.lua:3346: in function '(for generator)'
  ...te\pack\packer\start\aniseed\lua\aniseed\deps\fennel.lua:2685: in function ?
  [C]: in function 'str'
  ...a\site\pack\packer\start\aniseed\lua\aniseed\compile.lua:101: in function 'file'
  ...a\site\pack\packer\start\aniseed\lua\aniseed\compile.lua:129: in function 'glob'
  ...-data\site\pack\packer\start\aniseed\lua\aniseed\env.lua:92: in function 'init'
  [string "luaeval()"]:1: in main chunk
"C:\Users\keith\AppData\Local\nvim/fnl\module\settings.fnl"
runtime error: attempt to call local 'load_fn' (a nil value)
stack traceback:
  ...te\pack\packer\start\aniseed\lua\aniseed\deps\fennel.lua:3267: in function 'parse_string'
  ...te\pack\packer\start\aniseed\lua\aniseed\deps\fennel.lua:3346: in function '(for generator)'
  ...te\pack\packer\start\aniseed\lua\aniseed\deps\fennel.lua:2685: in function ?
  [C]: in function 'str'
  ...a\site\pack\packer\start\aniseed\lua\aniseed\compile.lua:101: in function 'file'
  ...a\site\pack\packer\start\aniseed\lua\aniseed\compile.lua:129: in function 'glob'
  ...-data\site\pack\packer\start\aniseed\lua\aniseed\env.lua:92: in function 'init'
  [string "luaeval()"]:1: in main chunk
"C:\Users\keith\AppData\Local\nvim/fnl\util.fnl"
runtime error: attempt to call local 'load_fn' (a nil value)
stack traceback:
  ...te\pack\packer\start\aniseed\lua\aniseed\deps\fennel.lua:3267: in function 'parse_string'
  ...te\pack\packer\start\aniseed\lua\aniseed\deps\fennel.lua:3346: in function '(for generator)'
  ...te\pack\packer\start\aniseed\lua\aniseed\deps\fennel.lua:2685: in function ?
  [C]: in function 'str'
  ...a\site\pack\packer\start\aniseed\lua\aniseed\compile.lua:101: in function 'file'
  ...a\site\pack\packer\start\aniseed\lua\aniseed\compile.lua:129: in function 'glob'
  ...-data\site\pack\packer\start\aniseed\lua\aniseed\env.lua:92: in function 'init'
  [string "luaeval()"]:1: in main chunk

So I searched on the fennel repo for similar errors and found: bakpakin/Fennel#357

Which told me that the error I was running into was likely due to a character escape issue. So I looked in the fennel.lua file and added a print line which revealed among other things, this string: "C:\Users\keith\AppData\Local\nvim/fnl\init.fnl"

I believe this comes from the stdpath(config) call. However becomes I'm on windows I'm not able to recompile aniseed (or don't know how) given that they are shell scripts. I think the backslashes need to be converted to forward slashes in env.fnl. Any clues as to how to fork and recompile on windows os I can fix this issue?

Is it possible to get the current module name?

I see that there is an aniseed/module entry in the table created by the module macro. Is this value accessible from inside the module?

For example:

(module foo.bar)

(defn print-module-name []
  "Prints the name of the currently loading module."
  ; Hypothetical variable name: _currentmodule_
  (print _currentmodule_))

In this case, I would expect foo.bar.print-module-name to print foo.bar.

My use case is to facilitate scripting Vim:

(module hello)

(defn hello []
  (vim.api.nvim_echo "Hello!!"))

(defn vimeval [source ...]
  "Kind of like luaeval(). Consider using %q, not %s, for strings."
  (vim.api.nvim-exec (string.format source ...)) true)

(defn setup []
  (vimeval
    "augroup Hello
       autocmd BufNewFile * lua require(%q).hello()
     augroup END"
    _currentmodule_))

Aniseed Neovim configuration statup time

Hey @Olical, finally after 4 days I managed to fully migrate and port my configuration to anissed, and based on our previous implicit agreement, I've measured the startuptime between my to-fnl branch and my main branch. I tried my best to port the same code, but for the most part the logic is identical. All tests are conducted with this command repeat 20 {time nvim -c "quit"}.

Summery

Without anissed on main branch, I got the following average :

# user system total
av 0.091s 0.025s 0.117

With anissed on to-fnl branch, I got the following average:

# user system total
av 0.161s 0.028s 0.192

So it turns out that with aniseed, the average startuptime is 0.16s, a 0.07s increased from my main branch. However, what really got my attention is the inconsistency with the result, the highest startuptime I got is 0.25s while the lowest is 0.12s. I believe that this gap of 0.13s and the inconsistency is the direct result of doing filesystem system checks at startup. To confirm this and to check whether fennel compiler did speed things up (not quite :D) I did another test but this time without initializing anissed (i.e. not requiring aniseed.env and instead calling lua/env.init directly), and here's what I got:

Without anissed's initialization on to-fnl branch:

# user system total
av 0.098s 0.021s 0.123

Here, without aniseed initialization function, the startuptime is identical to the main branch's startuptime (with still slight increase nonetheless), however what can be seen here is that there wasn't any inconsistency or gap between startuptime like with call aniseed.env initialization method (see details section).

Conclusion ..

.. And surly, this exclusively based on my machine, the way in which things my configuration are structured and loaded and how I did my tests.

  • Fennel compiler didn't match my expectations, I thought that it will at least be 10% faster the lua written by me, but at least it isn't slower (thank god, I like fennel a lot).
  • Aniseed's initialization method must skip filesystem checking at startup time and perhaps reconsidering a new way might be better for all of us, in term of startuptime and consistency in loading neovim (see).

For now, and until @Olical 's bright mind :D come up with something great, I created the following
in init.vim

let g:call_aniseed=0
au BufWritePost */nvim/fnl/* lua require('env.core.depm').toggle_aniseed(1)
packadd aniseed
if g:call_aniseed == 1
  lua require('aniseed.env').init({ module = 'env.init' })
  lua require('env.core.depm').toggle_aniseed(0)
else
  lua require('env.init')
endif

in core.depm.depm

(defn toggle_aniseed [val] 
  (let [cmd "'s/g:call_aniseed=.*/g:call_aniseed=%d/' %s/init.vim 2>/dev/null"
        args (string.format cmd val (vim.fn.stdpath "config"))]
    (if (not= val vim.g.call_aniseed)
      (do
        (vim.cmd (.. "silent! !sed -i " args))
        (vim.api.nvim_set_var "call_aniseed" val)))))

Looking forward for your @Olical comment on this, and again, thanks so much for this amazing tool.

Details

[Asciinema](https://asciinema.org/a/xlEQqTgVYVHLqA1DvQs1QxFfb)

Without Aniseed (main branch):

# user system total
01 0.090s 0.040s 0.132
02 0.090s 0.030s 0.118
03 0.100s 0.020s 0.116
04 0.090s 0.020s 0.117
05 0.090s 0.020s 0.119
06 0.100s 0.010s 0.121
07 0.100s 0.010s 0.116
08 0.090s 0.020s 0.118
09 0.100s 0.020s 0.116
10 0.090s 0.030s 0.117
11 0.100s 0.020s 0.116
12 0.090s 0.020s 0.114
13 0.090s 0.030s 0.117
14 0.090s 0.020s 0.115
15 0.090s 0.030s 0.116
16 0.100s 0.020s 0.115
17 0.090s 0.030s 0.117
18 0.090s 0.030s 0.116
19 0.070s 0.050s 0.121
20 0.080s 0.040s 0.116
= 0.091s 0.025s 0.117

With Aniseed

# user system total
01 0.250s 0.030s 0.280
02 0.140s 0.020s 0.165
03 0.220s 0.040s 0.258
04 0.140s 0.030s 0.173
05 0.170s 0.040s 0.217
06 0.210s 0.040s 0.246
07 0.220s 0.040s 0.257
08 0.140s 0.020s 0.165
09 0.160s 0.040s 0.206
10 0.120s 0.040s 0.165
11 0.140s 0.020s 0.163
12 0.150s 0.010s 0.163
13 0.200s 0.010s 0.214
14 0.130s 0.020s 0.158
15 0.140s 0.020s 0.162
16 0.130s 0.030s 0.162
17 0.120s 0.030s 0.164
18 0.140s 0.020s 0.157
19 0.150s 0.020s 0.173
20 0.160s 0.040s 0.205
= 0.161s 0.028s 0.192

Without initializing aniseed

# user system total
01 0.100s 0.030s 0.137
02 0.110s 0.010s 0.123
03 0.110s 0.010s 0.123
04 0.100s 0.020s 0.124
05 0.090s 0.030s 0.123
06 0.090s 0.030s 0.123
07 0.110s 0.010s 0.124
08 0.090s 0.030s 0.125
09 0.100s 0.020s 0.122
10 0.110s 0.010s 0.127
11 0.100s 0.020s 0.123
12 0.090s 0.030s 0.122
13 0.100s 0.020s 0.121
14 0.100s 0.010s 0.123
15 0.090s 0.030s 0.123
16 0.100s 0.020s 0.131
17 0.100s 0.020s 0.119
18 0.090s 0.030s 0.119
19 0.090s 0.020s 0.120
20 0.090s 0.020s 0.121
= 0.098s 0.021s 0.123

Is aniseed.nvim.util.fn-bridge broken?

First off, I'm loving aniseed, and having fun trimming my vim config with Fennel/Aniseed/Conjure.

I was looking at how you can map keys to fennel functions and saw your dotfiles where you use the fn-bridge command. I'm trying this out right now on latest neovim and this doesn't seem to work for me (the function doesn't get created).

Any ideas?

Slow startup time

related: #24

Hi, I'm running neovim 0.5 and have switched over my entire config to fennel with aniseed. However, I'm getting noticeable slower startup now since aniseed apparently takes around 50ms to load according to nvim --startuptime:

...
069.000  050.430  048.199: sourcing /home/javyre/.local/share/nvim/site/pack/paqs/start/aniseed/plugin/aniseed.vim
...

This ~50ms represents 50% of my now 100ms startup time. Can you reproduce this or is it something wrong in my config? I don't think its just my disk being slow as was mentioned on #24 as I'm running on an m.2 ssd as well.

I'm loading aniseed with compile=false and compiling on file save to save on startup time already (which saved me around 20ms)

Update: The same exact dotfiles synced on my laptop give me a total startup time of 260ms with aniseed taking up 195ms)

`aniseed.core.assoc` assigning multiple keys & values

Currently, aniseed.core.assoc only allows for a single key-value pair:

(assoc {} :stuff 5} ; => {:stuff 5}

(assoc {} :stuff 5 :things 4) ; Doesn't work, only gives `{:stuff 5}`

Would it be possible to make that second example possible, like with Clojure's assoc? Maybe using a variadic function?

If making a variadic version of assoc wouldn't work, then maybe something like this would work?

(assoc {} {:stuff 5 :things 4}) ; => {:stuff 5 :things 4}

For that version, this should be basically all that's needed, right?

(defn assoc [tbl kv-tbl]
  (let [tbl (or tbl {})]
    (each [k v (pairs kv-tbl)]
      (tset tbl k v)
    tbl))

As an aside, thank you immensely for making this library. Combined with Conjure, working with Fennel and Neovim is a wonderful experience! Keep up the amazing work!

fennel config small issues

I have been using fennel + aniseed to set my nvim config and everything works mostly fine but I found a little issue,
To begin with, this is my config structure:

├──  init.lua
├──  fnl
│  └──  my
│     ├──  init.fnl
│     ├──  macros.fnl
│     ├──  mapping.fnl
│     ├──  nvim-tree.fnl
│     ├──  options.fnl
│     ├──  pkgs.fnl
│     ├──  plugins
│     │  ├──  codi.fnl
│     │  ├──  fzf.fnl

I have in the init.lua just the code to load packer and aniseed and to set the aniseed#env to point to my.init
init.fnl loads options and plugins (in that order). Plugins setups packer to load the configs of each plugin on-demand ("pcalling" require). But my problem is that there are some options that have to be set before loading several plugins, as
mapleader, maplocalleader and termguicolors. So I had to set those in init.lua as it's the only way I managed them to be loaded before the plugins configs (and it's required other way they still have the old values).
But I was checking your config and you didn't have to do that. Is there something I'm doing wrong, or missing?

In case you wanna have a look, this my config, https://github.com/leiserfg/dots/tree/master/.config/nvim

Add an option for Aniseed to automatially share / export it's copy of fennel

Some 3rd party modules assume they can (require :fennel) which won't work most of the time with Aniseed since it hides it's copy away under aniseed.deps.fennel to avoid conflicts with other tools. An option that makes Aniseed expose this by default could be very helpful for people who want to use modules that depend on Aniseed.

Althouuuugh they could also just do (tset package.loaded :fennel (require :aniseed.deps.fennel))... 🤔 is this worth it?

Change aniseed.env (Fennel dotfiles) to use an option instead of a function call

People that want to use Aniseed's "Neovim configuration as Fennel" tooling need to call an Aniseed function to kick start the process, this can lead to issues if Aniseed isn't loaded yet which can happen with newer package management methods.

I propose replacing this function call with an option that you set instead. If you set the option Aniseed will call the required function on your behalf when it's plugin/aniseed.vim script is loaded. I think this is easier for people to use and works around a bunch of issues!

The old method will still exist, this will just be the canonical documented path to it.

Improve macro.fnl file support

Right now I think files called macros.fnl are the only ones copied over to the lua dir on compilation which ensures they end up on the path. That path is used when requiring the macros, so if your macro file isn't named appropriately it either won't be copied into the right place or Ansieed will try to compile it which will error since macro files can't be compiled.

There's no way to tell that something contains macros without prior knowledge, so we still have to make assumptions. I think the best bet is defaulting to finding anything ending in macros.fnl and making it easily reconfigurable. Then maybe don't copy them, but just add them to an exclude pattern then add the fnl dir to the macros path. (which is new in the latest fennel version!)

Add Windows compatibility

I tried using this for my config today, unfortunately, I see that by default, everything is set up for Linux with the use of symbolic links. This is great for Linux users, but not so great for me as I have to use Windows on my work machine.
I also learned that making "links" or "shortcuts" on Windows is made with the "mklink.exe" tool and it only works in "cmd.exe" AND you need to have administrator rights (god I hate Windows).
Would there be a simple way to add compatibility for both OSes or should I modify the Makefile to have support for Windows somehow?

Files don't get recompiled if require-macro file changes

If i change my macros file, included via require-macros, the file does not properly get reapplied. For it to apply the changes, I currently need to make a minor change in the file I want to have recompiled.

Expected behaviour

Changing a macro causes all files that require-macro it to be recompiled

When editing Fennel files, aniseed sources fennel.vim a lot

So every time I edit an Fennel file my startup time slightly increases because fennel.vim gets sourced multiple times... I'm not sure why this is but is there a way to keep this at a minimum?

nvim --startuptime log.txt

215.732  005.322: loading packages
221.371  005.543  005.543: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/nvim-compe/after/plugin/compe.vim
223.390  001.934  001.934: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/compe-conjure/after/plugin/compe_conjure.vim
223.703  000.494: loading after plugins
223.721  000.018: inits 3
224.780  001.059: reading ShaDa
225.544  000.042  000.042: sourcing /home/rishi/.local/share/nvim/site/pack/packer/opt/zen-mode.nvim/plugin/zen-mode.vim
228.233  003.411: opening buffers
228.543  000.039  000.039: sourcing /home/rishi/.local/share/nvim/site/pack/packer/opt/nvim-colorizer.lua/plugin/colorizer.vim
253.078  024.807: BufEnter autocommands
253.086  000.008: editing files in windows
270.631  000.145  000.145: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/ftplugin/fennel.vim
271.662  000.023  000.023: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/ftplugin/fennel.vim
275.609  000.483  000.483: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/indent/fennel.vim
276.025  000.033  000.033: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/indent/fennel.vim
278.568  000.987  000.987: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/syntax/fennel.vim
278.972  000.015  000.015: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/syntax/fennel.vim
484.833  000.018  000.018: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/ftplugin/fennel.vim
485.444  000.015  000.015: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/ftplugin/fennel.vim
488.385  000.208  000.208: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/indent/fennel.vim
488.707  000.015  000.015: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/indent/fennel.vim
490.364  000.458  000.458: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/syntax/fennel.vim
490.760  000.014  000.014: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/syntax/fennel.vim
494.448  000.433  000.433: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/syntax/fennel.vim
494.833  000.013  000.013: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/syntax/fennel.vim
497.738  000.014  000.014: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/ftplugin/fennel.vim
498.362  000.015  000.015: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/ftplugin/fennel.vim
501.217  000.189  000.189: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/indent/fennel.vim
501.525  000.015  000.015: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/indent/fennel.vim
503.107  000.414  000.414: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/syntax/fennel.vim
503.469  000.013  000.013: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/syntax/fennel.vim
506.995  000.375  000.375: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/syntax/fennel.vim
507.351  000.013  000.013: sourcing /home/rishi/.local/share/nvim/site/pack/packer/start/aniseed/syntax/fennel.vim
582.917  000.241  000.241: sourcing /usr/local/share/nvim/runtime/autoload/provider/clipboard.vim
583.178  315.953  311.805: sourcing /home/rishi/.local/share/nvim/sessions/%home%rishi%.config%nvim.vim
583.383  014.343: VimEnter autocommands
583.386  000.003: UIEnter autocommands
583.389  000.003: before starting main loop
590.783  007.393: first screen update
590.789  000.007: --- NVIM STARTED ---

I am using treesitter for Fennel highlighting if that matters.

Installing and Importing lua libraries

Hay @Olical, sorry if this is extremely simple question.

I'm trying to install a cool lib called lua fun, and I'd like to use it to develop my plugin, any suggestions?

Also, is it possible to use lib fun without prefix?

Thanks 🙏

Don't require aniseed.autoload if it's not used

Some people will use Aniseed at compile time only, so we can't rely on aniseed.autoload in the macros module, only load it if it's required. This could be easier to fix in one grand sweep by rewriting the module macros in terms of a compiler plugin.

Things left to do with the Aniseed eval+module rewrite

I've essentially finished my eval and module rewrite, which hopefully achieves the goals of #56 but we'll see. Things to fix:

  • Fix Conjure's Aniseed completion, can be simplified.
  • Update to the very latest Fennel in anticipation of v1.x
  • Evals without tree sitter miss the closing paren of every form! Possibly due to the Fennel compiler change where when returns nil instead of no value now?
  • Ensure errors print nicely
  • Ensure the REPL doesn't die after an error
  • Ensure we try to require or splat non-Aniseed modules into the current context through some clever filename->module search. (find the file name in the loaded module and get aniseed to splat that into scope)
  • Are there more things we can skip on aniseed.env startup? Just worth looking at again. Is it to do with the runtimepath mangling? Can I avoid that?
  • Remove the remaining aniseed/ prefixed keys that get placed on modules in favour of _LOCALS style... or just go back to aniseed/ prefixes for everything?
  • Evaluating conjure/log.fnl leads to a horrible looking Lua error... (see below) looks like it happens when I eval a file over and over... maybe I need to restart the REPL sometimes or reset the REPL somehow on file load?
  • Don't always copy macro files across, only on embed.sh. Then rely on the fennel macro path which includes the fnl directory for most macros. This avoids the duplication of macro files across the fnl and lua directories. Maybe we can use macro-searchers and do away with all the path mangling grossness? needless perfection and doesn't work with embed.sh
  • Do evals of a defns actually change the behaviour of the module exported fn?
  • Ensure completion works as expected
  • Add manual or automatic ways to restart Aniseed REPLs from Conjure when they hang etc
; eval (file): ...al/repos/Olical/conjure/fnl/conjure/log.fnl
; ...packer/start/conjure/lua/conjure/aniseed/deps/fennel.lua:534: [string "local sponsors = ___replLocals___['sponsors']..."]:201: main function has more than 200 local variables

Then after some soak time I think we're ready to go! You're more than welcome to use the develop branches now to get the slimmer more efficient Lua output and real interactive aniseed evals. This works now!

(local foo 10)
(+ 10 foo)

;; in two separate evals! No module macros required!
;; although the module macros now output code that should be near enough identical to what you'd write, yay!

Syntax Highlighting for aniseed macros

Hi there, so I cloned fennel.vim, and added syntax definition for macro and functions provide by aniseed. Is there a way to integrate those into aniseed repo, for better coding experience.

Request: More documentation on plugin development

This, perhaps, is not an Aniseed issue, but maybe my own lack of understanding of how to get plugins working. I've followed the guide so far, and things are working great. But I'm having a hard time getting from Aniseed & Conjure to nvim plugin.

I'm able to get the functionality I wanted with my fnl file open, but even poking through your Fennel/Aniseed projects, I'm unable to figure out how to turn my functions into a working plugin. Is there any chance you can add some more documentation on this part of the process?

Error when following the setup in Olical/dotfiles

Error detected while processing $HOME/.config/nvim/init.vim:
line  264:
E5105: Error while calling lua chunk: ...d/.local/share/nvim/plugged/aniseed/lua/aniseed/nvim.lua:67: validation_failed: "set": expected function, received nil
Press ENTER or type command to continue

nvim version: 0.3.5
OS: Ubuntu 18 Windows WSL

Create Vim help files

They're a great way to discover things from within Vim and I think they should be the primary way to dig into the project. The readme should serve as installation and beginner documentation, enough to get you up and running.

Once you have it set up you should be working off of documentation within Neovim so you can try out commands as you read about them etc. Having duplicate information across the readme and help files could be annoying to keep in sync so got to be careful to have a clear distinction / split.

vimscript-less init

I'm rewriting my vim config again, this time I'm trying to take a lua first approach for the package manager so that everything can be fennel.

I looked into it, and it appears that getting bootstrapped requires installing the aniseed plugin and the recommendation is to do that with a vimscript package manager. Is there any way to get around that by installing manually? I tried adding to the runtimepath and sourcing the plugin/aniseed.vim file, but I'm running into a strange error:
image

Any ideas? I think a lua only approach would be pretty slick and would align with the new neovim 0.5 stuff quite well.

<Enhancement> Include the Fennel.vim fork mentioned in Conjure

As of the latest Conjure release, there was a mention of possibly including your Fennel.vim fork in the Conjure+Aniseed toolkit. I personally think that this makes sense to include in this project, as without it Aniseed is not quite as useful. It only really makes sense to use with Fennel syntax highlighting, and probably should be included here.

How to include or use external modules in macros?

Hey @Olical, finally I'm back at rewriting my config with aniseed. Currently I'm trying to leverage macros. However, I'm getting errors due to external module, I tried to define c in let expression, didn't work, also tried defining a local variable (local c (require aniseed.core)) at the top of the file, but that too didn't fix my issue.

Here is my macro.fnl, I'm basically writing a macro that would bind key definition or a list of definitions.

Thanks

{
 :bindkey
 (fn [m]
   (let [options (or (. m 4) {})
         opts (c.merge {:noremap true :silent true} options)
         buffer (. m :buffer)
         prefix {}
         formatrhs (fn [m]
                     (let [opts (or (. m 4) {})
                           dep (. opts :dep)
                           extra (if (not dep) ""
                                   (c.table? dep) (.. "<cmd>packadd " (table.concat dep " ") "<cr>")
                                   (c.string? dep) (.. "<cmd>packadd " dep "<cr>"))
                           rhs (if (. opts :lua) (.. extra "<cmd>" "lua " (. m 3) "<cr>")
                                 (. opts :cmd) (.. extra "<cmd>" (. m 3) "<cr>")
                                 :else (.. extra (. m 3) ))] rhs))]
     `(do 
        (each [mode _ (string.gmatch (. m 1) "(%w)")]
          (table.insert prefix mode))
        (each [_ key (pairs [ "cmd" "lua" "dep" "buffer"])]
          (c.assoc opts key nil))
        (each [_ mode (pairs prefix)]
          (if buffer
            (vim.schedule #(vim.api.nvim_buf_set_keymap buffer mode (. m 2) (formatrhs m) opts))
            :else
            (vim.schedule #(vim.api.nvim_set_keymap mode (. m 2) (formatrhs m) opts))))   
        )))

 :bindgroup
 (fn [group]
   `(c.run! bindkey group))
}

aniseed.macros module not found

Hello, first of all thank you for this great project.
After updating aniseed to the newest version, I'm getting the following error upon loading neovim:

Compile error in /home/pablo/.config/nvim/fnl/dotfiles/init.fnl:1                               
  aniseed.macros module not found.                                                              
(module dotfiles.init                                                                              

reloading init.fnl on save

Hello,

I've been playing with fennel and aniseed for a little while and I'm trying to get it
to reload my config when I make save changes to the init.fnl file. How would I go about
that these days? I was using :AniseedEvalFile before but that doesn't seem like a thing now .
Thanks :)

Using seed.sh, error finding plugin.aniseed.core

Hi there, so I'm trying to create a new plugin with your amazing setup and its seems that I have an issue somewhere. I've run the seed.sh script, however, when trying to eval the following, I get not found error, even though I've run test and it worked as well as complie

 (module cyclist.main
   {require {a plugin.aniseed.core
             str plugin.aniseed.string
             nvim plugin.aniseed.nvim}})

I'm now using aniseed.x directly, which I think defeat the purpose of seed.sh . Please let me know if I miss something or it is just isn't possible for live eval.

Thanks again for aniseed :)

Question: what about the runtime directories?

First off, I would like to say thanks so much for your plugin. It gives me such a huge motivation to learn more about clojure for my favorite nvim.

However, I was wondering how you would integrate aniseed with e.g. those type specific configurations in after/ftplugin or some user custom defined functions in autoload/ . I know for a fact that I can leave those files in VimScript as they are, and the rest in Clojure as you showed on your blog post. But I feel like it would be cool if I can write all those files in Clojure too.

Since I'm pretty new to clojure and lua, please let me know if I misunderstand how aniseed works.

Improve error reporting

Fennel provides fennel.traceback, which can provide more ergonomic, readable and pleasing error messages. This is already being used in aniseed.eval, where the errors will be printed nicely.
When using aniseed for the vim configuration however, errors don't run through traceback, thus showing rather ugly and unhelpful lua error messages.

Wrapping the configuration in an xpcall that defers errors to fennels traceback handler should be pretty simple to implement, and would already drastically improve the experience of configuring vim in fennel.

This would still not affect any deferred execution, and thus wouldn't affect anything that's called on keybinds, autocmds, or passed as callbacks to other functions. This could be improved in several ways:

  • Simply provide an easy-to-use function to wrap custom functions in, that wraps the function you're calling in xpcall for you. This would require actively doing it, and would make it an "always-on" thing, which is both suboptimal. BUT: it would be rather trivial.
  • Try to automatically wrap functions by possibly using the fennel compiler plugin API (?). This would work automatically and allow the user to toggle it on and off depending on "development" vs "in-use" state. It would however also bring more extreme performance issues, and probably also change behaviour of code in many places where code relies on how errors behave.
  • Try to intercept errors at a higher level, overriding the traceback handler that vim uses to print it's errors. lua has debug.traceback, but from what I can tell that's not what is being used here (although I can't be sure, haven't looked into it). At least from my primitive tests, just overriding that function changed nothing.

Aniseed macros sans Neovim?

def, defn et al beautify Fennel, and make things flow more naturally. Between Neovim's first-class Lua support, Conjure and Fennel, we have the makings of an unbelievably well-integrated developer experience for Vim

However, there's a big issue as of today standing in the way of writing small Fennel libraries with a conversational approach to development. For example, imagine running fennel script.fnl where script.fnl defines its functions with defn. Or perhaps fennel -l aniseed-macros.fnl script.fnl. Sadly, it isn't possible to do this currently, even when you prefix script.fnl with (require-macros :path/to/aniseed/macros.fnl).

Instead it seems necessary to fundamentally rearchitect script.fnl as an extension of Olical/aniseed, per how Conjure does it, in order to write code with defn. That's a heavy burden to place on an otherwise lightweight Fennel script or library. Frustratingly so, because without writing Fennel with Aniseed's macros, it becomes difficult to interactively develop Fennel with Conjure: Conjure assumes you use defn et al in your Fennel, but it's just the opposite with the normal Fennel compiler, which doesn't seem to understand Aniseed's macros in the absence of Aniseed's compiler toolchain.

Speaking for myself, I'd love to have the ability to write all my Fennel code with defn etc, and then also optionally eval my code in Neovim with Conjure. But there's got to be a way to do that without fundamentally rearchitecting small libs; perhaps it could be accomplished through a luarocks lib.

I'd be more than willing to turn Aniseed's macros into an independent library for this purpose, but I haven't been able to figure out how to do so. I'm starting to suspect a clean implementation of this would require modifying the Fennel compiler. I'd greatly appreciate reading your thoughts on this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.