profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/rktjmp/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.

rktjmp/hotpot.nvim 63

:stew: Carl Weathers #1 Neovim Plugin.

rktjmp/fwatch.nvim 43

fwatch.nvim lets you watch files or directories for changes and then run vim commands or lua functions.

rktjmp/highlight-current-n.nvim 8

Highlights the current /, ? or * match under your cursor when pressing n or N and gets out of the way afterwards.

rktjmp/git-info.vim 5

Extract git repo information for use in vim status lines.

rktjmp/hotpot-build.nvim 2

WIP Hotpot assistant to build Fennel plugins

rktjmp/arduino.tmbundle 1

TextMate support for Arduino

rktjmp/ftgles 1

A truetype font rendering library for OpenGL ES on iOS devices (iPad and iPhone)

rktjmp/html-to-temple 1

Convert HTML to Temple

rktjmp/ker-pow 1

Site list index page for your Pow installation.

issue commentfamiu/feline.nvim

[Feature] Named components?

Without fully knowing the problem (or maybe just to rubber duck), why can't you just have a regular table that you insert components[component.name] = component when setup is called? Then just treat it as a hash table?

famiu

comment created time in 3 days

delete branch rktjmp/neovim

delete branch : mhanberg-typo-fix

delete time in 4 days

issue openedrktjmp/hotpot.nvim

Hooks interface?

RE: #33

To avoid the cost of requiring fennel if you want to do "low level" stuff, a/some hooks would be nice.

There is probably only one real place to hook which is just after we require Fennel. Adding other hooks for will-load-module|macro or will-compile-module|macro could exist but are probably not that useful?

(fn compile-string [string options]
  (local fennel (require-fennel))

  ;; -------------
  ;; hook interface?
  ;; -------------
  (each [_ hook (ipairs config.hooks)] ; config.when_fennel? config.with_fennel? 
    (hook fennel))

  (when (not has-injected-macro-searcher)
    (table.insert fennel.macro-searchers 1 macro-searcher)
    (set has-injected-macro-searcher true))

  (local options (doto (or options {})
                       (tset :filename (or options.filename :hotpot-compile-string))))
  (fn compile []
    (pick-values 1 (fennel.compile-string string options)))
  (xpcall compile fennel.traceback))

and a hook would just be a function that accepts fennel and returns ... true|nil,error? Probably the hook should just raise if they have an error.

local add_cloader = function(fennel)
  table.insert(fennel["macro-searchers"], function(module_name)
     local filename = fennel["search-module"](module_name, package.cpath)
     if filename then
        local func = "luaopen_" .. module_name
        return function() return package.loadlib(filename, func) end, filename
     end
  end)
end

require("hotpot").setup({
  provide_require_fennel = true,
  hook = {add_cloader}
})

Mostly this is just a question of names:

will_compile = {}
configure_fennel = {}
on|for|with|when|has_fennel = {}
when_load_fennel = {}

required_fennel = {} -- might cause confusion around regular "require fennel"
                     -- not popping the hook, though that could be made to work easily.

-- allows for future hooks in namespace
hook = {
  will_compile = {}
}

created time in 7 days

issue closedrktjmp/hotpot.nvim

Cannot import .so file in a macro file

Hello! I am here, again, with another bug.

This time the bug is related to trying to require a luarock module from a fennel macro file. I am trying to use this luarock inside my macro file to process strings using PCRE2 regexes.

As you can see in the next screenshot, the luarock can be required from init.lua and init.fnl, but it cannot be required from macrofile.fnl.

evidence

How to reproduce

Learning from past issues, I created this repository that contains how to reproduce the bug using docker.

My suspicions

I am using this:

local package_path_str = table.concat({
    "/opt/here/share/lua/5.1/?.lua", "/opt/here/share/lua/5.1/?/init.lua",
    "/opt/here/lib/luarocks/rocks-5.1/?.lua",
    "/opt/here/lib/luarocks/rocks-5.1/?/init.lua"
}, ";")

if not string.find(package.path, package_path_str, 1, true) then
    package.path = package.path .. ';' .. package_path_str
end

local install_cpath_pattern = "/opt/here/lib/lua/5.1/?.so"

if not string.find(package.cpath, install_cpath_pattern, 1, true) then
    package.cpath = package.cpath .. ';' .. install_cpath_pattern
end

To make neovim able to source luarocks as Lua modules. This is the way that packer recommends and uses.

Maybe the bug is related to the package.path variable.

closed time in 7 days

datwaft

issue commentrktjmp/hotpot.nvim

Cannot import .so file in a macro file

Hotpot aims to be "just Fennel", so it can disable the sandbox but doesn't by default, and won't patch this loader in by default either unless it were to be up streamed in someway.

As is, I think the user inserting the c-loader as shown is the solution.

Hotpot might (should?) get an optional hook interface so you can lazily insert the loader without having to directly require fennel, so you can avoid the startup time cost of (require :fennel).

Probably is worth noting the work around somewhere in the Fennel docs, or at least noting the limitation in the macro docs and why.

datwaft

comment created time in 7 days

push eventrktjmp/hotpot.nvim

Oliver Marriott

commit sha 1335f873a20f58ae6b9be52bd05d8cc4548fe5aa

Fix .fennel.latest() doc in setup

view details

push time in 7 days

issue openedrktjmp/hotpot.nvim

Adjust searcher insert position for nvim0.6

When https://github.com/neovim/neovim/pull/15436 is merged, nvim 0.6 will not clobber the default package.preloader searcher, so we can insert ourselves at 2 instead of 1.

Will have to check against version since 0.5 still has the errant behaviour.

https://github.com/rktjmp/hotpot.nvim/blob/71969804f234545cd66bbb19d33ab9b1bda6b311/fnl/hotpot/hotterpot.fnl#L23

created time in 7 days

issue closedrktjmp/hotpot.nvim

Add "intercept require :hotpot" option

Re: #27 where the cljlib must be patched so it's require :fennel calls can work without including fennel somewhere else.

It would be nice if Hotpot could optionally be instructed to intercept require calls for fennel and provide it's already included version.

require("hotpot").setup({
  intercept_require_fennel = true
})

closed time in 7 days

rktjmp

issue commentrktjmp/hotpot.nvim

Add "intercept require :hotpot" option

Fixed in #30

rktjmp

comment created time in 7 days

issue closedrktjmp/hotpot.nvim

Cannot import .lua file from a macro file

Hello! Sorry for so many issues.

This time I was trying to use another regex library, as a continuation of #33. This library is LuLPeg and it is a pure Lua port of LPeg; which means that it doesn't need any .so files.

When I try to require this file from a macro file it seems to try to compile the file as if it was a .fnl file.

Here is the error message:

Error detected while processing /root/.config/nvim/init.lua:
.../packer/start/hotpot.nvim/fnl/hotpot/searcher/module.fnl:104: Compile error in /root/.config/nvim/fnl/core/init.fnl:3
  Parse error in /root/.config/nvim/lua/lulpeg.lua:1
  invalid whitespace after quoting prefix
-- LuLPeg, a pure Lua port of LPeg, Roberto Ierusalimschy's
----------^
stack traceback:
^I[C]: in function 'parse_error'
^I...site/pack/packer/start/hotpot.nvim/lua/hotpot/fennel.lua:3589: in function 'parse_prefix'
^I...site/pack/packer/start/hotpot.nvim/lua/hotpot/fennel.lua:3663: in function '(for generator)'
^I...site/pack/packer/start/hotpot.nvim/lua/hotpot/fennel.lua:2996: in function 'compile-string'
^I...site/pack/packer/start/hotpot.nvim/lua/hotpot/fennel.lua:4014: in function 'loader'
^I...site/pack/packer/start/hotpot.nvim/lua/hotpot/fennel.lua:2004: in function '_2_'
^I...site/pack/packer/start/hotpot.nvim/lua/hotpot/fennel.lua:2007: in function 'require'
^I/root/.config/nvim/fnl/core/macro/macrofile.fnl:1: in function 'loader'
^I...site/pack/packer/start/hotpot.nvim/lua/hotpot/fennel.lua:2041: in function 'require-macros'
^Isrc/fennel/macros.fnl:257: in function <src/fennel/macros.fnl:251>
^I[C]: in function 'xpcall'
^I...
^I...site/pack/packer/start/hotpot.nvim/lua/hotpot/fennel.lua:3000: in function 'compile-string'
^I...te/pack/packer/start/hotpot.nvim/fnl/hotpot/compiler.fnl:23: in function <...te/pack/packer/start/hotpot.nvim/fnl/hotpot/compiler.fnl:22>
^I[C]: in function 'compile_string'
^I...te/pack/packer/start/hotpot.nvim/fnl/hotpot/compiler.fnl:40: in function <...te/pack/packer/start/hotpot.nvim/fnl/hotpot/compiler.fnl:29>
^I[C]: in function 'compile_fnl'
^I.../packer/start/hotpot.nvim/fnl/hotpot/searcher/module.fnl:101: in function <.../packer/start/hotpot.nvim/fnl/hotpot/searcher/module.fnl:89>
^I[C]: in function 'pcall'
^I.../packer/start/hotpot.nvim/fnl/hotpot/searcher/module.fnl:135: in function <.../packer/start/hotpot.nvim/fnl/hotpot/searcher/module.fnl:124>
^I[C]: in function 'require'
^I/root/.config/nvim/init.lua:15: in main chunk
(import-macros {} :core.macro.macrofile)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The module can be required without any problem in a normal .fnl file.

How to reproduce

Here is the repository to reproduce the issue: https://github.com/datwaft/hotpot-issue_34

closed time in 7 days

datwaft

issue commentrktjmp/hotpot.nvim

Cannot import .lua file from a macro file

merged #30

datwaft

comment created time in 7 days

push eventrktjmp/hotpot.nvim

Oliver Marriott

commit sha e59b660917a7c5ca3fe69635b5ae43a00ec33004

Add provide_require_fennel setup option

view details

Oliver Marriott

commit sha 3434a7038d2faa618729258a42c8185f5afb6fe4

Add module loader to macro searcher because apparently that's a thing

view details

Oliver Marriott

commit sha 4f6bfd84b2230fd933acb4fba1b4f9bb3f3b4d8b

S-expression S-implification

view details

Oliver Marriott

commit sha 7d14452cd4e495342f7e24c677844b056bfecc24

Rewrite searcher.macro to find lua|fnl modules too

view details

Oliver Marriott

commit sha ff40d43240f44238741b89e42eff897132238f31

Formatting

view details

Oliver Marriott

commit sha 86fcb3ff713ebe47b67aa1decef6ae4c82c2cd47

Remove match on nil

view details

Oliver Marriott

commit sha 6f594095800cc5eb79ca439728ef05f60f6e2fc9

Warn about lua+compiler env

view details

Oliver Marriott

commit sha 61b558fa21ff0b1c75ada9a6a7d931ed7a39eefc

provide_require_fennel documentation

view details

Oliver Marriott

commit sha 44081ad9a50fc13a69822a65f9066cdbdb749776

Use loadfile as module loader directly

view details

Oliver Marriott

commit sha ed05db4eb75301c7b02e4cbb51b18b2f95e47561

Also pass modname to macro eval contexts

view details

Oliver Marriott

commit sha 71969804f234545cd66bbb19d33ab9b1bda6b311

:bird:

view details

push time in 7 days

PR merged rktjmp/hotpot.nvim

Provides fennel

:mouse:

+85 -69

0 comment

9 changed files

rktjmp

pr closed time in 7 days

PullRequestReviewEvent

push eventrktjmp/hotpot.nvim

Oliver Marriott

commit sha 21622f3eb30017a635a15a44627fed7570735a9b

Use loadfile for lua-loader so we can pass modname for "..." value

view details

Oliver Marriott

commit sha e59b660917a7c5ca3fe69635b5ae43a00ec33004

Add provide_require_fennel setup option

view details

Oliver Marriott

commit sha 3434a7038d2faa618729258a42c8185f5afb6fe4

Add module loader to macro searcher because apparently that's a thing

view details

Oliver Marriott

commit sha 4f6bfd84b2230fd933acb4fba1b4f9bb3f3b4d8b

S-expression S-implification

view details

Oliver Marriott

commit sha 7d14452cd4e495342f7e24c677844b056bfecc24

Rewrite searcher.macro to find lua|fnl modules too

view details

Oliver Marriott

commit sha ff40d43240f44238741b89e42eff897132238f31

Formatting

view details

Oliver Marriott

commit sha 86fcb3ff713ebe47b67aa1decef6ae4c82c2cd47

Remove match on nil

view details

Oliver Marriott

commit sha 6f594095800cc5eb79ca439728ef05f60f6e2fc9

Warn about lua+compiler env

view details

Oliver Marriott

commit sha 61b558fa21ff0b1c75ada9a6a7d931ed7a39eefc

provide_require_fennel documentation

view details

Oliver Marriott

commit sha 44081ad9a50fc13a69822a65f9066cdbdb749776

Use loadfile as module loader directly

view details

Oliver Marriott

commit sha ed05db4eb75301c7b02e4cbb51b18b2f95e47561

Also pass modname to macro eval contexts

view details

Oliver Marriott

commit sha 71969804f234545cd66bbb19d33ab9b1bda6b311

:bird:

view details

push time in 7 days

issue commentrktjmp/hotpot.nvim

`...` is nil from Fennel but not from Lua

Hmm,

fennel.eval does accept a ... after options, but it's not where the bug happens (will still be patched though).

If I

; cljlib/init.pnl
(eval-compiler
  (print ...))

I get

nil ~/.../cljlib/init.fnl

I think the actual issue is that the process basically follows this:

  1. require cljlib
  2. compiler compiles cljlib/init.fnl -> lua
  3. create loader for compiled lua
  4. run loader with modname as arg

The problem is that at step 2, the import-macros expression is evaluated by the compiler , which does not have a module name set (... is nil filename). If it could find the macro, then inside the macro ... would be set, and post-compile when we run the module, ... is also set. Basically that check just happens to fall into some no mans land, not quite a fennel context, not yet a lua context.

I had a look around the fennel source and couldn't immediately see a way to pass it in, I don't think the compiler has any concept of a "module" because it may be compiling chunks or whatever.

I think cljlib just makes some assumptions that if you're going to compile it, it's happening in the cjllib/ dir or that otherwise you will eval it.

So cljlib probably will always need that patch.

datwaft

comment created time in 7 days

issue commentrktjmp/hotpot.nvim

`...` is nil from Fennel but not from Lua

Hmm, seems that cljlib still needs the patch,

; cljlib/init.fnl

(print ...)
(if (and ... (not= ... :init))
  (print :im (.. ... :.init-macros))
  (print :im :init-macros)) 

(import-macros {: defn : into : empty
                : when-let : if-let : when-some : if-some}
               (if (and ... (not= ... :init)) (.. ... :.init-macros) :init-macros))

Will still crash at the macro import, patching the macro path will work, and then the print checks for ... look OK. Might need an rewrite of this, to behave like the lua loader (don't just eval?)

https://github.com/rktjmp/hotpot.nvim/blob/21622f3eb30017a635a15a44627fed7570735a9b/fnl/hotpot/searcher/macro.fnl#L7-L24

datwaft

comment created time in 7 days

issue closedrktjmp/hotpot.nvim

`...` is nil from Fennel but not from Lua

Hello!

Today, while I was testing utf.lua, a library that seems to promising to process regexes with utf-8 characters, I found a very strange bug related to hotpot.

When requiring the library from a fennel file the following error message is displayed:

/root/.config/nvim/lua/utf8/init.lua:2: attempt to index local 'module_path' (a nil value)

It seems that this library aliases ... as module_path, and when requiring a file from Fennel ... is nil, but when requiring it from Lua it's not (permalink).

local module_path = ...
module_path = module_path:match("^(.-)init$") or (module_path .. '.')

This could be related to those patches from #27.

This issue is strange because, as you can see in this branch of the reproduction repository, when requiring the module from init.lua there is no problem.

Additionally, as you can see in this branch, when the order of the requires change and you first require from the Lua file and after that from the Fennel file, the test passes. This is because the package was successfully loaded from Lua and doesn't need to be loaded again.

This could be a temporary fix.

How to reproduce

I created this repository to reproduce the issue using Docker: datwaft/hotpot-issue_35

closed time in 7 days

datwaft

issue commentrktjmp/hotpot.nvim

`...` is nil from Fennel but not from Lua

Fixed https://github.com/rktjmp/hotpot.nvim/commit/21622f3eb30017a635a15a44627fed7570735a9b

Probably fixes that cljlib ... patch we needed too.

datwaft

comment created time in 7 days

push eventrktjmp/hotpot.nvim

Oliver Marriott

commit sha 21622f3eb30017a635a15a44627fed7570735a9b

Use loadfile for lua-loader so we can pass modname for "..." value

view details

push time in 7 days

issue commentrktjmp/hotpot.nvim

Cannot import .lua file from a macro file

Using #30 fixes this.

datwaft

comment created time in 8 days

issue commentrktjmp/hotpot.nvim

Cannot import .so file in a macro file

Bummer dude.

datwaft

comment created time in 9 days

issue commentrktjmp/hotpot.nvim

Cannot import .so file in a macro file

%x: (where x is any non-alphanumeric character) represents the character x. This is the standard way to escape the magic characters. Any punctuation character (even the non magic) can be preceded by a '%' when used to represent itself in a pattern.

%? should match ?

datwaft

comment created time in 10 days

issue commentrktjmp/hotpot.nvim

Cannot import .so file in a macro file

I actually asked on the IRC channel,

technomancy@technomancy:libera.chat
when I read your question I was like "there's no way there's a legitimate use
case for loading C code from a macro" ... then I read the issue and saw it was
PCRE and I was like "oh... OK, so I guess there is one"

technomancy@technomancy:libera.chat
short-term I think writing your own macro searcher is the way to go. I will
need to think about this. it seems like overkill to include it out of the box
if there is literally only one single use case for it but if the implementation
is simple maybe

If you do make sure you include a fennel repro, not a hotpot one to avoid any confusion. Opening an issue at least lets it get tracked.

datwaft

comment created time in 10 days

issue commentrktjmp/hotpot.nvim

Cannot import luarock from macro file

You can do this, https://github.com/rktjmp/hotpot-issue_33/commit/caf7851f81d19640f8b4279d6294cd9e480e048f to insert the two final lua loaders into the macro searchers.

It will incur a start up penalty as you now have to load fennel every boot, or you could just comment/uncomment it when you make changes to those macro files. My first attempt was to put that code in the macro file and try to just effect the searcher when loading that one file but fennel.macro-searchers is nil in that context so you can't append to it.

I don't really endorse doing this though, it's relying on things being in a "probable state".

datwaft

comment created time in 10 days

push eventrktjmp/hotpot-issue_33

Oliver Marriott

commit sha caf7851f81d19640f8b4279d6294cd9e480e048f

Add c-loader and all-in-one-loader to macro-searchers

view details

push time in 10 days

issue commentrktjmp/hotpot.nvim

Cannot import luarock from macro file

I did some AFK thinking and realised why it doesn't work. I neglected to poke at the cpath properly before (too sleepy :zzz:).

Fennel (and Lua in general) has a fallback system for the package finders. You can read more about this in the lua docs, re: require.

With hotpot and normal fennel, the searchers roughly go: [preload, hotpot, neovim, package.path, package.cpath], because we insert our loaders in front of lua's defaults.

But the macro searcher in Fennel doesn't inherit from that list, it has its own.

https://github.com/bakpakin/Fennel/blob/e6a8b03fec1f24f14f3734cb4eb4926c9641b301/src/fennel/specials.fnl#L1084-L1104

Specifically the list:

(local macro-searchers [lua-macro-searcher fennel-macro-searcher])

Since these searchers don't look at package.cpath themselves, nor do they fallback to the regular searchers, the lua-rock rex_pcre2.so isn't found (because that's where it lives).

Again, I am not sure if this is intentionally omitted or just forgotten.

I could patch the hotpot searcher to look at the cpath but it's supposed to be "last in the list" and I am not 100% on how to even load a .so from lua right how. I think it should be patched upstream if it's desired behaviour in Fennel.

datwaft

comment created time in 10 days

issue commentrktjmp/hotpot.nvim

Cannot import luarock from macro file

Obviously it would be nice if this did work.

datwaft

comment created time in 10 days

issue commentrktjmp/hotpot.nvim

Cannot import luarock from macro file

Thanks for all the testing you're doing and thanks for the detailed repro.

I can't get this to work with core Fennel, See my fork: https://github.com/rktjmp/hotpot-issue_33 and run the fennel test

root@5b112ec28647:~# cd fennel-test/
root@5b112ec28647:~/fennel-test# fennel test.fnl
required-in-macro	FAIL
required-in-module	OK

# not 100% on if this is the correct usage, values from (print package.path package.cpath)
root@ef627953ea69:~/fennel-test# fennel --add-package-path ";/opt/here/share/lua/5.1/?.lua;/opt/here/share/lua/5.1/?/init.lua" --add-fennel-path ";/opt/here/share/lua/5.1/?.lua;/opt/here/share/lua/5.1/?/init.lua" test.fnl
required-in-macro	FAIL
required-in-module	OK

Not sure if this is intentional on Fennels part or an oversight, the macro code has some specific rules around it. It does have a specific macro-path it uses for finding macros, not sure if finding modules in macros inherits from it. See https://fennel-lang.org/reference#macro-module-searching

This might be a wontfix, temporarily? Just not sure if it's a fix for upstream, intentional or if hotpot should just be cloning over some path values somewhere.

Basically if you can make it work with the fennel binary, then 100% we will make it work in Hotpot. I might have just mis-wrote the option out.

As some background, all the code run in macros is handled by Fennel. When you call (import-macros ...), Hotpot will find the file requested (so "lib/my-macro.fnl"), and the pass the contents of that file off to Fennel to actually run it.

https://github.com/rktjmp/hotpot.nvim/blob/657c208b7b2d639746a7a5a33623b8619b5e50ec/fnl/hotpot/searcher/macro.fnl#L19-L33

See hotpot read a file then just push to fennel.eval

We can pass options there, so if there is an option that lets fennel find the module, we can do that. Of course there could be issues with path's being set/passed correctly, but that it works in normal modules tells me that they are working OK and shouldn't need tweaking.

Note that I am using the provides-fennel #30 branch of hotpot in that repro which includes some macro-file module-finding parity/fixes to hotpot which might be useful to you (doesn't seem to fix this issue though).

datwaft

comment created time in 10 days

push eventrktjmp/hotpot-issue_33

Oliver Marriott

commit sha d8705e5ac4a10a66a487bcde7128b82dc52a371c

update readme

view details

push time in 10 days