Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: deprecate util.path.is_descendant #3524

Closed
wants to merge 1 commit into from

Conversation

dundargoc
Copy link
Member

Work on #2079.

@dundargoc dundargoc marked this pull request as ready for review December 22, 2024 16:54
@dundargoc dundargoc requested a review from glepnir as a code owner December 22, 2024 16:54
@dundargoc dundargoc marked this pull request as draft December 22, 2024 16:57
@@ -1,5 +1,9 @@
local util = require 'lspconfig.util'

local function is_descendant(root, path)
return vim.startswith(vim.fs.normalize(path), vim.fs.normalize(root))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't have an answer in vim.fs then we probably should wait until we do. Maybe it could be named vim.fs.has()

Copy link
Member Author

@dundargoc dundargoc Dec 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO something like vim.fs.relpath that returns the path relative to another path (similar to :~ in fnamemodify but generalized) would probably be more useful. I imagine it'd return nil in the case it isn't a descendant?

Actually, most uses of is_descendant in our configs could already be replaced by fnamemodify, it is only rust_analyzer that requires a generalized is_descendant. We could move this function to the rust_analyzer file and just use fnamemodify for the other?

Copy link
Member

@justinmk justinmk Dec 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could but it would be better to get stuff into vim.fs so that we can use it in the configs[1], instead of having to redo the configs again ...

[1] (for Phase 2 of #3494 , where we tag a final legacy release for Nvim 0.10 or older)

@dundargoc dundargoc force-pushed the refactor/is_descendant branch from e6865ea to 075429f Compare December 22, 2024 20:57
@dundargoc
Copy link
Member Author

Closing as some functionality is needed in core for this to be smooth.

@dundargoc dundargoc closed this Dec 22, 2024
@dundargoc dundargoc deleted the refactor/is_descendant branch December 22, 2024 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants