anuvyklack / pretty-fold.nvim

Foldtext customization in Neovim
Apache License 2.0
441 stars 21 forks source link

Neovim function curwin_col_off (FFI) does not exist anymore #38

Open cassava opened 5 months ago

cassava commented 5 months ago

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 commented 5 months ago

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
l00sed commented 3 months ago

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...?