Skip to content

Commit

Permalink
feat: ignore typos in config files
Browse files Browse the repository at this point in the history
resolves #47
  • Loading branch information
tekumara committed Mar 26, 2024
1 parent 41403eb commit 1841b4c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/typos-lsp/src/typos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ impl Instance<'_> {
engine.init_dir(path)?;
let walk_policy = engine.walk(path);

// add any explicit excludes
let mut ignores = OverrideBuilder::new(path);
// always ignore the config files like typos cli does
for f in typos_cli::config::SUPPORTED_FILE_NAMES {
ignores.add(&format!("!{}", f))?;
}

// add any explicit excludes
for pattern in walk_policy.extend_exclude.iter() {
ignores.add(&format!("!{}", pattern))?;
}
Expand Down
15 changes: 15 additions & 0 deletions crates/typos-lsp/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,21 @@ async fn test_position_with_unicode_text() {
);
}

#[test_log::test(tokio::test)]
async fn test_ignore_typos_in_config_files() {
let term = Url::from_str("file:///C%3A/.typos.toml").unwrap();

let did_open = &did_open_with("apropriate", Some(&term));

let mut server = TestServer::new();
let _ = server.request(&initialize_with(None, None)).await;

similar_asserts::assert_eq!(
server.request(&did_open).await,
publish_diagnostics_with(&[], Some(&term))
);
}

fn initialize() -> String {
initialize_with(None, None)
}
Expand Down

0 comments on commit 1841b4c

Please sign in to comment.