diff options
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r-- | runtime/lua/vim/filetype.lua | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index cd8dabe2ca..30dde915ed 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -2565,6 +2565,15 @@ local function normalize_path(path, as_pattern) return normal end +local abspath = function(x) + return fn.fnamemodify(x, ':p') +end +if fn.has('win32') == 1 then + abspath = function(x) + return (fn.fnamemodify(x, ':p'):gsub('\\', '/')) + end +end + --- @class vim.filetype.add.filetypes --- @inlinedoc --- @field pattern? vim.filetype.mapping @@ -2873,7 +2882,7 @@ function M.match(args) name = normalize_path(name) -- First check for the simple case where the full path exists as a key - local path = fn.fnamemodify(name, ':p') + local path = abspath(name) ft, on_detect = dispatch(filename[path], path, bufnr) if ft then return ft, on_detect |