on master help sign in
log syntax highlighting init errors (#895)
0cb5e0bKirawi
Cargo.lock+1
@@ -363,6 +363,7 @@ dependencies = [
363 "arc-swap",
363 "arc-swap",
364 "etcetera",
364 "etcetera",
365 "helix-syntax",
365 "helix-syntax",
366+ "log",
366 "once_cell",
367 "once_cell",
367 "quickcheck",
368 "quickcheck",
368 "regex",
369 "regex",
helix-core/Cargo.toml+1
@@ -27,6 +27,7 @@ once_cell = "1.8"
27arc-swap = "1"
27arc-swap = "1"
28regex = "1"
28regex = "1"
29
29
30+log = "0.4"
30serde = { version = "1.0", features = ["derive"] }
31serde = { version = "1.0", features = ["derive"] }
31serde_json = "1.0"
32serde_json = "1.0"
32toml = "0.5"
33toml = "0.5"
helix-core/src/syntax.rs+3−1
@@ -186,7 +186,9 @@ impl LanguageConfiguration {
186 if highlights_query.is_empty() {
186 if highlights_query.is_empty() {
187 None
187 None
188 } else {
188 } 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()?;
190 let config = HighlightConfiguration::new(
192 let config = HighlightConfiguration::new(
191 language,
193 language,
192 &highlights_query,
194 &highlights_query,
helix-term/src/main.rs+6−1
@@ -16,6 +16,11 @@ fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> {
16 };
16 };
17
17
18 // Separate file config so we can include year, month and day in file logs
18 // 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)?;
19 let file_config = fern::Dispatch::new()
24 let file_config = fern::Dispatch::new()
20 .format(|out, message, record| {
25 .format(|out, message, record| {
21 out.finish(format_args!(
26 out.finish(format_args!(
@@ -26,7 +31,7 @@ fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> {
26 message
31 message
27 ))
32 ))
28 })
33 })
29− .chain(fern::log_file(logpath)?);
34+ .chain(file);
30
35
31 base_config.chain(file_config).apply()?;
36 base_config.chain(file_config).apply()?;
32
37
helix-view/src/clipboard.rs+6−16
@@ -116,7 +116,7 @@ pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
116 }
116 }
117 } else {
117 } else {
118 #[cfg(target_os = "windows")]
118 #[cfg(target_os = "windows")]
119− return Box::new(provider::WindowsProvider::new());
119+ return Box::new(provider::WindowsProvider::default());
120
120
121 #[cfg(not(target_os = "windows"))]
121 #[cfg(not(target_os = "windows"))]
122 return Box::new(provider::NopProvider::new());
122 return Box::new(provider::NopProvider::new());
@@ -145,15 +145,15 @@ mod provider {
145 use anyhow::{bail, Context as _, Result};
145 use anyhow::{bail, Context as _, Result};
146 use std::borrow::Cow;
146 use std::borrow::Cow;
147
147
148+ #[cfg(not(target_os = "windows"))]
148 #[derive(Debug)]
149 #[derive(Debug)]
149 pub struct NopProvider {
150 pub struct NopProvider {
150 buf: String,
151 buf: String,
151 primary_buf: String,
152 primary_buf: String,
152 }
153 }
153
154
155+ #[cfg(not(target_os = "windows"))]
154 impl NopProvider {
156 impl NopProvider {
155− #[allow(dead_code)]
156− // Only dead_code on Windows.
157 pub fn new() -> Self {
157 pub fn new() -> Self {
158 Self {
158 Self {
159 buf: String::new(),
159 buf: String::new(),
@@ -162,6 +162,7 @@ mod provider {
162 }
162 }
163 }
163 }
164
164
165+ #[cfg(not(target_os = "windows"))]
165 impl ClipboardProvider for NopProvider {
166 impl ClipboardProvider for NopProvider {
166 fn name(&self) -> Cow<str> {
167 fn name(&self) -> Cow<str> {
167 Cow::Borrowed("none")
168 Cow::Borrowed("none")
@@ -186,19 +187,8 @@ mod provider {
186 }
187 }
187
188
188 #[cfg(target_os = "windows")]
189 #[cfg(target_os = "windows")]
189− #[derive(Debug)]
190+ #[derive(Default, Debug)]
190− pub struct WindowsProvider {
191+ 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− }
202
192
203 #[cfg(target_os = "windows")]
193 #[cfg(target_os = "windows")]
204 impl ClipboardProvider for WindowsProvider {
194 impl ClipboardProvider for WindowsProvider {
helix-view/src/editor.rs+5−1
@@ -294,7 +294,11 @@ impl Editor {
294 self.language_servers
294 self.language_servers
295 .get(language)
295 .get(language)
296 .map_err(|e| {
296 .map_err(|e| {
297+ log::error!(
298+ "Failed to initialize the LSP for `{}` {{ {} }}",
297− log::error!("Failed to get LSP, {}, for `{}`", e, language.scope())
299+ language.scope(),
300+ e
301+ )
298 })
302 })
299 .ok()
303 .ok()
300 });
304 });