utility/leetcode-nvim: init (#636)

* utility/leetcode-nvim: init

* utility/leetcode.nvim: Clean Code

Cleaned code upon PR review comments
This commit is contained in:
ARCIII 2025-02-16 03:10:32 -05:00 committed by GitHub
commit 0644475408
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 124 additions and 0 deletions

View file

@ -15,5 +15,6 @@
./telescope
./wakatime
./yanky-nvim
./leetcode-nvim
];
}

View file

@ -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;
};
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./leetcode-nvim.nix
./config.nix
];
}

View file

@ -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";
};
};
};
};
}