Merge branch 'main' into feature/wsl-copy-to-clipboard
commit
aa54812542
|
@ -37,7 +37,7 @@ v1.x has a different architecture and better performance than v0.x, and v1.x can
|
||||||
- 🔢 [WIP] Column number
|
- 🔢 [WIP] Column number
|
||||||
|
|
||||||
## Prerequirements
|
## Prerequirements
|
||||||
- Neovim 9.0+
|
- Neovim 0.9.0+
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
We recommend using [Lazy.nvim](https://github.com/folke/lazy.nvim) to install CodeSnap.nvim, but you can still use another plugin manager you prefer.
|
We recommend using [Lazy.nvim](https://github.com/folke/lazy.nvim) to install CodeSnap.nvim, but you can still use another plugin manager you prefer.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
**codesnap.nvim** 📸 Snapshot plugin that can make pretty code snapshots with real-time previews for Neovim
|
**codesnap.nvim** 📸 Snapshot plugin that can make pretty code snapshots with real-time previews for Neovim
|
||||||
|
|
||||||
Author: Mist <mist.zzh@gmail.com>
|
Author: Mist <mist.zzh@gmail.com>
|
||||||
version: 1.1.11
|
version: 1.1.12
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use cosmic_text::{Attrs, Family, Style, Weight};
|
use cosmic_text::{Attrs, Family, Style, Weight};
|
||||||
use syntect::{
|
use syntect::{
|
||||||
easy::HighlightLines,
|
easy::HighlightLines,
|
||||||
|
@ -8,11 +10,14 @@ use syntect::{
|
||||||
|
|
||||||
use crate::components::interface::render_error::RenderError;
|
use crate::components::interface::render_error::RenderError;
|
||||||
|
|
||||||
|
type SourceMap = HashMap<&'static str, &'static str>;
|
||||||
|
|
||||||
pub struct Highlight {
|
pub struct Highlight {
|
||||||
content: String,
|
content: String,
|
||||||
code_file_path: String,
|
code_file_path: String,
|
||||||
extension: Option<String>,
|
extension: Option<String>,
|
||||||
font_family: String,
|
font_family: String,
|
||||||
|
highlighting_language_source_map: SourceMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type HighlightResult<'a> = Vec<(&'a str, Attrs<'a>)>;
|
pub type HighlightResult<'a> = Vec<(&'a str, Attrs<'a>)>;
|
||||||
|
@ -29,6 +34,7 @@ impl Highlight {
|
||||||
code_file_path,
|
code_file_path,
|
||||||
extension,
|
extension,
|
||||||
font_family,
|
font_family,
|
||||||
|
highlighting_language_source_map: HashMap::from([("PHP", "<?php")]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +53,15 @@ impl Highlight {
|
||||||
))?,
|
))?,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Some(identifier) = self.highlighting_language_source_map.get(&syntax.name[..]) {
|
||||||
|
if !self.content.contains(identifier) {
|
||||||
|
return Ok(syntax_set
|
||||||
|
.find_syntax_by_name(&format!("{} Source", &syntax.name))
|
||||||
|
.unwrap_or(syntax)
|
||||||
|
.to_owned());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(syntax.to_owned())
|
Ok(syntax.to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,6 @@
|
||||||
[project]
|
[project]
|
||||||
name = "codesnap.nvim"
|
name = "codesnap.nvim"
|
||||||
version = "1.1.11"
|
version = "1.1.12"
|
||||||
description = "📸 Snapshot plugin that can make pretty code snapshots with real-time previews for Neovim"
|
description = "📸 Snapshot plugin that can make pretty code snapshots with real-time previews for Neovim"
|
||||||
author = "Mist"
|
author = "Mist"
|
||||||
email = "mist.zzh@gmail.com"
|
email = "mist.zzh@gmail.com"
|
||||||
|
|
Loading…
Reference in New Issue