Skip to content

Commit c279f97

Browse files
committed
feat: auto-expand dir field paths with vim.fn.expand()
This matches lazy.nvim behavior where ~ is expanded to home directory. Also includes documentation improvements: - Reorganized README to move import examples to dedicated section - Changed "bells and whistles" to "frills" for clarity - Removed first-person language ("my personal config" -> "example config")
1 parent 6c40410 commit c279f97

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ As a thin layer, zpack does not provide:
159159
If you're a lazy.nvim user, see [Migrating from lazy.nvim](#migrating-from-lazynvim)
160160

161161
## Examples
162-
For more examples, refer to my personal config:
162+
For more examples, refer to example config:
163163
- [zpack installation and setup](https://github.com/zuqini/nvim/blob/main/init.lua)
164164
- [plugins directory structure](https://github.com/zuqini/nvim/tree/main/lua/plugins)
165165

@@ -366,7 +366,7 @@ return {
366366
-- Plugin source (provide exactly one)
367367
[1] = "user/repo", -- Plugin short name. Expands to https://github.com/{user/repo}
368368
src = "https://...", -- Custom git URL or local path
369-
dir = "/path/to/plugin", -- Local plugin directory (lazy.nvim compat, mapped to src)
369+
dir = "/path/to/plugin", -- Local plugin directory (lazy.nvim compat, ~ expanded, mapped to src)
370370
url = "https://...", -- Custom git URL (lazy.nvim compat, mapped to src)
371371

372372
-- Dependencies
@@ -454,7 +454,7 @@ The plugin data object passed to hooks and trigger functions:
454454
Most of your lazy.nvim plugin specs will work as-is with zpack. However, zpack follows `vim.pack` conventions over lazy.nvim conventions, and is missing a few advanced features:
455455
- **version pinning**: lazy.nvim's `version` field maps to zpack's `sem_version`. See [Version Pinning](#version-pinning-for-lazynvim-compatibility)
456456
- **dev mode**: Use `src = vim.fn.expand('~/projects/my_plugin.nvim')` for local development
457-
- **profiling**: Use `nvim --startuptime startuptime.log`. Also see my [Neovim Profiler script](https://gist.github.com/zuqini/35993710f81983fbfa6baca67bdb32ed)
457+
- **profiling**: Use `nvim --startuptime startuptime.log`. Also refer to example [Neovim Profiler script](https://gist.github.com/zuqini/35993710f81983fbfa6baca67bdb32ed)
458458

459459
## Acknowledgements
460460

doc/zpack.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ through zpack, please submit an issue or PR!
263263
==============================================================================
264264
6. EXAMPLES *zpack-examples*
265265

266-
For more examples, refer to my personal config:
266+
For more examples, refer to example config:
267267
- zpack installation and setup:
268268
https://github.com/zuqini/nvim/blob/main/init.lua
269269
- plugins directory structure:
@@ -502,7 +502,7 @@ parent's lazy trigger fires.
502502
-- Plugin source (provide exactly one)
503503
[1] = "user/repo", -- Short name (github.com/...)
504504
src = "https://...", -- Custom git URL or local path
505-
dir = "/path/to/plugin", -- Local path (lazy.nvim compat)
505+
dir = "/path/to/plugin", -- Local path (lazy.nvim compat, ~ expanded)
506506
url = "https://...", -- Git URL (lazy.nvim compat)
507507

508508
-- Dependencies
@@ -569,8 +569,9 @@ src (string, optional)
569569
*zpack-Spec.dir*
570570
dir (string, optional)
571571
Local plugin directory path. For lazy.nvim compatibility.
572-
Mapped to `src` internally. Provide exactly one of:
573-
[1], src, dir, or url.
572+
Paths are automatically expanded (e.g., `~` expands to home
573+
directory). Mapped to `src` internally. Provide exactly one
574+
of: [1], src, dir, or url.
574575

575576
*zpack-Spec.url*
576577
url (string, optional)

lua/zpack/import.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ local normalize_source = function(spec)
2727
elseif spec.url then
2828
return spec.url
2929
elseif spec.dir then
30-
return spec.dir
30+
return vim.fn.expand(spec.dir)
3131
else
3232
return nil, "spec must provide one of: [1], src, dir, or url"
3333
end

tests/setup_test.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,22 @@ return function()
184184

185185
helpers.cleanup_test_env()
186186
end)
187+
188+
helpers.test("dir field expands ~ to home directory", function()
189+
helpers.setup_test_env()
190+
local state = require('zpack.state')
191+
192+
require('zpack').setup({
193+
spec = {
194+
{ dir = '~/projects/my-plugin' },
195+
},
196+
defaults = { confirm = false },
197+
})
198+
199+
local expected_src = vim.fn.expand('~/projects/my-plugin')
200+
helpers.assert_not_nil(state.spec_registry[expected_src], "dir should expand ~ to home directory")
201+
202+
helpers.cleanup_test_env()
203+
end)
187204
end)
188205
end

0 commit comments

Comments
 (0)