Skip to content

Commit

Permalink
Use Lua function directly for the opfunc
Browse files Browse the repository at this point in the history
  • Loading branch information
Olical committed Feb 15, 2025
1 parent 2939310 commit 2ff8013
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 35 deletions.
10 changes: 2 additions & 8 deletions fnl/conjure/mapping.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@
(M.buf
:EvalMotion (cfg :eval_motion)
(fn []
(set vim.o.opfunc :ConjureEvalMotionOpFunc)
(set _G._conjure_opfunc (fn [...] (eval.selection ...)))
(set vim.o.opfunc "v:lua._conjure_opfunc")

;; Doesn't work unless we schedule it :( this might break some things.
(client.schedule #(vim.api.nvim_feedkeys "g@" :m false)))
Expand Down Expand Up @@ -301,13 +302,6 @@
"\\k\\+$"))))
(eval.completions-sync base)))

;; TOOD Maybe we don't need this now we can pass fn refs?
(vim.api.nvim_command
(->> ["function! ConjureEvalMotionOpFunc(kind)"
"call luaeval(\"require('conjure.eval')['selection'](_A)\", a:kind)"
"endfunction"]
(str.join "\n")))

(vim.api.nvim_command
(->> ["function! ConjureOmnifunc(findstart, base)"
"return luaeval(\"require('conjure.mapping')['omnifunc'](_A[1] == 1, _A[2])\", [a:findstart, a:base])"
Expand Down
57 changes: 30 additions & 27 deletions lua/conjure/mapping.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2ff8013

Please sign in to comment.