diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-03-09 23:46:22 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-03-09 23:46:22 +0900 |
| commit | 82184cdfa758fdb1193bd1a82de6fce236b7d174 (patch) | |
| tree | d273c4fd6f43b716d8c4d286a1da8373f4b93b9f /.config/nvim/lua/leaf/fold.lua | |
| parent | 73fa3647434b800e502231da81c3c5a1f2c35bb5 (diff) | |
| download | dotfiles-82184cdfa758fdb1193bd1a82de6fce236b7d174.tar.gz dotfiles-82184cdfa758fdb1193bd1a82de6fce236b7d174.tar.zst dotfiles-82184cdfa758fdb1193bd1a82de6fce236b7d174.zip | |
nvim: remove leaf
Diffstat (limited to '.config/nvim/lua/leaf/fold.lua')
| -rw-r--r-- | .config/nvim/lua/leaf/fold.lua | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/.config/nvim/lua/leaf/fold.lua b/.config/nvim/lua/leaf/fold.lua deleted file mode 100644 index 0221dda..0000000 --- a/.config/nvim/lua/leaf/fold.lua +++ /dev/null @@ -1,61 +0,0 @@ -local M = {} - - -local F = vim.fn -local V = vim.v - - -local function find_plain_string(haystack, needle, start) - return haystack:find(needle, start or 1, true) -end - - -function M.foldexpr() - local lnum = V.lnum - local current_line_indent = F.indent(lnum) - local task_level = math.floor(current_line_indent / F.shiftwidth()) - if lnum == F.line('$') then - return task_level - end - local next_line_indent = F.indent(lnum + 1) - if current_line_indent < next_line_indent then - return ('>%d'):format(task_level + 1) - else - return task_level - end -end - - -function M.foldtext() - local foldstart = V.foldstart - local foldend = V.foldend - local shiftwidth = F.shiftwidth() - local current_line_indent = F.indent(foldstart) - - local todo = 0 - local done = 0 - for i = foldstart + 1, foldend do - local line = F.getline(i) - local line_indent = F.indent(i) - if line_indent == current_line_indent + shiftwidth then - if find_plain_string(line, '[x] ') then - done = done + 1 - elseif find_plain_string(line, '[ ] ') then - todo = todo + 1 - elseif find_plain_string(line, '[-] ') then - done = done + 1 - end - end - end - - local progress - if done + todo == 0 then - progress = '...' - else - progress = (' [%d/%d]'):format(done, done + todo) - end - return F.getline(foldstart) .. progress -end - - -return M |
