Closed shlomocarmeter closed 3 years ago
Your solution:
vim.g.esearch = {
regex = 1
textobj = 0
case = 'smart'
textobj = 0,
default_mappings = 0,
}
vim.cmd('let g:esearch.write_cb = {buf, bang -> buf.write(bang) && (!buf.existed && buf.bwipeout())}')
TLDR buf
is a buffer handle to work with them using OOP API and not to deal with commands that are much harder to use. bang
is true when :write!
is used. With :write
it's set to be false.
The problem is that neovim still cannot dump viml objects properly to work with them inside lua. E.g.
vim.g.esearch = {write_cb = function(buf, bang) print(vim.inspect(buf)) end}
outputs
{
bufnr = 3,
bwipeout = vim.NIL,
write = vim.NIL,
-- ...
}
you can see that all the methods are NIL at the moment. The first snippet with your solution is completely legit, but probably in later neovim versions viml and lua will work seamlessly and your code will look like:
vim.g.esearch = {
-- ...
write_cb = function(buf, bang) return buf:write(bang) and (not buf.existed and buf:wipeout()) end,
}
Thank you for taking the time to reply. Keep up the good work!
Hi, This is a great plugin, very nice work.
I'm using neovim (v0.6.0-dev+131-g2c60f7c99) with lua file config, I tried using example from README:
first tried:
But this gets an error after write confirm:
Error detected while processing function217_write_cmd[20]..esearch#writer#do[1]..376[33]..1[1]..282[1]..190_bufdo[6]..
284:
line 1:
E16: Invalid range: 5 buffer!
Then tried config in lua like so:
Still no go.
Can you provide an example on how to do this in lua? (Maybe update the README?)
Thanks