From e2381e49868c880c87faff92f2774ef1cad33585 Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks Date: Tue, 25 Sep 2018 17:14:56 -0500 Subject: [PATCH] initial commit --- README.md | 13 ++++++++++++ ale_linters/markdown/ficdown.vim | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 README.md create mode 100644 ale_linters/markdown/ficdown.vim diff --git a/README.md b/README.md new file mode 100644 index 0000000..2315834 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# vim-ficdown + +A linter definition for [ALE](https://github.com/w0rp/ale) that provides error checking for Ficdown stories as you write them. + +## Pre-requisites + +You need to have [Mono](https://www.mono-project.com/) installed an on your path, and you need to have [Ficdown](https://github.com/rudism/ficdown) installed somewhere. + +## Configuration + +```vimscript +let g:ficdown_exe_path='/path/to/ficdown.exe' +``` diff --git a/ale_linters/markdown/ficdown.vim b/ale_linters/markdown/ficdown.vim new file mode 100644 index 0000000..b1f4fe5 --- /dev/null +++ b/ale_linters/markdown/ficdown.vim @@ -0,0 +1,34 @@ +function! ale_linters#markdown#ficdown#ProcessOutput(buffer, lines) abort + let l:pattern = '^\(\w\)\w\+ L\(\d\+\),\(\d\+\): \("[^"]\+": \)\?\(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'type': l:match[1], + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[5] + \}) + endfor + + return l:output +endfunction + +function! ale_linters#markdown#ficdown#GetCommand(buffer) abort + let s:exe_path = '' + if !exists('g:ficdown_exe_path') + let s:exe_path = 'ficdown.exe' + else + let s:exe_path = g:ficdown_exe_path + endif + + return '%e ' . s:exe_path . ' --format lint' +endfunction + +call ale#linter#Define('markdown', { +\ 'name': 'ficdown', +\ 'aliases': ['Ficdown', 'FicDown'], +\ 'executable': 'mono', +\ 'command_callback': 'ale_linters#markdown#ficdown#GetCommand', +\ 'callback': 'ale_linters#markdown#ficdown#ProcessOutput' +\})