From 06444754089517680da5cdef6008b920e30c1f30 Mon Sep 17 00:00:00 2001 From: ARCIII <88923299+ArmandoCIII@users.noreply.github.com> Date: Sun, 16 Feb 2025 03:10:32 -0500 Subject: [PATCH] utility/leetcode-nvim: init (#636) * utility/leetcode-nvim: init * utility/leetcode.nvim: Clean Code Cleaned code upon PR review comments --- configuration.nix | 1 + docs/release-notes/rl-0.8.md | 4 + modules/plugins/utility/default.nix | 1 + .../plugins/utility/leetcode-nvim/config.nix | 26 +++++++ .../plugins/utility/leetcode-nvim/default.nix | 6 ++ .../utility/leetcode-nvim/leetcode-nvim.nix | 74 +++++++++++++++++++ npins/sources.json | 12 +++ 7 files changed, 124 insertions(+) create mode 100644 modules/plugins/utility/leetcode-nvim/config.nix create mode 100644 modules/plugins/utility/leetcode-nvim/default.nix create mode 100644 modules/plugins/utility/leetcode-nvim/leetcode-nvim.nix diff --git a/configuration.nix b/configuration.nix index 15138a2b..c7b0f288 100644 --- a/configuration.nix +++ b/configuration.nix @@ -177,6 +177,7 @@ isMaximal: { surround.enable = isMaximal; diffview-nvim.enable = true; yanky-nvim.enable = false; + leetcode-nvim.enable = isMaximal; motion = { hop.enable = true; leap.enable = true; diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index c9b4892a..621e976f 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -143,8 +143,12 @@ [ARCIII](https://github.com/ArmandoCIII): +[leetcode.nvim]: https://github.com/kawre/leetcode.nvim + - Add `vim.languages.zig.dap` support through pkgs.lldb dap adapter. Code Inspiration from `vim.languages.clang.dap` implementation. +- Add [leetcode.nvim] plugin under `vim.utility.leetcode-nvim`. + [nezia1](https://github.com/nezia1) diff --git a/modules/plugins/utility/default.nix b/modules/plugins/utility/default.nix index 65ef8680..372a4f53 100644 --- a/modules/plugins/utility/default.nix +++ b/modules/plugins/utility/default.nix @@ -15,5 +15,6 @@ ./telescope ./wakatime ./yanky-nvim + ./leetcode-nvim ]; } diff --git a/modules/plugins/utility/leetcode-nvim/config.nix b/modules/plugins/utility/leetcode-nvim/config.nix new file mode 100644 index 00000000..be002727 --- /dev/null +++ b/modules/plugins/utility/leetcode-nvim/config.nix @@ -0,0 +1,26 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + + cfg = config.vim.utility.leetcode-nvim; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = [ + "leetcode-nvim" + "plenary-nvim" + "fzf-lua" + "nui-nvim" + ]; + + lazy.plugins.leetcode-nvim = { + package = "leetcode-nvim"; + setupModule = "leetcode"; + inherit (cfg) setupOpts; + }; + }; + }; +} diff --git a/modules/plugins/utility/leetcode-nvim/default.nix b/modules/plugins/utility/leetcode-nvim/default.nix new file mode 100644 index 00000000..4dffd9f8 --- /dev/null +++ b/modules/plugins/utility/leetcode-nvim/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./leetcode-nvim.nix + ./config.nix + ]; +} diff --git a/modules/plugins/utility/leetcode-nvim/leetcode-nvim.nix b/modules/plugins/utility/leetcode-nvim/leetcode-nvim.nix new file mode 100644 index 00000000..f71da02a --- /dev/null +++ b/modules/plugins/utility/leetcode-nvim/leetcode-nvim.nix @@ -0,0 +1,74 @@ +{lib, ...}: let + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) enum str bool; + inherit (lib.generators) mkLuaInline; + inherit (lib.nvim.types) mkPluginSetupOption luaInline; +in { + options.vim.utility = { + leetcode-nvim = { + enable = mkEnableOption "complementary neovim plugin for leetcode.nvim"; + + setupOpts = mkPluginSetupOption "leetcode-nvim" { + logging = mkEnableOption "logging for leetcode.nvim status notifications." // {default = true;}; + image_support = mkEnableOption "question description images using image.nvim (image-nvim must be enabled)."; + + lang = mkOption { + type = enum [ + "cpp" + "java" + "python" + "python3" + "c" + "csharp" + "javascript" + "typescript" + "php" + "swift" + "kotlin" + "dart" + "golang" + "ruby" + "scala" + "rust" + "racket" + "erlang" + "elixir" + "bash" + ]; + default = "python3"; + description = "Language to start your session with"; + }; + + arg = mkOption { + type = str; + default = "leetcode.nvim"; + description = "Argument for Neovim"; + }; + + cn = { + enabled = mkEnableOption "leetcode.cn instead of leetcode.com"; + translator = mkEnableOption "translator" // {default = true;}; + translate_problems = mkEnableOption "translation for problem questions" // {default = true;}; + }; + + storage = { + home = mkOption { + type = luaInline; + default = mkLuaInline "vim.fn.stdpath(\"data\") .. \"/leetcode\""; + description = "Home storage directory"; + }; + + cache = mkOption { + type = luaInline; + default = mkLuaInline "vim.fn.stdpath(\"cache\") .. \"/leetcode\""; + description = "Cache storage directory"; + }; + }; + + plugins = { + non_standalone = mkEnableOption "leetcode.nvim in a non-standalone mode"; + }; + }; + }; + }; +} diff --git a/npins/sources.json b/npins/sources.json index 82eb60d4..d6fb562f 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -567,6 +567,18 @@ "url": "https://github.com/ggandor/leap.nvim/archive/c6bfb191f1161fbabace1f36f578a20ac6c7642c.tar.gz", "hash": "1dmy45czi3irjd5qb74yamjam4d1lvqsgfxgh4vaj740b19gyl1w" }, + "leetcode-nvim": { + "type": "Git", + "repository": { + "type": "GitHub", + "owner": "kawre", + "repo": "leetcode.nvim" + }, + "branch": "master", + "revision": "db7e1cd6b9191b34b4c1f2f96e4e3949cde9f951", + "url": "https://github.com/kawre/leetcode.nvim/archive/db7e1cd6b9191b34b4c1f2f96e4e3949cde9f951.tar.gz", + "hash": "1d3lb7625b2qdzqm74mzrac66rxqc0qgjd3mb37l4v8wqyiyv6pp" + }, "lsp-lines": { "type": "Git", "repository": {