Skip to content

Commit

Permalink
raise form
Browse files Browse the repository at this point in the history
  • Loading branch information
grierson committed Aug 15, 2023
1 parent 4d469f1 commit beed7cc
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 5 deletions.
11 changes: 11 additions & 0 deletions fnl/formedit/raise.fnl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(local find (require :formedit.find))
(local ts (require :vim.treesitter))

(fn form []
(let [form (find.form)
parent (form:parent)
text (ts.get_node_text form 0)
[start-row start-col end-row end-col] [(parent:range)]]
(vim.api.nvim_buf_set_text 0 start-row start-col end-row end-col [text])))

{: form}
16 changes: 16 additions & 0 deletions fnl/spec/raise_spec.fnl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(local {: describe : it : before_each} (require :plenary.busted))
(local h (require :spec.helper))
(local raise (require :formedit.raise))

(local keymap :<localleader>o)

(describe :raise
(fn []
(before_each (fn []
(set vim.g.maplocalleader keymap)
(vim.keymap.set :n keymap raise.form)))
(it :form
(fn []
(h.setup {:content "(1 (2))" :cursor [1 4]})
(h.feedkeys keymap)
(h.expect {:content "(2)" :cursor [1 2]})))))
6 changes: 4 additions & 2 deletions fnl/spec/wrap_spec.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
(fn []
(h.setup {:content "(1)" :cursor [1 0]})
(h.feedkeys keymap)
(h.expect {:content "( (1))" :cursor [1 1]})))
(h.expect {:content "( (1))" :cursor [1 0]})))
(it "sub form"
(fn []
(h.setup {:content "(1 (2))" :cursor [1 4]})
(h.feedkeys keymap)
(h.expect {:content "(1 ( (2)))" :cursor [1 4]})))))
(h.expect {:content "(1 ( (2)))" :cursor [1 3]})))))

(print :foo)
15 changes: 15 additions & 0 deletions lua/formedit/raise.lua

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

22 changes: 22 additions & 0 deletions lua/spec/raise_spec.lua

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

7 changes: 4 additions & 3 deletions lua/spec/wrap_spec.lua

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

0 comments on commit beed7cc

Please sign in to comment.