diff --git a/src/lib.rs b/src/lib.rs index 5a17dac..486954a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,7 @@ use utils::{parse_str_color, IntoFont, IntoFontStyle}; use nvim_oxi as oxi; use oxi::{ - api::{self, opts::*, types::*, Buffer, Error}, + api::{self, opts::*, types::*, Error}, Dictionary, Function, }; use silicon::{ @@ -36,12 +36,14 @@ fn save_image(opts: Opts) -> Result<(), Error> { let code = get_lines(&opts)?; - let ft: oxi::String = Buffer::current().get_option("filetype")?; + // HACK: This allows us to avoid currently broken oxi APIs to get the filetype option. + // Instead we call into VimL and get the value that way -- super ghetto, but it works without + // any breaking changes from what I can tell. + let ft = oxi::api::exec("echo &filetype", true)?.ok_or_else(|| Error::Other(String::from("Unable to determine filetype!")))?; let syntax = ps .find_syntax_by_token( - ft.as_str() - .map_err(|e| Error::Other(format!("utf error: {e}")))?, + &ft ) .ok_or_else(|| Error::Other("Could not find syntax for filetype.".to_owned()))?; @@ -260,4 +262,4 @@ fn silicon() -> oxi::Result { ("capture", Function::from_fn(save_image)), ("setup", Function::from_fn(setup)), ])) -} +} \ No newline at end of file