irongit

A Neovim plugin enabling you to solve LeetCode problems.

56 commits
Clone โ–พ
HTTPS
SSH
CLI
README.md

leetcode.nvim

๐Ÿ”ฅ Solve LeetCode problems within Neovim ๐Ÿ”ฅ

https://github.com/kawre/leetcode.nvim/assets/69250723/4647761c-609c-4b85-9396-535ae6baf3ba

โœจ Features

  • ๐Ÿ˜ Description formatting

  • ๐Ÿ“ˆ LeetCode statistics withing Neovim (Soon)

  • ๐Ÿ”€ Support for daily and random questions

  • ๐Ÿ’พ Caching

๐Ÿ“ฌ Requirements

๐Ÿ“ฆ Installation

{
    "kawre/leetcode.nvim",
    build = ":TSUpdate html",
    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",
    },
    opts = {
        -- configuration goes here
    },
    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>")

        require("leetcode").setup(opts)
    end,
}

๐Ÿ› ๏ธ Configuration

To see full configuration types see template.lua

โš™๏ธ default configuration

{
    ---@type lc.domain
    domain = "com", -- For now "com" is the only one supported

    ---@type string
    arg = "leetcode.nvim",

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

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

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

    ---@type boolean
    logging = true,

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

        result = {
            max_stdout_length = 200, ---@type integer
        },
    },

    description = {
        width = "40%", ---@type string | integer
    },
}

arg

Argument for Neovim

---@type string
arg = "leetcode.nvim"

See usage for more info

lang

Language to start your session with

---@type lc.lang
lang = "cpp"

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

domain

LeetCode domain.

---@type lc.domain
domain = "com" -- For now "com" is the only one supported

directory

Where to store leetcode.nvim data

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

logging

Whether to log leetcode.nvim status notifications

---@type boolean
logging = true

console

Console appearance

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

    result = {
        max_stdout_length = 200, ---@type integer
    },
}

description

Question description appearance

description = {
    width = "40%", ---@type string | integer
}

๐Ÿš€ Usage

This plugin is meant to be used within a fresh Neovim instance. Meaning that to lauch leetcode.nvim you have to pass arg as the first and only Neovim argument

nvim leetcode.nvim

Sign In

It is required to be signed-in to use leetcode.nvim

https://github.com/kawre/leetcode.nvim/assets/69250723/13594f1d-fff6-444b-b128-29c8cf83e97f

Working with multiple questions

When you open a new question, leetcode.nvim creates a new tabpage containing all of the contents related to it. To switch between these tabs, use LcQuestionTabs command

https://github.com/kawre/leetcode.nvim/assets/69250723/b4407308-8c81-4b24-97e6-476f2da3b727

๐Ÿ“‹ Commands

command triggers
LcMenu opens menu dashboard
LcConsole opens console for currently opened question
LcQuestionTabs opens a picker with all currently opened question tabs
LcLanguage opens a picker to select a language for the current session
LcDescriptionToggle toggle question description

โœ… Todo

  • CN version
  • SQL support
  • Statistics menu page
  • Docs