Skip to content

Commit

Permalink
feat(ui): init fold logic (#2)
Browse files Browse the repository at this point in the history
- extract logic from nvim config
  • Loading branch information
snelling-a authored Apr 23, 2023
1 parent 323d5cd commit c3a246e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions lua/better-folds/folds.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local right = ""
local l = ""

--  [9ℓ]: text_from_the_first_line  󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼󰇼

local M = {}

function M.foldtext()
local foldstart, foldend = vim.v.foldstart, vim.v.foldend
local fold_length = foldend - foldstart + 1

local first_line = vim.fn.getline(foldstart)
local sanitized_first_line = string.gsub(first_line, "^%s*(.*)[{[]$", "%1")

return string.format("%s [%i%s]: %s %s ", right, fold_length, l, sanitized_first_line, right)
end

return M
2 changes: 1 addition & 1 deletion lua/better-folds/init.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local M = {}

function M.setup()
vim.notify("hello")
vim.opt.foldtext = 'v:lua.require("better-folds.folds").foldtext()'
end

return M

0 comments on commit c3a246e

Please sign in to comment.