• Stars
    star
    1,209
  • Rank 38,754 (Top 0.8 %)
  • Language
    Vim Script
  • License
    MIT License
  • Created over 14 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Changes Vim working directory to project root.

Rooter

Rooter changes the working directory to the project root when you open a file or directory.

The project root can be identified by:

  • being a known directory;
  • having a known directory or file;
  • being a subdirectory of a known directory.
  • being a direct subdirectory of a known directory

You can also exclude directories.

For a file or directory which doesn't have a root, Rooter can: do nothing; change to the file's directory (similar to autochdir); or change to your home directory.

Usage

By default you don't need to do anything: Rooter will change the working directory automatically and echo the new working directory.

You can turn this off (see below) and use the :Rooter command to invoke Rooter manually.

When Rooter changes the working directory it emits the autocmd user event RooterChDir.

Rooter will unset &autochdir if it's set.

Configuration

Which buffers trigger Rooter

By default all files and directories trigger Rooter. Configure a comma separated list of patterns to specify which files trigger. Include / to trigger on directories. For example:

" Everything (default)
let g:rooter_targets = '/,*'

" All files
let g:rooter_targets = '*'

" YAML files
let g:rooter_targets = '*.yml,*.yaml'

" Directories and YAML files
let g:rooter_targets = '/,*.yml,*.yaml'

Which buffer types trigger Rooter

Rooter only runs in buffer types where it makes sense to look for a root directory.

A normal file has an empty 'buftype'. Directory browsing plugins often set the 'buftype' to "nofile", "nowrite", or "acwrite". To stick to normal files:

let g:rooter_buftypes = ['']

How to identify a root directory

Set g:rooter_patterns to a list of identifiers. They are checked breadth-first as Rooter walks up the directory tree and the first match is used.

To specify the root is a certain directory, prefix it with =.

let g:rooter_patterns = ['=src']

To specify the root has a certain directory or file (which may be a glob), just give the name:

let g:rooter_patterns = ['.git', 'Makefile', '*.sln', 'build/env.sh']

To specify the root has a certain directory as an ancestor (useful for excluding directories), prefix it with ^:

let g:rooter_patterns = ['^fixtures']

To specify the root has a certain directory as its direct ancestor / parent (useful when you put working projects in a common directory), prefix it with >:

let g:rooter_patterns = ['>Latex']

To exclude a pattern, prefix it with !.

let g:rooter_patterns = ['!.git/worktrees', '!=extras', '!^fixtures', '!build/env.sh']

List your exclusions before the patterns you do want.

Non-project files

  • Don't change directory (default).

    let g:rooter_change_directory_for_non_project_files = ''
  • Change to file's directory (similar to autochdir).

    let g:rooter_change_directory_for_non_project_files = 'current'
  • Change to home directory.

    let g:rooter_change_directory_for_non_project_files = 'home'

Running automatically or manually

To toggle between automatic and manual behaviour, use :RooterToggle.

To make Rooter start in manual mode:

let g:rooter_manual_only = 1

Miscellaneous

By default vim-rooter uses :cd to change directory. To use :lcd or :tcd instead:

let g:rooter_cd_cmd = 'lcd'

To stop Rooter echoing the project directory:

let g:rooter_silent_chdir = 1

By default Rooter doesn't resolve symbolic links in the file or directory which triggers it. To do so:

let g:rooter_resolve_links = 1

Using root-finding functionality in other scripts

The public function FindRootDirectory() returns the absolute path to the root directory as a string, if a root directory is found, or an empty string otherwise.

More Repositories

1

vim-gitgutter

A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks.
Vim Script
8,327
star
2

chartjs-ror

[Not supported - see #53] Simplifies using Chart.js in Rails
Ruby
184
star
3

acts_as_enterprisey

Rails make life easy for us but -- and it's a big but -- we don't want it to look easy. ActsAsEnterprisey makes it look hard.
Ruby
75
star
4

stimulus-datepicker

Stimulus-powered accessible datepicker
JavaScript
60
star
5

dotvim

How I configure the one true text editor.
Vim Script
41
star
6

air_budd_form_builder

[Deprecated] A form builder that generates semantic HTML as advocated by Andy Budd in CSS Mastery.
Ruby
34
star
7

quo_vadis

Multifactor authentication for Rails (7 and 6).
Ruby
32
star
8

vim-matchquote

A Vim plugin to provide %-style motion for single / double quotation marks, backticks and pipe.
Vim Script
31
star
9

vim-localorie

A Vim plugin for easy look-up of translations for Rails i18n YAML keys.
Vim Script
29
star
10

voom

A simplest-thing-that-works Vim plugin manager. Use with Vim 8 or Pathogen.
Shell
28
star
11

css_dryer

[Deprecated] Please use https://github.com/neopoly/css_dryer instead.
Ruby
27
star
12

vim-system-escape

Aims to become the definitive reference for escaping commands for system()
21
star
13

dotfiles

How one rolls.
Shell
18
star
14

geo_tools

Easier latitudes and longitudes on forms (and validation in model) for Rails 2.3.
Ruby
14
star
15

bin

It's not rubbish.
Perl
13
star
16

mys3ql

Simple backup of your MySQL database onto Amazon S3.
Ruby
12
star
17

fyi

Find out what cron is doing.
Ruby
11
star
18

vim-interdental

Indent guides that span empty lines
Vim Script
9
star
19

headlessui-stimulus

Stimulus components for Headless UI
JavaScript
9
star
20

vim-accent

A Vim plugin for typing accented characters without remembering their pseudo versions.
Vim Script
8
star
21

git-stager

Easily stage and unstage files.
Ruby
8
star
22

tcs

Tailwind class sorter - sorts the classes in your HTML into Tailwind's recommended class order, without Prettier
Ruby
7
star
23

vim-helptab

Ensure Vim's help docs always open in their own, single tab.
Vim Script
7
star
24

template_form

Rails form builder using templates to define the HTML
Ruby
6
star
25

brocade

[Deprecated] Generates barcodes for Rails ActiveRecord models.
Ruby
5
star
26

vim-current-search-match

Highlights the current search match.
Vim Script
5
star
27

entitlement

Simple page titles in Rails 3 and 4.
Ruby
4
star
28

gem-versions

(Gem command plugin to) list all published versions of a gem.
Ruby
3
star
29

base_look_and_feel

Generates a basic, neat look and feel for a Rails app.
Ruby
3
star
30

vim-highline

A Vim plugin which lets you toggle a line highlight for any line
Vim Script
3
star
31

vim-tailwind

A Vim plugin to autocomplete Tailwind classes without LSP. Also looks up Tailwind classes' CSS properties.
Vim Script
3
star
32

vim-tag-closer

A Vim plugin to close HTML tags on demand.
Vim Script
2
star
33

acts_as_parent_of

Implements the parent model code from Advanced Rails Recipe 13.
Ruby
2
star
34

flippeur

Simple feature flipping.
Ruby
2
star
35

air_blade_tools

[DEPRECATED] Foreign key support in Rails 2.x migrations.
Ruby
2
star
36

jquery-rhythm

Fit images to the vertical baseline rhythm without distortion.
JavaScript
2
star
37

vim-contest

A runner for Vimscript tests.
Vim Script
2
star
38

right_aws

RightScale's RightAws (they don't seem to have a Git repository)
Ruby
2
star
39

vim-tcs

Integrates tcs (Tailwind class sorter) with Vim
Vim Script
2
star
40

respecta

Measures how well an abbreviation matches a string.
Ruby
1
star
41

label_definitions

An open source list of label dimensions.
Ruby
1
star
42

plugin_routing

Rails plugin which is a port of James Adam's RailsEngine routing extension.
Ruby
1
star
43

pubmed

A few hacky scripts to load PubMed baseline files into a database.
Ruby
1
star
44

sinter

Sinter checks files for syntax errors.
Shell
1
star
45

pdf-print

How to print a PDF at 100%
Ruby
1
star