Skip to content

Commit

Permalink
docs: how to get package.json parent dir #3506
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhas07 authored Dec 14, 2024
1 parent 4761665 commit 3cb6c05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions doc/lspconfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ below returns a function that takes as its argument the current buffer path.
containing a `.git` directory. >
root_dir = util.find_git_ancestor
- Locate the first parent dir containing a "node_modules" dir: >lua
vim.fs.find('node_modules', { path = root_dir, upward = true })[1]
vim.fs.dirname(vim.fs.find('node_modules', { path = root_dir, upward = true })[1])
<
If you have Nvim 0.10 or newer then >lua
vim.fs.root(root_dir, "node_modules")
Expand All @@ -308,7 +308,7 @@ below returns a function that takes as its argument the current buffer path.
be removed.

- Locate the first parent dir containing a "package.json" dir: >lua
vim.fs.find('package.json', { path = root_dir, upward = true })[1]
vim.fs.dirname(vim.fs.find('package.json', { path = root_dir, upward = true })[1])
<
If you have Nvim 0.10 or newer then >lua
vim.fs.root(root_dir, "package.json")
Expand Down
6 changes: 3 additions & 3 deletions lua/lspconfig/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,17 @@ function M.path.exists(filename)
return stat and stat.type or false
end

--- @deprecated use `vim.fs.find('.hg', { path = startpath, upward = true })[1]` instead
--- @deprecated use `vim.fs.dirname(vim.fs.find('.hg', { path = startpath, upward = true })[1])` instead
function M.find_mercurial_ancestor(startpath)
return vim.fs.dirname(vim.fs.find('.hg', { path = startpath, upward = true })[1])
end

--- @deprecated use `vim.fs.find('node_modules', { path = startpath, upward = true })[1]` instead
--- @deprecated use `vim.fs.dirname(vim.fs.find('node_modules', { path = startpath, upward = true })[1])` instead
function M.find_node_modules_ancestor(startpath)
return vim.fs.dirname(vim.fs.find('node_modules', { path = startpath, upward = true })[1])
end

--- @deprecated use `vim.fs.find('package.json', { path = startpath, upward = true })[1]` instead
--- @deprecated use `vim.fs.dirname(vim.fs.find('package.json', { path = startpath, upward = true })[1])` instead
function M.find_package_json_ancestor(startpath)
return vim.fs.dirname(vim.fs.find('package.json', { path = startpath, upward = true })[1])
end
Expand Down

0 comments on commit 3cb6c05

Please sign in to comment.