Add support for neovim 0.10
dblume

dblume commited on 2024-12-03 00:17:59
Showing 1 changed files, with 9 additions and 1 deletions.


Neovim 0.10 removed support for the filetype methods. Now check
the version of neovim, and make compatible calls.
... ...
@@ -454,10 +454,18 @@ lua << EOF
454 454
       ['.*'] = {
455 455
         priority = -math.huge,
456 456
         function(path, bufnr)
457
+          local rokulog_pat = [[^\d\{2\}-\d\{2\} \d\{2\}:\d\{2\}:\d\{2\}.\d\{3\}\s\+\(!\|n\|dev\|\d\+\(_[0-9a-f]\+\)\?\|tvinput\.\S\+\)\?[ *]\[]]
458
+          if vim.fn.has('nvim-0.10') == 1 then
459
+            local content = vim.api.nvim_buf_get_lines(bufnr, 0, 1, false)[1] or ''
460
+            if vim.regex(rokulog_pat):match_str(content) ~= nil then
461
+              return 'rokulog'
462
+            end
463
+          else
457 464
             local content = vim.filetype.getlines(bufnr, 1)
458
-        if vim.filetype.matchregex(content, [[^\d\{2\}-\d\{2\} \d\{2\}:\d\{2\}:\d\{2\}.\d\{3\}\s\+\(!\|n\|dev\|\d\+\(_[0-9a-f]\+\)\?\|tvinput\.\S\+\)\?[ *]\[]]) then
465
+            if vim.filetype.matchregex(content, rokulog_pat) then
459 466
               return 'rokulog'
460 467
             end
468
+          end
461 469
         end,
462 470
       },
463 471
     },
464 472