on master help sign in
log syntax highlighting init errors (#895)
commit0cb5e0b2caba61bbcf6f57ce58506882766d5eea authorKirawi <67773714+kirawi@users.noreply.github.com> dateSat 23 Oct 2021, 08:52 (5 years ago) parent0f886af
6 files changed+22−19
Cargo.lock+1 helix-core/Cargo.toml+1 helix-core/src/syntax.rs+3−1 helix-term/src/main.rs+6−1 helix-view/src/clipboard.rs+6−16 helix-view/src/editor.rs+5−1
Cargo.lock+1
@@ -363,6 +363,7 @@ dependencies = [
363363 "arc-swap",
364364 "etcetera",
365365 "helix-syntax",
366+ "log",
366367 "once_cell",
367368 "quickcheck",
368369 "regex",
helix-core/Cargo.toml+1
@@ -27,6 +27,7 @@ once_cell = "1.8"
2727arc-swap = "1"
2828regex = "1"
2929
30+log = "0.4"
3031serde = { version = "1.0", features = ["derive"] }
3132serde_json = "1.0"
3233toml = "0.5"
helix-core/src/syntax.rs+3−1
@@ -186,7 +186,9 @@ impl LanguageConfiguration {
186186 if highlights_query.is_empty() {
187187 None
188188 } else {
189− let language = get_language(&crate::RUNTIME_DIR, &self.language_id).ok()?;
189+ let language = get_language(&crate::RUNTIME_DIR, &self.language_id)
190+ .map_err(|e| log::info!("{}", e))
191+ .ok()?;
190192 let config = HighlightConfiguration::new(
191193 language,
192194 &highlights_query,
helix-term/src/main.rs+6−1
@@ -16,6 +16,11 @@ fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> {
1616 };
1717
1818 // Separate file config so we can include year, month and day in file logs
19+ let file = std::fs::OpenOptions::new()
20+ .write(true)
21+ .create(true)
22+ .truncate(true)
23+ .open(logpath)?;
1924 let file_config = fern::Dispatch::new()
2025 .format(|out, message, record| {
2126 out.finish(format_args!(
@@ -26,7 +31,7 @@ fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> {
2631 message
2732 ))
2833 })
29− .chain(fern::log_file(logpath)?);
34+ .chain(file);
3035
3136 base_config.chain(file_config).apply()?;
3237
helix-view/src/clipboard.rs+6−16
@@ -116,7 +116,7 @@ pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
116116 }
117117 } else {
118118 #[cfg(target_os = "windows")]
119− return Box::new(provider::WindowsProvider::new());
119+ return Box::new(provider::WindowsProvider::default());
120120
121121 #[cfg(not(target_os = "windows"))]
122122 return Box::new(provider::NopProvider::new());
@@ -145,15 +145,15 @@ mod provider {
145145 use anyhow::{bail, Context as _, Result};
146146 use std::borrow::Cow;
147147
148+ #[cfg(not(target_os = "windows"))]
148149 #[derive(Debug)]
149150 pub struct NopProvider {
150151 buf: String,
151152 primary_buf: String,
152153 }
153154
155+ #[cfg(not(target_os = "windows"))]
154156 impl NopProvider {
155− #[allow(dead_code)]
156− // Only dead_code on Windows.
157157 pub fn new() -> Self {
158158 Self {
159159 buf: String::new(),
@@ -162,6 +162,7 @@ mod provider {
162162 }
163163 }
164164
165+ #[cfg(not(target_os = "windows"))]
165166 impl ClipboardProvider for NopProvider {
166167 fn name(&self) -> Cow<str> {
167168 Cow::Borrowed("none")
@@ -186,19 +187,8 @@ mod provider {
186187 }
187188
188189 #[cfg(target_os = "windows")]
189− #[derive(Debug)]
190− pub struct WindowsProvider {
191− selection_buf: String,
192− }
193−
194− #[cfg(target_os = "windows")]
195− impl WindowsProvider {
196− pub fn new() -> Self {
197− Self {
198− selection_buf: String::new(),
199− }
200− }
201− }
190+ #[derive(Default, Debug)]
191+ pub struct WindowsProvider;
202192
203193 #[cfg(target_os = "windows")]
204194 impl ClipboardProvider for WindowsProvider {
helix-view/src/editor.rs+5−1
@@ -294,7 +294,11 @@ impl Editor {
294294 self.language_servers
295295 .get(language)
296296 .map_err(|e| {
297− log::error!("Failed to get LSP, {}, for `{}`", e, language.scope())
297+ log::error!(
298+ "Failed to initialize the LSP for `{}` {{ {} }}",
299+ language.scope(),
300+ e
301+ )
298302 })
299303 .ok()
300304 });