Skip to content

Commit 54315e3

Browse files
committed
disable lsp in integration tests
1 parent f7cab9b commit 54315e3

2 files changed

Lines changed: 21 additions & 24 deletions

File tree

helix-term/tests/test/auto_indent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ async fn auto_indent_c() -> anyhow::Result<()> {
77
files: vec![(PathBuf::from("foo.c"), Position::default())],
88
..Default::default()
99
},
10-
Config::default(),
10+
helpers::test_config(),
1111
helpers::test_syntax_conf(None),
1212
// switches to append mode?
1313
(

helix-term/tests/test/helpers.rs

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use std::{
88
use anyhow::bail;
99
use crossterm::event::{Event, KeyEvent};
1010
use helix_core::{diagnostic::Severity, test, Selection, Transaction};
11-
use helix_term::{application::Application, args::Args, config::Config};
12-
use helix_view::{doc, input::parse_macro, Editor};
11+
use helix_term::{application::Application, args::Args, config::Config, keymap::merge_keys};
12+
use helix_view::{doc, editor::LspConfig, input::parse_macro, Editor};
1313
use tempfile::NamedTempFile;
1414
use tokio_stream::wrappers::UnboundedReceiverStream;
1515

@@ -118,7 +118,7 @@ pub async fn test_key_sequence_with_input_text<T: Into<TestCase>>(
118118
let test_case = test_case.into();
119119
let mut app = match app {
120120
Some(app) => app,
121-
None => Application::new(Args::default(), Config::default(), test_syntax_conf(None))?,
121+
None => Application::new(Args::default(), test_config(), test_syntax_conf(None))?,
122122
};
123123

124124
let (view, doc) = helix_view::current!(app.editor);
@@ -143,27 +143,9 @@ pub async fn test_key_sequence_with_input_text<T: Into<TestCase>>(
143143

144144
/// Generates language configs that merge in overrides, like a user language
145145
/// config. The argument string must be a raw TOML document.
146-
///
147-
/// By default, language server configuration is dropped from the languages.toml
148-
/// document. If a language-server is necessary for a test, it must be explicitly
149-
/// added in `overrides`.
150146
pub fn test_syntax_conf(overrides: Option<String>) -> helix_core::syntax::Configuration {
151147
let mut lang = helix_loader::config::default_lang_config();
152148

153-
for lang_config in lang
154-
.as_table_mut()
155-
.expect("Expected languages.toml to be a table")
156-
.get_mut("language")
157-
.expect("Expected languages.toml to have \"language\" keys")
158-
.as_array_mut()
159-
.expect("Expected an array of language configurations")
160-
{
161-
lang_config
162-
.as_table_mut()
163-
.expect("Expected language config to be a TOML table")
164-
.remove("language-server");
165-
}
166-
167149
if let Some(overrides) = overrides {
168150
let override_toml = toml::from_str(&overrides).unwrap();
169151
lang = helix_loader::merge_toml_values(lang, override_toml, 3);
@@ -177,11 +159,12 @@ pub fn test_syntax_conf(overrides: Option<String>) -> helix_core::syntax::Config
177159
/// want to verify the resulting document and selection.
178160
pub async fn test_with_config<T: Into<TestCase>>(
179161
args: Args,
180-
config: Config,
162+
mut config: Config,
181163
syn_conf: helix_core::syntax::Configuration,
182164
test_case: T,
183165
) -> anyhow::Result<()> {
184166
let test_case = test_case.into();
167+
config = helix_term::keymap::merge_keys(config);
185168
let app = Application::new(args, config, syn_conf)?;
186169

187170
test_key_sequence_with_input_text(
@@ -205,7 +188,7 @@ pub async fn test_with_config<T: Into<TestCase>>(
205188
pub async fn test<T: Into<TestCase>>(test_case: T) -> anyhow::Result<()> {
206189
test_with_config(
207190
Args::default(),
208-
Config::default(),
191+
test_config(),
209192
test_syntax_conf(None),
210193
test_case,
211194
)
@@ -226,6 +209,20 @@ pub fn temp_file_with_contents<S: AsRef<str>>(
226209
Ok(temp_file)
227210
}
228211

212+
/// Generates a config with defaults more suitable for integration tests
213+
pub fn test_config() -> Config {
214+
merge_keys(Config {
215+
editor: helix_view::editor::Config {
216+
lsp: LspConfig {
217+
enable: false,
218+
..Default::default()
219+
},
220+
..Default::default()
221+
},
222+
..Default::default()
223+
})
224+
}
225+
229226
/// Replaces all LF chars with the system's appropriate line feed
230227
/// character, and if one doesn't exist already, appends the system's
231228
/// appropriate line ending to the end of a string.

0 commit comments

Comments
 (0)