From b1909e6c2f37cb1cbfdad090659080c128bccc55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20=C5=BDdanov?= Date: Fri, 7 Mar 2025 17:24:42 +0200 Subject: [PATCH 1/4] feat(recipes): add additional information about rooter --- src/content/docs/recipes/rooter.mdx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/content/docs/recipes/rooter.mdx b/src/content/docs/recipes/rooter.mdx index b557721e1..e620a4501 100644 --- a/src/content/docs/recipes/rooter.mdx +++ b/src/content/docs/recipes/rooter.mdx @@ -43,3 +43,31 @@ return { }, } ``` + +## What is a "Rooter"? + +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. +Why Use a Rooter? + +### The working directory in Neovim affects many operations: + +- **File searching**: Tools like Telescope will search relative to your working directory +- **Command execution**: Shell commands run from Neovim use the working directory as their context +- **Project navigation**: Moving between files is easier when your working directory is at the project root + +### Without a rooter, you might encounter these scenarios: + +- Opening a file from a deeply nested directory makes it difficult to search for other project files +- Moving between files in different parts of a project changes your context unpredictably +- Running commands against your project requires manually changing directories + +## Rooter vs. autochdir + +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. + +## Practical Use Cases: + +- **Cross-project navigation**: When opening files from different projects, the rooter ensures your working context switches appropriately +- **Telescope optimization**: Limits searches to the relevant project rather than including unrelated files +- **Consistent command context**: Shell commands and LSP operations work against the proper project root +- **Improved file navigation**: Makes it easier to navigate between related files in a project From c9fd185f3fc6b4268152198b43ce42470b9ca490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20=C5=BDdanov?= Date: Fri, 7 Mar 2025 17:36:58 +0200 Subject: [PATCH 2/4] clarify autochdir and rooter difference --- src/content/docs/recipes/rooter.mdx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/content/docs/recipes/rooter.mdx b/src/content/docs/recipes/rooter.mdx index e620a4501..3ccd5e25a 100644 --- a/src/content/docs/recipes/rooter.mdx +++ b/src/content/docs/recipes/rooter.mdx @@ -46,24 +46,27 @@ return { ## What is a "Rooter"? -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. -Why Use a Rooter? +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. + +## Why Use a Rooter? ### The working directory in Neovim affects many operations: - **File searching**: Tools like Telescope will search relative to your working directory - **Command execution**: Shell commands run from Neovim use the working directory as their context - **Project navigation**: Moving between files is easier when your working directory is at the project root +- **LSP operations**: Many language servers work best when operating from the project root ### Without a rooter, you might encounter these scenarios: - Opening a file from a deeply nested directory makes it difficult to search for other project files - Moving between files in different parts of a project changes your context unpredictably - Running commands against your project requires manually changing directories +- Build tools and language servers might not function correctly if not at the project root ## Rooter vs. autochdir -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. +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. ## Practical Use Cases: From 545e8f0eb9442482ed4b6e4cd26bd6f1a8b556fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20=C5=BDdanov?= Date: Fri, 7 Mar 2025 17:42:37 +0200 Subject: [PATCH 3/4] Update rooter.mdx --- src/content/docs/recipes/rooter.mdx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/content/docs/recipes/rooter.mdx b/src/content/docs/recipes/rooter.mdx index 3ccd5e25a..a93f760a1 100644 --- a/src/content/docs/recipes/rooter.mdx +++ b/src/content/docs/recipes/rooter.mdx @@ -55,18 +55,16 @@ A rooter automatically changes Neovim's working directory based on the context o - **File searching**: Tools like Telescope will search relative to your working directory - **Command execution**: Shell commands run from Neovim use the working directory as their context - **Project navigation**: Moving between files is easier when your working directory is at the project root -- **LSP operations**: Many language servers work best when operating from the project root ### Without a rooter, you might encounter these scenarios: - Opening a file from a deeply nested directory makes it difficult to search for other project files - Moving between files in different parts of a project changes your context unpredictably - Running commands against your project requires manually changing directories -- Build tools and language servers might not function correctly if not at the project root ## Rooter vs. autochdir -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. +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. This feature aims to intelligently find the project root, which can be several levels up from individual files by applying more rules for detecting the root of the project. ## Practical Use Cases: From ae4db1be8214cd99adfdad4789c75a0b218a1b35 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Fri, 7 Mar 2025 11:16:49 -0500 Subject: [PATCH 4/4] Improve language since `autochdir` is a rooter --- src/content/docs/recipes/rooter.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/recipes/rooter.mdx b/src/content/docs/recipes/rooter.mdx index a93f760a1..aaa6bea43 100644 --- a/src/content/docs/recipes/rooter.mdx +++ b/src/content/docs/recipes/rooter.mdx @@ -62,7 +62,7 @@ A rooter automatically changes Neovim's working directory based on the context o - Moving between files in different parts of a project changes your context unpredictably - Running commands against your project requires manually changing directories -## Rooter vs. autochdir +## AstroRoot vs. `autochdir` 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. This feature aims to intelligently find the project root, which can be several levels up from individual files by applying more rules for detecting the root of the project.