Skip to content

Commit

Permalink
fix wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
grierson committed Aug 15, 2023
1 parent beed7cc commit c914c41
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
15 changes: 5 additions & 10 deletions fnl/formedit/wrap.fnl
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
(local find (require :formedit.find))

(fn range [form]
(let [[start-row start-col end-row end-col] [(form:range)]]
[(+ start-row 1) start-col (+ end-row 1) end-col]))

(fn head []
(let [form (find.form)
insert-offset (. find.insert-offset (form:type))
[start-row start-col end-row end-col] (range form)]
(vim.api.nvim_win_set_cursor 0 [end-row end-col])
(vim.api.nvim_command "normal! i)")
(vim.api.nvim_win_set_cursor 0 [start-row start-col])
(vim.api.nvim_command "normal! i( ")
(vim.api.nvim_win_set_cursor 0 [start-row (+ start-col insert-offset)])
[start-row start-col end-row end-col] [(form:range)]]
(vim.api.nvim_buf_set_text 0 end-row end-col end-row end-col [")"])
(vim.api.nvim_buf_set_text 0 start-row start-col start-row start-col ["( "])
(vim.api.nvim_win_set_cursor 0
[(+ start-row 1) (+ start-col insert-offset)])
(vim.api.nvim_feedkeys :i :n true)))

{: head}
22 changes: 6 additions & 16 deletions lua/formedit/wrap.lua

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

0 comments on commit c914c41

Please sign in to comment.