Closed p00f closed 4 years ago
btw which plugin did you use for previewing files (here https://asciinema.org/a/326401) (when you finished typing `aniseed.nvim at 00:12)
Hey, of course! So the .fnl language is Fennel lang which can be compiled to Lua and run within Neovim's LuaJIT instance. I use my own tool, Aniseed to do this and add the (module ...)
, defn
and def
syntax, since Lua's vanilla module system isn't very good for interactive evaluation of code as you change it.
Aniseed is what compiles my fnl
to lua
and loads it automatically, the line at the bottom of my init.vim
(lua require('aniseed.dotfiles')
) is what kicks all of this off. I think that's documented in Aniseed's readme or help text.
Once you have Aniseed you get access to the standard library I wrote as well as nvim.lua which is a dependency I bundle with Aniseed and expose for you.
set clipboard+=unnamedplus
would require (set nvim.o.clipboard (.. nvim.o.clipboard ",unnamedplus"))
I think, although you could write a nice function for this that used the aniseed.string
module to split nvim.o.clipboard
(a comma separated string), append your new item and then rejoin on ,
.
I'd just use ex
commands from Lua for this, so something like (nvim.ex.highlight "LineNr term=bold cterm=NONE ctermfg=DarkGrey...")
where nvim
is the aniseed.nvim
module (which is actually nvim.lua!). The same goes for the autocmd
, just lean on ex
commands for that. And the same for map
!
Any normal vim config thing you want to do can be done with aniseed.nvim
, which reads nicely when you alias it to nvim. Although it's worth mentioning you could do all of this without that module, just type
:h api` in nvim and you'll find all of the functions available to you from Lua or from a remote RPC plugin.
Finally, the thing that pops up at 0:12 is Conjure, which is written in Fennel with Aniseed! It's used to develop Clojure or Janet code outside of Neovim as well as Aniseed itself, it can be used to work on Aniseed/Fennel code live within Neovim.
You can always try out :ConjureSchool
if you install Conjure to learn all about evaluating Fennel within Neovim or even try the school without installing the plugin via my handy script :smile: https://github.com/Olical/conjure#try-without-installing
I hope this helps!
Thank you so much!
I think, although you could write a nice function for this that used the aniseed.string module to split nvim.o.clipboard (a comma separated string), append your new item and then rejoin on ,.
How would I do that? I have tried
(module dotfiles.module.core
{require {nvim aniseed.nvim
str aniseed.string}})
(set nvim.o.clipboard
(str.join
{(str.split nvim.o.clipboard ",")
"unnamedplus"}
",")
which compiles to this lua:
nvim.o.clipboard = str.join({[str.split(nvim.o.clipboard, ",")] = "unnamedplus"}, ",")
which means I definitely misunderstood the library and that doesn't work (ie vim doesn't use the intended clipboard)
(set nvim.o.clipboard (.. nvim.o.clipboard ",unnamedplus"))
gives E5108: Error executing lua /home/chinmay/.config/nvim/lua/dotfiles/module/core.lua:37: E474: Invalid argument
where line 37 of core.lua
is
nvim.o.clipboard = (nvim.o.clipboard .. ",unnamedplus")
For the second example, that works totally fine for me, so I'm assuming nvim.o.clipboard
is nil
at the time of eval? Since you can't append a string to nil
you'd have to check if nvim.o.clipboard
was set before attempting to append to it. The split/join approach doesn't have this problem since my library functions handle nil gracefully a la Clojure.
For the use of string split and join:
(set nvim.o.clipboard (str.join "," (a.concat (str.split nvim.o.clipboard ",") ["unnamedplus"])))
Should do the trick! (you can use square braces for lists)
Your issue there is that you're ending up with nested lists like [[...] ...]
when you want one level of list items like [...]
which we can use concat
to append one list to another in a non-mutating way. The other function you can use is (table.append my-table :some-item)
which is built into Lua.
Thanks! Are these questions better suited in the aniseed repo?
I have another one - there's a neovim gui called goneovim which defines g:gonvim_running
as 1
on startup and i want to check that and do some stuff. I have already tried these:
1) aniseed's nil?
(if (not (nil? (nvim.g.gonvim_running)))
nvim.ex.highlight :MsgSeparator "guifg=#282a36")
2) fennel's if
(if (nvim.g.gonvim_running)
nvim.ex.highlight :MsgSeparator "guifg=#282a36")
3) fennel's when
(I think I'm using this one wrong https://fennel-lang.org/reference#if-conditional)
(when (not (nil? (nvim.g.gonvim_running)))?
(nvim.ex.highlight :MsgSeparator "guifg=#282a36"))
all three of which which give attempt to call field 'gonvim_running' (a nil value)
on startup. It being nil is kinda the point lol.
(I get this error in both terminal vim and the gonvim gui which is another problem because it should have been already defined in the gui case)
Hey, so that's because you're trying to execute the result of the expression nvim.g.gonvim_running
as a function by wrapping it in parens. I think all you need to do is delete the parens around (nvim.g.gonvim_running)
and it should be fine. And potentially, yes, these questions are definitely Aniseed / Fennel related :slightly_smiling_face: if you have more we could chat there in other issues. Or even in the fennel channel in the Conjure discord (https://conjure.fun/discord).
Hi! Sorry for the trouble, I know very little lisp from emacs configs and tree-sitter queries.
Your neovim config looks really clean, I want to have this too (I have only separated mine into
plugins.vim
which loads plugins,mappings.vim
anddefinitions.vim
which has all thelet g:x = y
stuff, this looks nowhere near as good as yours).1) Can you explain as to which files need to have
(I'm almost sure everything needs at least
nvim aniseed.nvim
.)2) I have gone through
core.fnl
but still need some basic vim to fennel, like how would you do:huh this one was simpler than i expectedset guifont=xyz:h12
set clipboard+=unnamedplus
set listchars=eol:↴,tab:<->,space:·
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
autocmd FileType dashboard set showtabline=0 | autocmd WinLeave <buffer> set showtabline=2
map
(as opposed tonoremap
)3) what does
util.fnl
do? can i/do i have to change it?