kawre / leetcode.nvim

A Neovim plugin enabling you to solve LeetCode problems.
MIT License
654 stars 34 forks source link

Error thrown on startup when Windows curl executable is called #106

Open simonavans opened 1 week ago

simonavans commented 1 week ago

On Windows machines, starting leetcode.nvim results in an error being thrown:

Error executing luv callback:
...a/Local/nvim-data/lazy/plenary.nvim/lua/plenary/curl.lua:300: post https://leetcode.com/graphql/ - curl error exit_code=2 stderr={ "curl: option --http2: the installed libcurl version doesn't support this", "curl: try 'curl --help' for more information" }
stack traceback:
        [C]: in function 'error'
    ...a/Local/nvim-data/lazy/plenary.nvim/lua/plenary/curl.lua:300: in function '_user_on_exit'
    ...ta/Local/nvim-data/lazy/plenary.nvim/lua/plenary/job.lua:241: in function '_shutdown'
    ...ta/Local/nvim-data/lazy/plenary.nvim/lua/plenary/job.lua:48: in function <...ta/Local/nvim-data/lazy/plenary.nvim/lua/plenary/job.lua:39>
        [C]: in function 'nvim_buf_set_name'
    ...ata/lazy/leetcode.nvim/lua/leetcode-ui/renderer/menu.lua:124: in function 'apply_options'
    ...ata/lazy/leetcode.nvim/lua/leetcode-ui/renderer/menu.lua:207: in function '_mount'
    ...ata/lazy/leetcode.nvim/lua/leetcode-ui/renderer/menu.lua:201: in function 'mount'
    ...Data/Local/nvim-data/lazy/leetcode.nvim/lua/leetcode.lua:64: in function 'start'
    ...Data/Local/nvim-data/lazy/leetcode.nvim/lua/leetcode.lua:92: in function <...Data/Local/nvim-data/lazy/leetcode.nvim/lua/leetcode.lua:91>

This is because the default curl on Windows does not support HTTP/2.

I have worked around this issue by installing curl via chocolatey (with HTTP/2). I then added its curl executable to path as an environment variable before the C:\Windows\system32 entry, so it overrides it. It's not a perfect solution though.

I suggest that users may choose which HTTP version to use for the requests. Or at least to have the problem mentioned in the documentation.