Merge pull request #68 from barrettruth/fix/highlight-unknown-filetypes
fix(parser): emit hunks for files with unknown filetypes
This commit is contained in:
commit
b4e40e4093
2 changed files with 20 additions and 1 deletions
|
|
@ -68,7 +68,7 @@ function M.parse_buffer(bufnr)
|
||||||
local header_lines = {}
|
local header_lines = {}
|
||||||
|
|
||||||
local function flush_hunk()
|
local function flush_hunk()
|
||||||
if hunk_start and #hunk_lines > 0 and (current_lang or current_ft) then
|
if hunk_start and #hunk_lines > 0 then
|
||||||
local hunk = {
|
local hunk = {
|
||||||
filename = current_filename,
|
filename = current_filename,
|
||||||
ft = current_ft,
|
ft = current_ft,
|
||||||
|
|
|
||||||
|
|
@ -285,5 +285,24 @@ describe('parser', function()
|
||||||
assert.are.equal('diff --git a/parser.lua b/parser.lua', hunks[1].header_lines[1])
|
assert.are.equal('diff --git a/parser.lua b/parser.lua', hunks[1].header_lines[1])
|
||||||
delete_buffer(bufnr)
|
delete_buffer(bufnr)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('emits hunk for files with unknown filetype', function()
|
||||||
|
local bufnr = create_buffer({
|
||||||
|
'M config.obscuretype',
|
||||||
|
'@@ -1,2 +1,3 @@',
|
||||||
|
' setting1 = value1',
|
||||||
|
'-setting2 = value2',
|
||||||
|
'+setting2 = MODIFIED',
|
||||||
|
'+setting4 = newvalue',
|
||||||
|
})
|
||||||
|
local hunks = parser.parse_buffer(bufnr)
|
||||||
|
|
||||||
|
assert.are.equal(1, #hunks)
|
||||||
|
assert.are.equal('config.obscuretype', hunks[1].filename)
|
||||||
|
assert.is_nil(hunks[1].ft)
|
||||||
|
assert.is_nil(hunks[1].lang)
|
||||||
|
assert.are.equal(4, #hunks[1].lines)
|
||||||
|
delete_buffer(bufnr)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue