Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log syntax highlighting init errors #895

Merged
merged 1 commit into from
Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions helix-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ once_cell = "1.8"
arc-swap = "1"
regex = "1"

log = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
toml = "0.5"
Expand Down
4 changes: 3 additions & 1 deletion helix-core/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ impl LanguageConfiguration {
if highlights_query.is_empty() {
None
} else {
let language = get_language(&crate::RUNTIME_DIR, &self.language_id).ok()?;
let language = get_language(&crate::RUNTIME_DIR, &self.language_id)
.map_err(|e| log::info!("{}", e))
.ok()?;
let config = HighlightConfiguration::new(
language,
&highlights_query,
Expand Down
7 changes: 6 additions & 1 deletion helix-term/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> {
};

// Separate file config so we can include year, month and day in file logs
let file = std::fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(logpath)?;
let file_config = fern::Dispatch::new()
.format(|out, message, record| {
out.finish(format_args!(
Expand All @@ -26,7 +31,7 @@ fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> {
message
))
})
.chain(fern::log_file(logpath)?);
.chain(file);

base_config.chain(file_config).apply()?;

Expand Down
22 changes: 6 additions & 16 deletions helix-view/src/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
}
} else {
#[cfg(target_os = "windows")]
return Box::new(provider::WindowsProvider::new());
return Box::new(provider::WindowsProvider::default());

#[cfg(not(target_os = "windows"))]
return Box::new(provider::NopProvider::new());
Expand Down Expand Up @@ -145,15 +145,15 @@ mod provider {
use anyhow::{bail, Context as _, Result};
use std::borrow::Cow;

#[cfg(not(target_os = "windows"))]
#[derive(Debug)]
pub struct NopProvider {
buf: String,
primary_buf: String,
}

#[cfg(not(target_os = "windows"))]
impl NopProvider {
#[allow(dead_code)]
// Only dead_code on Windows.
pub fn new() -> Self {
Self {
buf: String::new(),
Expand All @@ -162,6 +162,7 @@ mod provider {
}
}

#[cfg(not(target_os = "windows"))]
impl ClipboardProvider for NopProvider {
fn name(&self) -> Cow<str> {
Cow::Borrowed("none")
Expand All @@ -186,19 +187,8 @@ mod provider {
}

#[cfg(target_os = "windows")]
#[derive(Debug)]
pub struct WindowsProvider {
selection_buf: String,
}

#[cfg(target_os = "windows")]
impl WindowsProvider {
pub fn new() -> Self {
Self {
selection_buf: String::new(),
}
}
}
#[derive(Default, Debug)]
pub struct WindowsProvider;

#[cfg(target_os = "windows")]
impl ClipboardProvider for WindowsProvider {
Expand Down
6 changes: 5 additions & 1 deletion helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,11 @@ impl Editor {
self.language_servers
.get(language)
.map_err(|e| {
log::error!("Failed to get LSP, {}, for `{}`", e, language.scope())
log::error!(
"Failed to initialize the LSP for `{}` {{ {} }}",
language.scope(),
e
)
})
.ok()
});
Expand Down