Git Product home page Git Product logo

pretty-fold.nvim's Introduction

Yuriy Artemyev

I am terminal geek:) My dotfiles containes 30000 lines.
Also, I am a Neovim fan and create Neovim plugins I want to use myself!

Projects:

And several others plugins:

Anurag's GitHub stats

pretty-fold.nvim's People

Contributors

anuvyklack avatar danbills avatar debugloop avatar jaekyeom avatar n3wborn avatar tiagovla avatar wookayin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pretty-fold.nvim's Issues

show_preview throwing error

Screenshot 2022-01-17 at 23 23 05
Screenshot 2022-01-17 at 23 24 42

i'm using default configuration based on documentation, but throwing error, all border value i try to apply but nothing happen

issue with Neovim 0.10

Just upgraded Neovim to 0.10 and then folded a code section in a markdown file, and saw lots of error messages:

:messages
...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: dlsym(RTLD_DEFAULT, curwin_col_off): symbol not found
stack traceback:
^I[C]: in function '__index'
^I...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: in function <...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:69>
...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: dlsym(RTLD_DEFAULT, curwin_col_off): symbol not found
stack traceback:
^I[C]: in function '__index'
^I...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: in function <...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:69> functi
on: builtin#18 ...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: dlsym(RTLD_DEFAULT, curwin_col_off): symbol not found
stack traceback:
^I[C]: in function '__index'
^I...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: in function <...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:69>
...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: dlsym(RTLD_DEFAULT, curwin_col_off): symbol not found
stack traceback:
^I[C]: in function '__index'
^I...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: in function <...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:69> functi
on: builtin#18 ...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: dlsym(RTLD_DEFAULT, curwin_col_off): symbol not found
stack traceback:
^I[C]: in function '__index'
^I...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: in function <...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:69> functi
on: builtin#18 ...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: dlsym(RTLD_DEFAULT, curwin_col_off): symbol not found
stack traceback:
^I[C]: in function '__index'
^I...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: in function <...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:69>
...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: dlsym(RTLD_DEFAULT, curwin_col_off): symbol not found
stack traceback:
^I[C]: in function '__index'
^I...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: in function <...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:69> functi
on: builtin#18 ...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: dlsym(RTLD_DEFAULT, curwin_col_off): symbol not found
stack traceback:
^I[C]: in function '__index'
^I...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: in function <...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:69> functi
on: builtin#18 ...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: dlsym(RTLD_DEFAULT, curwin_col_off): symbol not found
stack traceback:
^I[C]: in function '__index'
^I...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: in function <...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:69> functi
on: builtin#18 ...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: dlsym(RTLD_DEFAULT, curwin_col_off): symbol not found
stack traceback:
^I[C]: in function '__index'
^I...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: in function <...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:69>
...ack/paqs/start/pretty-fold.nvim/lua/pretty-fold/init.lua:85: dlsym(RTLD_DEFAULT, curwin_col_off): symbol not found
stack traceback:
-- More --

dlsym(RTLD_DEFAULT, curwin_col_off): symbol not found

After some upgrades, I get an error "symbol not found" pointing to pretty-fold.nvim.
Could be a Nvim core bug?

foldtextresult 2 ...hare/nvim/lazy/pretty-fold.nvim/lua/pretty-fold/init.lua:85: dlsym(RTLD_DEFAULT, curwin_col_off): symbol not found
stack traceback:
^I[C]: in function '__index'
^I...hare/nvim/lazy/pretty-fold.nvim/lua/pretty-fold/init.lua:85: in function <...hare/nvim/lazy/pretty-fold.nvim/lua/pretty-fold/init.lua:69>
^I[C]: in function 'foldtextresult'
^I...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:263: in function 'refresh'
^I...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:120: in function 'debounced_refresh'
^I...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:144: in function 'debounced_refresh'
^I...are/nvim/lazy/indent-blankline.nvim/lua/ibl/autocmds.lua:26: in function <...are/nvim/lazy/indent-blankline.nvim/lua/ibl/autocmds.lua:25>
^I[C]: in function 'nvim_cmd'
^I...brew/Cellar/neovim/0.9.2/share/nvim/runtime/filetype.lua:25: in function <...brew/Cellar/neovim/0.9.2/share/nvim/runtime/filetype.lua:24>
^I[C]: in function 'nvim_buf_call'
^I...brew/Cellar/neovim/0.9.2/share/nvim/runtime/filetype.lua:24: in function <...brew/Cellar/neovim/0.9.2/share/nvim/runtime/filetype.lua:10>

Running:
MacOS Sonoma 14
Neovim 0.9.2
latest pretty-fold.nvim
healthchecks look good

EDIT: tried with an empty .setup() and I'm still getting the issue.

Not generating folds automatically

I installed it in my lazy config file as:

    { 'anuvyklack/pretty-fold.nvim', config = function() require('pretty-fold').setup() end }

It installs the plugin successfully.

But when I open a new nvim window in my codebase, traverse to my file, and try folding, I get:
E490: No Fold found

How do I go about fixing this?

Broken friendship with diffview plugin

Error

^I...ack/packer/opt/pretty-fold.nvim/lua/pretty-fold/init.lua:69: in function <...ack/packer/opt/pretty-fold.nvim/lua/pretty-fold/init.lua:61> function: builtin#18 ...ack/packer/opt/pretty-fold.nvim/lua/pretty-fold/init.lua:69: attempt to inde
x local 'config' (a nil value)

It happens with any config.

Screenshot

Screenshot 2022-01-07 at 12 47 02

Notes

Extra kudos for this plugin anyway.

References

Better matchup experience

Could it possible to fold HTML tag

<div>
  HTML tag
</div>

Like this:

<div>...</div>

Maybe correctly defined matchup patterns could do it, but I don't know how to.

FR: highlight 'content'

Great Plugin!

Is there a way to highlight the 'content'?
It'll make the function signature looks better

image

image

pretty-fold.preview: mapping breaks countable movement with h/l

As the title says basically. When the plugin is loaded one can't do 20l, 42h, or some such. I use counts for those movements occasionally and I stumbled upon this.

In case it helps, I've made mapping accept a count using:

function() for i=1,vim.v.count1 do
...
end end

Getting error `attempt to index local 'config' (a nil value)`

Hi, I have a specific setup when doing diff comparisons, and when doing diffs, they have a fold for the parts the are the same between the two splits.

I'm getting an error:

...d/.vim/plugged/pretty-fold.nvim/lua/pretty-fold/init.lua:76: attempt to index local 'config' (a nil value)
stack traceback:
^I...d/.vim/plugged/pretty-fold.nvim/lua/pretty-fold/init.lua:76: in function <...d/.vim/plugged/pretty-fold.nvim/lua/pretty-fold/init.lua:69> function: builtin#18 ...d/.vim/plugged/pretty-fold.nvim/lua/pretty-fold/init.lua:76: attempt to index local 'config' (a nil value
)
stack traceback:
^I...d/.vim/plugged/pretty-fold.nvim/lua/pretty-fold/init.lua:76: in function <...d/.vim/plugged/pretty-fold.nvim/lua/pretty-fold/init.lua:69> function: builtin#18 ...d/.vim/plugged/pretty-fold.nvim/lua/pretty-fold/init.lua:76: attempt to index local 'config' (a nil value
)
stack traceback:
^I...d/.vim/plugged/pretty-fold.nvim/lua/pretty-fold/init.lua:76: in function <...d/.vim/plugged/pretty-fold.nvim/lua/pretty-fold/init.lua:69> function: builtin#18 ...d/.vim/plugged/pretty-fold.nvim/lua/pretty-fold/init.lua:76: attempt to index local 'config' (a nil value
)
...

and it keeps repeating and repeating. Unfortunately, I'm not exactly sure under what circumstances I'm getting the error, but I know it's in the context of comparing 2 diff splits.

My setup is from the README:

Plug 'anuvyklack/pretty-fold.nvim'

And:

require('pretty-fold').setup{}
require('pretty-fold.preview').setup_keybinding()

Please tell me if there's any additional information I can provide

Toggle Preview Keybinding

Hi,
Is it possible to implement behaviour similar to vim.lsp.buf.hover()?
i.e. define ONE keybinding to enable the preview - and if a preview window is already active with the same keybinding pressed, that window becomes active (cursor goes into it). User can also move their cursor to exit the preview

Conflict with nvim-scrollbar

I am not sure who would be in charge of fixing this, but I have found a conflict between this plugin and petertriho/nvim-scrollbar.

Here is what it looks like:
2022-01-25_23-48_2
2022-01-25_23-48_1
2022-01-25_23-48

It is kind of hard to tell from the still pictures, but it is super glitch looking when scrolling, and most of the bar isn't even shown. I only have this issue where I use a lot of folds.

I will gladly move this to nvim-scrollbar if you see fit.

Preview key mappings

Hi! Thanks for a great plugin.

I've run into some issues with preview key mappings.

First, keymap cannot be disabled by setting key = nil, as it will be superseded by a default config. Even if I have the following config, it will result in the default h key being mapped to opening preview.

require('pretty-fold.preview').setup {
  key = nil,
}

In addition, the mapping key can be either h or l, but not both. I wanted to map both keys. The config could be improved by allowing two mapping keys (or any other keys in general):

require('pretty-fold.preview').setup {
  key = {'h', 'l'},
}

[Error] error messages pops up on entering nvim

I am getting this error message whenever entering my neovim

Error executing vim.schedule lua callback: ...k/packer/start/pretty-fold.nvim/lua/pretty-fold/util.lua:11: attempt to call field 'notify_once' (a nil value) stack traceback: ...k/packer/start/pretty-fold.nvim/lua/pretty-fold/util.lua:11: in function <...k/packer/start/pretty-fold.nv im/lua/pretty-fold/util.lua:10>

This should be solved by changing

vim.schedule(callback)

at line 11 in util.lua to

---Raise a warning message
---@param msg string
function M.warn(msg)
   vim.schedule_wrap(function()
      vim.notify_once('[pretty-fold.nvim] '..msg, vim.log.levels.WARN)
   end)
end

Since this way it defers callback until the Nvim API is safe to call.

How to get rid of the `fill_char`s in the foldtext before the `content`

Hello there,

Let's assume the following code snippet:
image

When i fold the function, the code looks like this
image

I would like to get rid of the red circled fill_chars

As far as I can tell, the way to go about this is by configuring fill_char = ' ' within the pretty-folds setup() function and then creating a right-side section which also generates the dots in between. Something like this:

local fold_text = function()
    local lines = vim.v.foldend - vim.v.foldstart + 1
    local padding = has_scrollbar() and ' ' or ''
    local n = vim.api.nvim_win_get_width(0)
         - vim.fn.strdisplaywidth(lines)
         - vim.fn.strdisplaywidth(padding)
         - vim.fn.strdiplaywidth(content) -- How do i get content???
         + 8) -- plus 8 because I have 8 fixed characters in my final string
    local fill_chars = string.rep('', n)
    return string.format('%s %d LINES %s', fill_chars, lines, padding)
end

require('pretty-fold').setup {
    sections = {
        left = { 'content' }, -- I want to have the length of this content in my custom function before
        right = { fold_text }, -- use my custom function
    },
    fill_char = ' ',
    add_close_pattern = true,
}

I'm aware I could skip using the content generated by the plugin and grab the text of the first line of the fold using vim.api.nvim_buf_get_lines(...). However, that would mean missing out on the cool substitutions like the close_pattern, etc.

Is there a way to determine the length of the content? Or perhaps a simpler approach to achieve my goal?

Thanks a lot!

[nvim noob] no idea how to set it up

I added it to Packer in my Packer init.lua.
Created a pretty-fold-config where I pasted the settings into an init.lua.
But I don't see any changes. Is this supposed to work with custom folds or it auto detects. Also how to toggle it?
Apologies if maybe asking the obvious but I'm a noob at nvim(and lua)

Option to always show preview of first line

This may be a ridiculous request, but if it's possible without major downsides there's probably a lot of people who would appreciate it.

As you almost certainly know, one of the current limitations of vim folds is the ability to syntax highlight the folded text. Some people, like me, would like to emulate the feature of other editors, where the class or function signature remains visible and highlighted when the body of the class/function is folded.

There's a couple of in-depth issues with screenshots and technical background and partial implementations in the neovim and treesitter trackers:

neovim/neovim#12649

nvim-treesitter/nvim-treesitter#390

I noticed while using your plugin that you appear to have most of the elements in place already to do a decent version of this. Though I'm not familiar enough with vim floating windows to know if what I'm requesting is possible or not.

Ideally, I'd like the preview to always show the first line, effectively hiding the actual fold, and stay visible and move in sync with the rest of the code, with a visual effect similar to this screenshot of Atom that was posted in the treesitter issue linked above:

98057074-63a48080-1e0f-11eb-8fc5-795e5421adc5

Default binding for `h` and `l` causes non-responsive `PackerSync`

Hi, it seems that the default keybinding for h and l (from pretty-fold.preview) causes the floating window for PackerSync (packer.nvim) to be non-responsive. j and k work fine however.

It seems like this causes an infinite loop in M.mapping.close_preview_open_fold(original), where original() causes this to be recursively called.

Neovim function curwin_col_off (FFI) does not exist anymore

In this commit it was removed.

The current code would need to be replaced with something like:

ffi.cdef [[typedef struct window_S win_T;
 int win_col_off(win_T *wp);
 extern win_T *curwin;
]]

function curwin_col_off()
  return ffi.C.win_col_off(ffi.C.curwin)
end

The function win_col_off does not appear to be new, so using this new approach should not cause problems for those on older versions of Neovim.

Can i change the filestype of the preview?

image
I use the plugin neorg, which automatically changes a certain syntax into a symbol and such. And in every .norg file it does it automatically. So i was wondering if i could change the filetype of thre preview to have those symbols shown. Something like this:
image

Plugin not effect

in function <...k/packer/start/pretty-fold.nvim/lua/pretty-fold/init.lua:59>  function: builtin#18 ...k/packer/start/pretty-fold.nvim/lua/pretty-f
old/init.lua:75: missing declaration for symbol 'curwin_col_off'

When use fold, I see this message in :messages, and fold method view as default of nvim, this plugin not effect

my nvim version is v0.6.0, install plugin by packer

Getting an error when pressing `h` on a fold

Hi, I installed the plugin using vim-plug, and I added the setup lines in my config:

require('pretty-fold').setup{}
require('pretty-fold.preview').setup_keybinding()

However, when I go on a fold and press h, I get the following error:

E5108: Error executing lua ...vim/plugged/pretty-fold.nvim/lua/pretty-fold/preview.lua:112: Vim(autocmd):E216: No such group or event:
ModeChanged <buffer> ++once lua _G.pretty_fold_preview[1].close()
stack traceback:
        [C]: in function 'cmd'
        ...vim/plugged/pretty-fold.nvim/lua/pretty-fold/preview.lua:112: in function 'show_preview'
        ...vim/plugged/pretty-fold.nvim/lua/pretty-fold/preview.lua:127: in function 'keymap_open_close'
        [string ":lua"]:1: in main chunk

I'm using neovim version 0.6.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.