Skip to content

Commit b1909e6

Browse files
authored
feat(recipes): add additional information about rooter
1 parent 3462cb0 commit b1909e6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/content/docs/recipes/rooter.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,31 @@ return {
4343
},
4444
}
4545
```
46+
47+
## What is a "Rooter"?
48+
49+
A rooter automatically changes Neovim's working directory based on the context of your current file. Instead of staying in the directory where you launched Neovim, it can detect and switch to the root of your project. This concept has been popular in the Vim ecosystem for many years, with plugins like [vim-rooter](https://github.com/airblade/vim-rooter) being among the first implementations.
50+
Why Use a Rooter?
51+
52+
### The working directory in Neovim affects many operations:
53+
54+
- **File searching**: Tools like Telescope will search relative to your working directory
55+
- **Command execution**: Shell commands run from Neovim use the working directory as their context
56+
- **Project navigation**: Moving between files is easier when your working directory is at the project root
57+
58+
### Without a rooter, you might encounter these scenarios:
59+
60+
- Opening a file from a deeply nested directory makes it difficult to search for other project files
61+
- Moving between files in different parts of a project changes your context unpredictably
62+
- Running commands against your project requires manually changing directories
63+
64+
## Rooter vs. autochdir
65+
66+
Neovim has a built-in autochdir option that automatically changes the working directory to match the current file's directory. However, this is rarely ideal for project work, since `autochdir` always sets the directory to the file's immediate parent directory. But a rooter intelligently finds the project root, which is typically several levels up from individual files.
67+
68+
## Practical Use Cases:
69+
70+
- **Cross-project navigation**: When opening files from different projects, the rooter ensures your working context switches appropriately
71+
- **Telescope optimization**: Limits searches to the relevant project rather than including unrelated files
72+
- **Consistent command context**: Shell commands and LSP operations work against the proper project root
73+
- **Improved file navigation**: Makes it easier to navigate between related files in a project

0 commit comments

Comments
 (0)