Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cassava opened this issue Mar 26, 2024 · 2 comments
Open

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

cassava opened this issue Mar 26, 2024 · 2 comments

Comments

@cassava
Copy link

cassava commented Mar 26, 2024

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
Copy link
Author

cassava commented Mar 26, 2024

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
Copy link

l00sed commented May 17, 2024

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

e-roux added a commit to e-roux/pretty-fold.nvim that referenced this issue May 23, 2024
bbjornstad added a commit to bbjornstad/pretty-fold.nvim that referenced this issue May 29, 2024
…ixes anuvyklack#38

As noted by @cassava, as of a recent version of this plugin, the
`curwin_col_off` function was removed, leaving us to fend for ourselves.
Luckily, @cassava also proposed a fix, the likes of which seems to work on my
machine and from the limited reports, other individuals' machines as well.

This commit simply implements the patch specified by @cassava as the solution to
issues related to `curwin_col_off` no longer existing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants