kawre / leetcode.nvim

A Neovim plugin enabling you to solve LeetCode problems.
MIT License
1.05k stars 46 forks source link

Error when running nvim leetcode.nvim #9

Closed VinnyT456 closed 11 months ago

VinnyT456 commented 11 months ago
Error executing vim.schedule lua callback: .../share/nvim/lazy/leetcode.nvim/lua/leetcode/api/auth.lua:9: attempt to index lo
cal 'res' (a nil value)
stack traceback:
        .../share/nvim/lazy/leetcode.nvim/lua/leetcode/api/auth.lua:9: in function 'update_cfg_auth'
        .../share/nvim/lazy/leetcode.nvim/lua/leetcode/api/auth.lua:53: in function 'cb'
        ...share/nvim/lazy/leetcode.nvim/lua/leetcode/api/utils.lua:83: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

I'm getting this error when I try to run leetcode.nvim.

return {
    "kawre/leetcode.nvim",
    build = ":TSUpdate html",
    dependencies = {
        "nvim-treesitter/nvim-treesitter",
        "nvim-telescope/telescope.nvim",
        "nvim-lua/plenary.nvim",
        "MunifTanjim/nui.nvim",

        "nvim-tree/nvim-web-devicons",
        "rcarriga/nvim-notify",
    },
    opts = {
        console = {
            open_on_runcode = true,
            size = {
                width = "100%", ---@type string | integer
                height = "95%", ---@type string | integer
            },
            dir = "row", ---@type "col" | "row"
        },
        lang = "python3",
        description = {
            width = "100%", ---@type string | integer
        }
    },
    config = function(_, opts)
        vim.keymap.set("n", "<leader>lq", "<cmd>LcQuestionTabs<cr>")
        vim.keymap.set("n", "<leader>lm", "<cmd>LcMenu<cr>")
        vim.keymap.set("n", "<leader>lc", "<cmd>LcConsole<cr>")
        vim.keymap.set("n", "<leader>ll", "<cmd>LcLanguage<cr>")
        vim.keymap.set("n", "<leader>ld", "<cmd>LcDescriptionToggle<cr>")
        vim.keymap.set("n", "<leader>lr", "<cmd>LcRun<cr>")
        vim.keymap.set("n", "<leader>ls", "<cmd>LcSubmit<cr>")
        require("leetcode").setup(opts)
    end,
}

Here is my setup.

kawre commented 11 months ago

Are you on the latest commit? 428b764. Use :Lazy log leetcode.nvim

VinnyT456 commented 11 months ago

Yes, I'm on the latest commit

leetcode.nvim 5.01ms 
        428b764 fix(auth): `user_fields` (2 hours ago)
        4a00ed3 docs: license (3 hours ago)
        e443c14 fix(cookie): require verified account (3 hours ago)
        3c6a7ff feat!: new cache format (4 hours ago)
        84d8cd2 fix: sql submission accepted (5 hours ago)
        d49f7a2 fix: improvements (5 hours ago)
        2efc794 feat: improved sql support (6 hours ago)
        51637c1 fix(result): improved compile error handler (21 hours ago)
kawre commented 11 months ago

Can you try removing .cookie and .problemlist inside leetcode.nvim home directory

VinnyT456 commented 11 months ago

In the lua/leetcode/cache folder right?

kawre commented 11 months ago

do :lua print(vim.fn.stdpath("data") .. "/leetcode/")

VinnyT456 commented 11 months ago

done but I don't have that folder in my ~/.local/share/nvim/

kawre commented 11 months ago

does it work now?

VinnyT456 commented 11 months ago
Screenshot 2023-10-11 at 4 58 34 PM
VinnyT456 commented 11 months ago

It just keeps on stopping at this screen with the error.

kawre commented 11 months ago

can you add branch = "dev" inside

return {
    "kawre/leetcode.nvim",
    build = ":TSUpdate html",
    dependencies = {
        "nvim-treesitter/nvim-treesitter",
        "nvim-telescope/telescope.nvim",
        "nvim-lua/plenary.nvim",
        "MunifTanjim/nui.nvim",

        "nvim-tree/nvim-web-devicons",
        "rcarriga/nvim-notify",
    },
    opts = {
        console = {
            open_on_runcode = true,
            size = {
                width = "100%", ---@type string | integer
                height = "95%", ---@type string | integer
            },
            dir = "row", ---@type "col" | "row"
        },
        lang = "python3",
        description = {
            width = "100%", ---@type string | integer
        }
    },
    config = function(_, opts)
        vim.keymap.set("n", "<leader>lq", "<cmd>LcQuestionTabs<cr>")
        vim.keymap.set("n", "<leader>lm", "<cmd>LcMenu<cr>")
        vim.keymap.set("n", "<leader>lc", "<cmd>LcConsole<cr>")
        vim.keymap.set("n", "<leader>ll", "<cmd>LcLanguage<cr>")
        vim.keymap.set("n", "<leader>ld", "<cmd>LcDescriptionToggle<cr>")
        vim.keymap.set("n", "<leader>lr", "<cmd>LcRun<cr>")
        vim.keymap.set("n", "<leader>ls", "<cmd>LcSubmit<cr>")
        require("leetcode").setup(opts)
    end,
}

and run :Lazy update leetcode.nvim

VinnyT456 commented 11 months ago

I managed to get in but for some reason there is only 1 question in the list for the problems

kawre commented 11 months ago

It's because of #8 . I would recommend to delete :lua print(vim.fn.stdpath("data") .. "/leetcode/") directory

VinnyT456 commented 11 months ago

Sorry but I deleted that directory but there is still only one question in the problems list.

kawre commented 11 months ago

Then go to Menu > Cache > Update and it should work

VinnyT456 commented 11 months ago

Still not working

kawre commented 11 months ago

It's actually leetcode having problems rn. I can't even enter their site

VinnyT456 commented 11 months ago

Ok, I will try again later and see if it works thank you for your help.

VinnyT456 commented 11 months ago

Leetcode is back but it's still not working after the Menu > Cache > Update`

Screenshot 2023-10-11 at 5 56 16 PM
kawre commented 11 months ago

do you get the problemlist cache updated notification?

VinnyT456 commented 11 months ago

yeah it gives me that notification

kawre commented 11 months ago

Idk, it might be a problem with lazynvim not actually loading the new version, because the issues you are getting were fixed a few commits ago. Can you play around with commands like Lazy sync, Lazy clean, Lazy update, Lazy build

kawre commented 11 months ago

also try deleting ~/.local/share/nvim/lazy/leetcode.nvim/

VinnyT456 commented 11 months ago

ok

kawre commented 11 months ago

Are you 10000% sure that you deleted the home directory file? you can also use lua print(require("leetcode.config").home:absolute()) after you entered into leetcode.nvim to see the home dir path

VinnyT456 commented 11 months ago

Yes I deleted the file that you said above and here is the output of the lua print(require("leetcode.config").home:absolute()) ~/.local/share/nvim/leetcode

kawre commented 11 months ago

If you have deleted ~/.local/share/nvim/leetcode and ~/.local/share/nvim/lazy/leetcode.nvim and you still get only one record then i can't really think of any solution right now. I will try to find one and let you know if i do find it

VinnyT456 commented 11 months ago

ok thank you for your time to help me.

BenjaminHor commented 11 months ago

I've also been having a similar issue regarding this error.

NVIM v0.9.2
Build type: Release
LuaJIT 2.1.0-beta3
Error executing vim.schedule lua callback: .../share/nvim/lazy/leetcode.nvim/lua/leetcode/api/auth.lua:9: attempt to index local 'res' (a nil value)
stack traceback:
        .../share/nvim/lazy/leetcode.nvim/lua/leetcode/api/auth.lua:9: in function 'update_cfg_auth'
        .../share/nvim/lazy/leetcode.nvim/lua/leetcode/api/auth.lua:53: in function 'cb'
        ...share/nvim/lazy/leetcode.nvim/lua/leetcode/api/utils.lua:83: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

I've had to revert back to commit 4d3bbce in order for the plugin to work again.

This is my config

return {
    "kawre/leetcode.nvim",
    build = ":TSUpdate html",
    -- enabled = false,
    dependencies = {
        "nvim-treesitter/nvim-treesitter",
        "nvim-telescope/telescope.nvim",
        "nvim-lua/plenary.nvim", -- required by telescope
        "MunifTanjim/nui.nvim",

        -- optional
        -- "nvim-tree/nvim-web-devicons",

        -- recommended
        -- "rcarriga/nvim-notify",
    },
    branch = "master",
    commit = "4d3bbce",
    opts = {
        -- configuration goes here
        domain = "com", -- For now "com" is the only one supported

        ---@type lc.lang
        lang = "python3",

        ---@type lc.sql_lang
        sql = "mysql",

        ---@type string
        directory = vim.fn.stdpath("data") .. "/leetcode/",

        ---@type boolean
        logging = true,

        console = {
            open_on_runcode = true,
            size = {
                width = "50%", ---@type string | integer
                height = "50%", ---@type string | integer
            },
            dir = "row", ---@type "col" | "row"
        },

        description = {
            width = "40%", ---@type string | integer
        },
        arg = "leetcode",
    },
    config = function(_, opts)
        vim.keymap.set("n", "<leader>lq", "<cmd>LcQuestionTabs<cr>")
        vim.keymap.set("n", "<leader>lm", "<cmd>LcMenu<cr>")
        vim.keymap.set("n", "<leader>lc", "<cmd>LcConsole<cr>")
        vim.keymap.set("n", "<leader>ll", "<cmd>LcLanguage<cr>")
        vim.keymap.set("n", "<leader>ld", "<cmd>LcDescriptionToggle<cr>")
        vim.keymap.set("n", "<leader>lr", "<cmd>LcRun<cr>")
        vim.keymap.set("n", "<leader>ls", "<cmd>LcSubmit<cr>")
        require("leetcode").setup(opts)
    end,
}
kawre commented 11 months ago

Reverted master branch to 51637c1. Let me know if it fixes your issues.

VinnyT456 commented 11 months ago

If you have deleted ~/.local/share/nvim/leetcode and ~/.local/share/nvim/lazy/leetcode.nvim and you still get only one record then i can't really think of any solution right now. I will try to find one and let you know if i do find it

I don't understand why but the questions managed to get updated today so I guess the problems got solved.