aboutsummaryrefslogtreecommitdiff
path: root/neovim/.config/nvim/lua/dyamon/foldtext.lua
blob: 6d5858eebb697f4bf53022c765cf77cb1893b6dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
--- Personal lua config files for NeoVim.
--  Last Changed: 2019-01-27
--  Author: Federico Igne <git@federicoigne.com>
--  License: This file is placed in the public domain.

-- Override default `foldtext` with something like:
--
--    »···[42l]···Title··················································
--
local foldtext = function()
  local start = "»"
  local middots = "···"
  local foldstart = vim.v.foldstart
  local foldend = vim.v.foldend
  local lines = string.format("[%3dl]", foldend - foldstart + 1)
  local indent = middots:rep(vim.v.foldlevel)
  local title = vim.api.nvim_buf_get_lines(0, foldstart - 1, foldstart, false)[1]:gsub("^.*{{{%d+ ", "")
  return start .. middots .. lines .. indent .. title
end

return foldtext