A Neovim plugin enabling you to solve LeetCode problems.
feat: `config.home` using `plenary.path`
6 files changed, +13 -16
+1-1.neoconf.json
| @@ -3,7 +3,7 @@ | ||
| 3 | 3 | "library": { |
| 4 | 4 | "enabled": true, |
| 5 | 5 | "plugins": [ |
| 6 | - "nvim-notify", | |
| 6 | + "nvim-treesitter/nvim-treesitter", | |
| 7 | 7 | "telescope.nvim", |
| 8 | 8 | "plenary.nvim", |
| 9 | 9 | "nui.nvim" |
+0-1README.md
| @@ -149,7 +149,6 @@ To see full configuration types see [template.lua](./lua/leetcode/config/templat | ||
| 149 | 149 | |
| 150 | 150 | Argument for [Neovim][neovim] |
| 151 | 151 | |
| 152 | - | |
| 153 | 152 | ```lua |
| 154 | 153 | ---@type string |
| 155 | 154 | arg = "leetcode.nvim" |
+1-1lua/leetcode/cache/cookie.lua
| @@ -2,7 +2,7 @@ local path = require("plenary.path") | ||
| 2 | 2 | local log = require("leetcode.logger") |
| 3 | 3 | |
| 4 | 4 | local config = require("leetcode.config") |
| 5 | -local file = path:new(config.directory .. ".cookie") | |
| 5 | +local file = config.home:joinpath(".cookie") | |
| 6 | 6 | |
| 7 | 7 | ---@class lc.Cookie |
| 8 | 8 | ---@field csrftoken string |
+3-5lua/leetcode/cache/problems.lua
| @@ -1,11 +1,9 @@ | ||
| 1 | ----@mod lc.cache.problems | |
| 2 | - | |
| 3 | 1 | local log = require("leetcode.logger") |
| 2 | +local path = require("plenary.path") | |
| 4 | 3 | |
| 5 | 4 | local config = require("leetcode.config") |
| 6 | -local path = require("plenary.path") | |
| 7 | -local file = path:new(config.directory .. ".problemlist") | |
| 8 | -local async = require("plenary.async") | |
| 5 | +local file = config.home:joinpath(".problemlist") | |
| 6 | + | |
| 9 | 7 | local problems_api = require("leetcode.api.problems") |
| 10 | 8 | |
| 11 | 9 | ---@class lc.Cache.Question |
+6-6lua/leetcode/config/init.lua
| @@ -3,8 +3,8 @@ local path = require("plenary.path") | ||
| 3 | 3 | |
| 4 | 4 | ---@class lc.Settings |
| 5 | 5 | local config = { |
| 6 | - default = template, ---@type lc.UserConfig Default User configuration | |
| 7 | - user = template, ---@type lc.UserConfig User configuration | |
| 6 | + default = template, | |
| 7 | + user = template, | |
| 8 | 8 | |
| 9 | 9 | name = "leetcode.nvim", |
| 10 | 10 | domain = "https://leetcode.com", |
| @@ -24,12 +24,12 @@ config.auth = {} | ||
| 24 | 24 | ---@param cfg lc.UserConfig Configurations to be merged. |
| 25 | 25 | function config.apply(cfg) |
| 26 | 26 | config.user = vim.tbl_deep_extend("force", config.default, cfg) |
| 27 | + | |
| 27 | 28 | config.domain = "https://leetcode." .. config.user.domain |
| 28 | 29 | config.lang = config.user.lang |
| 29 | - config.directory = config.user.directory | |
| 30 | - | |
| 31 | - config.file = path:new(config.directory) | |
| 32 | - config.file:mkdir() | |
| 30 | + ---@type Path | |
| 31 | + config.home = path:new(config.user.directory) | |
| 32 | + config.home:mkdir() | |
| 33 | 33 | end |
| 34 | 34 | |
| 35 | 35 | return config |
+2-2lua/leetcode/ui/question.lua
| @@ -92,12 +92,12 @@ function question:init(problem) | ||
| 92 | 92 | local q = api_question.by_title_slug(problem.title_slug) |
| 93 | 93 | local lang = config.lang |
| 94 | 94 | |
| 95 | - local dir = config.directory | |
| 96 | 95 | local ft = utils.filetype(lang) |
| 97 | 96 | local fn = string.format("%s.%s.%s", q.frontend_id, q.title_slug, ft) |
| 97 | + local file = config.home:joinpath(fn) | |
| 98 | 98 | |
| 99 | 99 | local obj = setmetatable({ |
| 100 | - file = path:new(dir .. fn), | |
| 100 | + file = file, | |
| 101 | 101 | q = q, |
| 102 | 102 | lang = lang, |
| 103 | 103 | }, self) |