@@ -5,57 +5,11 @@ local strings = require "neoplen.strings"
55local conf = require (" telescope.config" ).values
66
77local Job = require " neoplen.job"
8- local Path = require " neoplen.path"
98
109local utils = {}
1110
12- local detect_from_shebang = function (p )
13- local s = p :readbyterange (0 , 256 )
14- if s then
15- local lines = ts_utils .split_lines (s )
16- return vim .filetype .match { contents = lines }
17- end
18- end
19-
20- local parse_modeline = function (tail )
21- if tail :find " vim:" then
22- return tail :match " .*:ft=([^: ]*):.*$" or " "
23- end
24- end
25-
26- local detect_from_modeline = function (p )
27- local s = p :readbyterange (- 256 , 256 )
28- if s then
29- local lines = ts_utils .split_lines (s )
30- local idx = lines [# lines ] ~= " " and # lines or # lines - 1
31- if idx >= 1 then
32- return parse_modeline (lines [idx ])
33- end
34- end
35- end
36-
3711utils .filetype_detect = function (filepath )
38- if type (filepath ) ~= string then
39- filepath = tostring (filepath )
40- end
41-
42- local match = vim .filetype .match { filename = filepath }
43- if match and match ~= " " then
44- return match
45- end
46-
47- local p = Path :new (filepath )
48- if p and p :is_file () then
49- match = detect_from_shebang (p )
50- if match and match ~= " " then
51- return match
52- end
53-
54- match = detect_from_modeline (p )
55- if match and match ~= " " then
56- return match
57- end
58- end
12+ return vim .filetype .match { filename = filepath }
5913end
6014
6115-- API helper functions for buffer previewer
0 commit comments