-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added
gitcommit
support to harper-ls
- Loading branch information
1 parent
09a9180
commit aaf0e11
Showing
5 changed files
with
33 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use harper_core::parsers::{Markdown, Parser}; | ||
|
||
/// A Harper parser for Git commit files | ||
pub struct GitCommitParser; | ||
|
||
impl Parser for GitCommitParser { | ||
/// Admittedly a somewhat naive implementation. | ||
/// We're going to get _something_ to work, before we polish it off. | ||
fn parse(&mut self, source: &[char]) -> Vec<harper_core::Token> { | ||
// Locate the first `#` | ||
let end = source | ||
.iter() | ||
.position(|c| *c == '#') | ||
.unwrap_or(source.len()); | ||
|
||
let mut md_parser = Markdown; | ||
|
||
md_parser.parse(&source[0..end]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters