Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kyoh86/climbdir.nvim
https://github.com/kyoh86/climbdir.nvim
neovim neovim-plugin nvim nvim-plugin
Last synced: about 19 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/kyoh86/climbdir.nvim
- Owner: kyoh86
- License: mit
- Created: 2022-05-04T14:49:17.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-30T04:32:44.000Z (5 months ago)
- Last Synced: 2024-11-16T18:34:18.933Z (2 days ago)
- Topics: neovim, neovim-plugin, nvim, nvim-plugin
- Language: Lua
- Size: 19.5 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# This is alpha. It may be dropped without notice
# climbdir.nvim
A neovim lib-plugin to climb directory to search project root marker.
## Functions
### `climb({start_path}, {marker}, {*opts})`
Open a file in background floatwin.
Parameters:
- `{start_path}`: a path starting climbing.
- `{marker}`: a function check if a path is matched.
They accept a path to check and return true if the path is matched.
You can use functions in "climbdir.marker" module.
See [Markers](#markers).- `{*opts}`: dictionary of options:
- `halt` (function) optional: a function checking if a path is to stop climbing.## Markers
### `has_directory({name})`
Get a marker to accept a directory has a directory with fixed name.
Parameters:
- `{name}` (string) A name of the directory as marker.
### `has_readable_file({name})`
Get a marker to accept a directory has a readable file with fixed name.
Parameters:
- `{name}` (string) A name of the file as marker.
### `has_writable_file({name})`
Get a marker to accept a directory has a writable file with fixed name.
Parameters:
- `{name}` (string) A name of the file as marker.
### `glob({pattern})`
Get a marker to accept a directory has files/directories in glob.
Parameters:
- `{pattern}` (string) A pattern to search as marker.
### `one_of({markers...})`
Get a marker to accepts in case of any marker accepts.
Parameters:
- `{markers...}` (function) marker.
### `all_of({markers...})`
Get a marker to accepts in case of all markers accept.
Parameters:
- `{markers...}` (function) marker.
## Examples
Climb to a directory having `deno.json` or `deps.ts` without
`package.json` nor `node_modules/` in subdirectories.```lua
local climbdir = require("climbdir")
local marker = require("climbdir.marker")
climbdir.climb(
"/tmp/foo/bar/baz",
marker.one_of(
marker.has_readable_file("deno.json"),
marker.has_readable_file("deps.ts"),
),
{
halt = marker.one_of(
marker.has_readable_file("package.json"),
marker.has_directory("node_modules"),
),
},
)
```## LICENSE
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg)](http://www.opensource.org/licenses/MIT)
This is distributed under the [MIT License](http://www.opensource.org/licenses/MIT).