1

I am using Neovim v0.9.5 and configured this editor using Lua.

I'm searching for a way of using a single caret down (▾) character for folds.

Here is what is currently used by Neovim by default.

** Heading title folded---------------------------------------------------------------------------------
** Another heading unfolded
   Some content

Here is what I want

** Heading title folded ▾
** Another heading unfolded
   Some content

Also, notice the space afte the d letter and the caret character.

What is the Lua code that I can append to my init.lua file in order to achieve this goal?

3
  • Do you still have something open in your question? How can we help you further? If one of the answers solves your problem maybe could accept it using the v button next to the arrow voting buttons. It let others know that it is worth reading and allow the question to rest :-) Jan 18 at 9:38
  • 1
    The answer did not seem to work as intended, but I need to create a reproduction of the issue in an isolated environment. I simply did not have the time to do that but this is planned for the week-end. Thank you for the follow up.
    – Amin NAIRI
    Jan 19 at 10:08
  • Thanks for the feedback. Take your time we will continue to help when it is further clarified :-) Jan 19 at 17:40

1 Answer 1

0

If VimScript I would do:

set fillchars+=fold:\ 

function! MyFoldText()
  let line = getline(v:foldstart)
  subistitute(line, '\s*$', '', 'g')
  let line = line . ' ▾'
  return line 
endfunction

set foldtext=MyFoldText()

Or in "pure" lua:

vim.opt.fillchars:append({fold = ' '})

function myfoldtext()
  local line = vim.fn.getline(vim.v.foldstart)
  return line .. ' ▾'
end

vim.o.foldtext = 'v:lua.myfoldtext()'

I you want this to apply to only some filetype then the code should be put in the corresponding filtype.lua file and use local options:

vim.opt_local.fillchars:append({fold = ' '})


function myfoldtext()
  local line = vim.fn.getline(vim.v.foldstart)
  return line .. ' ▾'
end

vim.opt_local.foldtext = 'v:lua.myfoldtext()'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.