feat(dirman)!: use pathlib for all dirman operations #1354
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pathlib.nvim
pathlib.nvim is a plugin which aims to decrease the difficulties of path management across mutliple OSs in neovim. The plugin API is heavily inspired by Python’s pathlib.path with tweaks to fit neovim usage.
You can search through the methods at: https://pysan3.github.io/pathlib.nvim/search.html
Commits
feat(spec): add pathlib.nvim to dependency
This adds pathlib.nvim to neorg's dependencies managed by
.github/workflows/luarocks.yml
andbuild.lua
.This commit also changes the typecheck CI to install all its dependencies defined by
*.rockspec
and use the packages for type annotations. Thanks to this change, types likePathlibPath
(defined in pathlib.nvim) also get annotated as a valid type and will be type-checked against.You will want to do this with local development as well.
After running these commands, packages will be installed under
./lua_modules
and those packages will be picked up bylua_ls
thanks to config in./.luarc.json
and you will get all nvim-cmp completions!docs(annotation): add better type annotations
Some updates to type annotations unrelated to dirman to make life easier with completions.
feat(dirman)!: use pathlib for all dirman operations
This commit contains all the breaking changes.
Some of the public facing APIs from dirman now returns a
PathlibPath
object instead of a string.Besides, there is a new function
dirman.utils.expand_pathlib
which is meant to replacedirman.utils.expand_path
.I have not deprecated
expand_path
just yet since it is used in some places in the codebase, and if I deprecate it now, typecheck CI will complain about it resulting to ❌.Some notable changes to modules other than dirman are as follows.
core.completion
dirman.get_norg_files
to get the list of norg files under the workspace.core.summary
path:len() == string.len(tostring(path))
so,string.len(ws_root)
won't work butws_root:len()
will callPath.len
orstring.len
based on the type but result in the same value.@vhyrro I know you are busy but please take your time to read through the changes.
I tried my best to keep the diff as little as possible so that the diff explains what pathlib brings to the table (especially this commit).
I hope after you read through the changes, you already have some good understanding of how to use the library.
Of course if you have any question, feel free to ping me anytime.
I labeled this PR with
feat!
flagging it as a breaking change (which will increase the major version). Do you agree?I think neorg v9 is labeled to bring the v3 parser so I'm not sure if introducing pathlib is worth making a major jump already.