pretty-fold.nvim icon indicating copy to clipboard operation
pretty-fold.nvim copied to clipboard

Neovim function curwin_col_off (FFI) does not exist anymore

Open cassava opened this issue 1 year ago • 5 comments

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.

cassava avatar Mar 26 '24 09:03 cassava

Here's what a patch could look like:

diff --git a/lua/pretty-fold/init.lua b/lua/pretty-fold/init.lua
index b0b3788..09776ae 100644
--- a/lua/pretty-fold/init.lua
+++ b/lua/pretty-fold/init.lua
@@ -3,7 +3,11 @@ local wo = vim.wo
 local fn = vim.fn
 local api = vim.api
 
-ffi.cdef('int curwin_col_off(void);')
+ffi.cdef [[
+  typedef struct window_S win_T;
+  int win_col_off(win_T *wp);
+  extern win_T *curwin;
+]]
 
 local M = {
    foldtext = {}, -- Table with all 'foldtext' functions.
@@ -82,7 +86,7 @@ local function fold_text(config)
    ---The width of offset of a window, occupied by line number column,
    ---fold column and sign column.
    ---@type number
-   local gutter_width = ffi.C.curwin_col_off()
+   local gutter_width = ffi.C.win_col_off(ffi.C.curwin)
 
    local visible_win_width = api.nvim_win_get_width(0) - gutter_width
 

cassava avatar Mar 26 '24 09:03 cassava

I'm having this issue too with Nvim 0.10.0. The proposed fix seems to work for me. Is something other than free time holding back this PR from getting merged...?

l00sed avatar May 17 '24 13:05 l00sed

Hmm, the issue make neovim crash. Is there any plan merge #39 ? Thanks.

tan-wei avatar Nov 21 '24 06:11 tan-wei

FWIW, there are some forks out there with the fix implemented: https://github.com/bbjornstad/pretty-fold.nvim

Easy swap if you're using a plugin manager. Might switch back to anuvyklack, but seems like there's low bandwidth.

l00sed avatar Nov 21 '24 14:11 l00sed

@l00sed Great! I'll try to use the fork instead. Thanks.

tan-wei avatar Nov 22 '24 04:11 tan-wei