Skip to content

[BUG]: Codebook does not seem to look in parent directories for project-specific config file #278

@noahkawaguchi

Description

@noahkawaguchi

Issue Description

Both as an LSP (in Helix) and running lint from the command line, Codebook seems to require that the config file is at codebook.toml (or the path configured with configPath in LSP options) rather than looking in parent directories.

If my understanding is correct, Helix provides a different root to LSPs for different file types, e.g. the directory with Cargo.toml for Rust files but the directory with .git for TOML files. While these roots are usually the same, it results in Codebook seeming to require multiple codebook.toml files in a monorepo where, for example, the Git root and the Cargo root are not the same.

This should work:

monorepo/
 ├── .git/
 ├── rust_project/
 │  ├── src/
 │  │  └── main.rs
 │  └── Cargo.toml
 └── codebook.toml

But this seems to be required (when used as an LSP):

monorepo/
 ├── .git/
 ├── rust_project/
 │  ├── src/
 │  │  └── main.rs
 │  ├── Cargo.toml
 │  └── codebook.toml  # For typos in `main.rs`
 └── codebook.toml     # For typos in `Cargo.toml`

In this case, no location of a manually combined codebook.toml file seems to be in effect in both main.rs and Cargo.toml. I reproduced similar behavior for Go, Python, and TypeScript.

A codebook.toml file completely above the Git root seems to be ignored for all file types.

Operating System

Linux (Ubuntu/Debian)

Editor

Helix

Codebook Version

0.3.40

Configuration

words = ["wurld"]

Steps to Reproduce

CLI steps:

echo 'words = ["wurld"]' > codebook.toml
cargo new hello
echo 'fn main() { println!("Hello wurld"); }' > hello/src/main.rs
codebook-lsp lint hello/src/main.rs # Passes
cd hello
codebook-lsp lint src/main.rs # Fails

Resultant directory structure for reference:

.
├── hello/
│  ├── .git/
│  ├── src/
│  │  └── main.rs
│  ├── target/
│  ├── .gitignore
│  ├── Cargo.lock
│  └── Cargo.toml
└── codebook.toml

LSP steps:

  1. Create the same structure and file content as above.
  2. Open main.rs in Helix. (The working directory when starting Helix doesn't matter.)
  3. Observe that "wurld" is marked as a typo even though it is an allowed word in a parent directory's codebook.toml.

Expected Behavior

Whether Codebook is given a root by Helix based on the file type or is simply invoked from the command line, it should find and use a config file present in a parent directory.

Actual Behavior

Codebook seems to only check one place for a config file relative to a root directory defined by the editor or the CLI's working directory.

Code Sample

fn main() { println!("Hello, wurld!"); }

Log Output

I enabled them according to the README, but could not figure out where the output should be. Sorry.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions