diff --git a/data/core/doc/init.lua b/data/core/doc/init.lua index 74116fd5..572b2d78 100644 --- a/data/core/doc/init.lua +++ b/data/core/doc/init.lua @@ -44,7 +44,12 @@ end function Doc:reset_syntax() local header = self:get_text(1, 1, self:position_offset(1, 1, 128)) - local syn = syntax.get(self.filename or "", header) + local path = self.abs_filename + if not path and self.filename then + path = core.project_dir .. PATHSEP .. self.filename + end + if path then path = common.normalize_path(path) end + local syn = syntax.get(path or "", header) if self.syntax ~= syn then self.syntax = syn self.highlighter:soft_reset() diff --git a/data/core/syntax.lua b/data/core/syntax.lua index 6fe8984a..977983c1 100644 --- a/data/core/syntax.lua +++ b/data/core/syntax.lua @@ -44,7 +44,7 @@ local function find(string, field) end function syntax.get(filename, header) - return find(common.basename(filename), "files") + return find(filename, "files") or (header and find(header, "headers")) or plain_text_syntax end