-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I go Fennel with luar? #5
Comments
Hi, @andreyorst ! I use Fennel in some projects and was actually wondering what could be the best way to integrate it with The first thing to note is that you can already import some module written in Fennel and use it inside a Suppose you have a file called (local um 17)
(fn outro [n] ( 1 n))
{: um
: outro} Then you could use it inside a lua %opt{some_option} %{
local fennel = require "fennel"
table.insert(package.loaders or package.searchers, fennel.searcher)
local module = require "module"
if arg[1] then
return module.um
end
return module.outro(18)
} Or you could compile your fennel code first with fennel ---compile module.fnl > module.lua and import One problem these solutions have is that inside ; This is module.fnl
(fn [kak]
(kak.set-option "buffer" "alingtab" false)) And then: # This is the kak file
lua %{
local fennel = require "fennel"
table.insert(package.loaders or package.searchers, fennel.searcher)
local main = require "module"
main(kak)
} We could also define a
What do you think? |
There's yet another option, using lua %{
local fennel = require "fennel"
fennel.eval [[
(kak.set-option "buffer" "alingtab" false)
]]
} If you think it could be useful having a
Then we could write: fennel %val{bufname} %(
(let [name (args)]
(kak.echo name))) |
I've mainly thought about using fennel directly from expansions, so I guess |
OK! I'm gonna take a look at it. |
theoretically, fennel compiler should be pure, so when we compile fennel code we should always receive the same result. So as a quick way we could compute fast hash sum of fennel code, and compile it down once. So when user calls |
I'd rather prefer to keep it as simple as possible. Additionally, I think it's a good idea to avoid premature optimisations. When you say "reparsing whole fennel", do you mean the Instead of writing the I want to document here some design decisions: Error handlingError handling is the most laborious part. Specially considering that the output of the lua interpreter is different from the output of the fennel interpreter. So, I needed some common functions to both of them, but others are specific to each case. Compiler outputRegarding compiler output, I've originally decided to print all the code of a Having been working with Elm, I value good compiler messages and want to see them displayed when calling So, I've made a new switch ( Fennel
|
Instead of interpreting fennel code from within lua code, we now run the `fennel` interpreter. It was made possible by requiring the fennel library from `lib.lua` and passing it to `luar.fnl`.
Instead of requiring `fennel` module in `lib.lua`, it can be required directly in `luar.fnl`. This makes a better separation of concerns. See #5.
I've tried some simple things (don't have a lot of time currently) and it seems to work. Hopefully, I'll be able to come back to this in a week or so. |
I'm closing this issue by now because it seems there isn't enough demand for this feature. If you or someone else want reconsider it, please tell me. I won't delete the |
I forgot to mention that I live on Venus, and our week is about 1701 Earth days.. Sorry, since I've recently decided to fully move to Emacs, I had very little time with Kakoune since, and couldn't do more testing. |
Don't worry, @andreyorst! Even if you'd remained interested in such a feature, I still would wonder if it would be a good idea releasing it for just two potential users (you and me). And considering we can compile Fennel code to Lua ahead of time, perhaps it's just not necessary. |
Hey, @andreyorst ! I decided to revisit this issue and make a new implementation. I extracted the common functions to a separate module both Are you still interested in a |
Sure, will test this tomorrow!
|
Great! I still need to update the docs, but it works mostly the same as the |
It does seem that I don't have |
That's right: the last release (v2020.09.01) doesn't yet contain support for Fennel. So I'll probably hold the merge to |
I'm still interested in this, FWIW 🙂 |
Hi, @evanrelf ! Ok! Since demand is low and it would increase code size a bit, I was considering not integrating it. But I'm gonna do it soon. In the meanwhile, you can use the plugin in the |
I'd be interested in using Fennel as you use lua in
lua %{}
blocks. Fennel is a Lisp that compiles down to Lua, so perhaps it could be possible to make a wrapper that will use luar underneath. What do you think?The text was updated successfully, but these errors were encountered: