zest.nvim icon indicating copy to clipboard operation
zest.nvim copied to clipboard

def-keymap-fn throws error

Open p00f opened this issue 4 years ago • 13 comments

def-keymap works but def-keymap-fn throws this:

; Sponsored by @rafaeldelboni ❤
; --------------------------------------------------------------------------------
; eval (file): ...s/nvim/.config/nvim/fnl/dotfiles/mappings.fnl
; Compile error in /home/p00f/.local/share/nvim/site/pack/packer/start/zest.nvim/fnl/zest/macros.fnl:117
;   unknown global in strict mode: ZEST_VLUA_23_auto
; 
;               `(.. ":call " ZEST_VLUA# "()<cr>"))
; * Try looking to see if there's a typo.
; * Try using the _G table instead, eg. _G.ZEST_VLUA_23_auto if you really want a global.
; * Try moving this code to somewhere that ZEST_VLUA_23_auto is in scope.
; * Try binding ZEST_VLUA_23_auto as a local in the scope of this code.

when i do

(import-macros {:def-keymap-fn fmap
                :def-keymap kmap} :zest.macros)
(kmap :<C-n> [n] ":bnext<CR>")
(fmap :de [n] (print 1))

p00f avatar Sep 02 '21 08:09 p00f

What plugin do you use to compile fennel, I tried it out and it didn't seem like a problem.

UdayvirThind avatar Sep 05 '21 07:09 UdayvirThind

aniseed

p00f avatar Sep 05 '21 10:09 p00f

That's conjure's eval buffer, right? It could be just conjure not liking the globals.

I believe aniseed's compiler allows them, though. Does it create the binding successfully?

tsbohc avatar Sep 05 '21 11:09 tsbohc

aniseed doesn't like it either

p00f avatar Sep 05 '21 12:09 p00f

Found the bug, Fennel deprecated unknown globals with v10.0, Aniseed uses fennel v10.0, conjure also uses aniseed to compile.

UdayvirThind avatar Sep 05 '21 13:09 UdayvirThind

Thanks!

Well, that's one more reason to move over to runtime. As it is right now, one either has to explicitly disable strict globals or use an older version of fennel to compile.

I'm pretty busy with uni at the moment, but I'll get to it when I can.

tsbohc avatar Sep 05 '21 13:09 tsbohc

Yeah, I also use v0.9.2 to compile because of macros.

UdayvirThind avatar Sep 05 '21 13:09 UdayvirThind

Thanks!

p00f avatar Sep 05 '21 14:09 p00f

Here is a quick dirty solution to this:

(fn local-getter []
  '(fn [xs#]
     (for [i# 1 20]
       (let [(name# local-val#) (_G.debug.getlocal 2 i#)]
         (if (= name# xs#)
           (lua ,(.. "return " (view 'local-val#)))
           (not name#)
           (lua :break))))))

Usage:

; inside macro
(local get# ,(local-getter))
(get# ,(view 'ZEST_VLUA#)) ; tostring can also be used instead of view

UdayvirThind avatar Sep 05 '21 14:09 UdayvirThind

btw I think conjure uses aniseed's compiler - i downgraded aniseed to 3.20 and i could evaluate this

p00f avatar Sep 05 '21 15:09 p00f

If aniseed is installed conjure uses it as it compiler

UdayvirThind avatar Sep 05 '21 15:09 UdayvirThind

Oh this should also be fixed by #8, you can use my fork until it's merged too.

Olical avatar Oct 01 '21 18:10 Olical

It's not so much to do with the unknown global crack down, I don't think. It's mostly to do with how they enforce gensyms across syntax quote boundaries correctly now.

Olical avatar Oct 01 '21 18:10 Olical