Skip to content

Commit c9fd185

Browse files
authored
clarify autochdir and rooter difference
1 parent b1909e6 commit c9fd185

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/content/docs/recipes/rooter.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,27 @@ return {
4646

4747
## What is a "Rooter"?
4848

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?
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 the `autochdir` option, and with plugins like [vim-rooter](https://github.com/airblade/vim-rooter) being among the first implementations.
50+
51+
## Why Use a Rooter?
5152

5253
### The working directory in Neovim affects many operations:
5354

5455
- **File searching**: Tools like Telescope will search relative to your working directory
5556
- **Command execution**: Shell commands run from Neovim use the working directory as their context
5657
- **Project navigation**: Moving between files is easier when your working directory is at the project root
58+
- **LSP operations**: Many language servers work best when operating from the project root
5759

5860
### Without a rooter, you might encounter these scenarios:
5961

6062
- Opening a file from a deeply nested directory makes it difficult to search for other project files
6163
- Moving between files in different parts of a project changes your context unpredictably
6264
- Running commands against your project requires manually changing directories
65+
- Build tools and language servers might not function correctly if not at the project root
6366

6467
## Rooter vs. autochdir
6568

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.
69+
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 by applying more rules for detecting the root of the project.
6770

6871
## Practical Use Cases:
6972

0 commit comments

Comments
 (0)