irongit

A Neovim plugin enabling you to solve LeetCode problems.

feat: `config.home` using `plenary.path`

kawreauthored
parent e95fb70commit e07415192cd5d3258719f829f32b47db52249ce7Browse files

6 files changed, +13 -16

+1-1.neoconf.json
@@ -3,7 +3,7 @@
33 "library": {
44 "enabled": true,
55 "plugins": [
6- "nvim-notify",
6+ "nvim-treesitter/nvim-treesitter",
77 "telescope.nvim",
88 "plenary.nvim",
99 "nui.nvim"
+0-1README.md
@@ -149,7 +149,6 @@ To see full configuration types see [template.lua](./lua/leetcode/config/templat
149149
150150 Argument for [Neovim][neovim]
151151
152-
153152 ```lua
154153 ---@type string
155154 arg = "leetcode.nvim"
+1-1lua/leetcode/cache/cookie.lua
@@ -2,7 +2,7 @@ local path = require("plenary.path")
22 local log = require("leetcode.logger")
33
44 local config = require("leetcode.config")
5-local file = path:new(config.directory .. ".cookie")
5+local file = config.home:joinpath(".cookie")
66
77 ---@class lc.Cookie
88 ---@field csrftoken string
+3-5lua/leetcode/cache/problems.lua
@@ -1,11 +1,9 @@
1----@mod lc.cache.problems
2-
31 local log = require("leetcode.logger")
2+local path = require("plenary.path")
43
54 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+
97 local problems_api = require("leetcode.api.problems")
108
119 ---@class lc.Cache.Question
+6-6lua/leetcode/config/init.lua
@@ -3,8 +3,8 @@ local path = require("plenary.path")
33
44 ---@class lc.Settings
55 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,
88
99 name = "leetcode.nvim",
1010 domain = "https://leetcode.com",
@@ -24,12 +24,12 @@ config.auth = {}
2424 ---@param cfg lc.UserConfig Configurations to be merged.
2525 function config.apply(cfg)
2626 config.user = vim.tbl_deep_extend("force", config.default, cfg)
27+
2728 config.domain = "https://leetcode." .. config.user.domain
2829 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()
3333 end
3434
3535 return config
+2-2lua/leetcode/ui/question.lua
@@ -92,12 +92,12 @@ function question:init(problem)
9292 local q = api_question.by_title_slug(problem.title_slug)
9393 local lang = config.lang
9494
95- local dir = config.directory
9695 local ft = utils.filetype(lang)
9796 local fn = string.format("%s.%s.%s", q.frontend_id, q.title_slug, ft)
97+ local file = config.home:joinpath(fn)
9898
9999 local obj = setmetatable({
100- file = path:new(dir .. fn),
100+ file = file,
101101 q = q,
102102 lang = lang,
103103 }, self)