Skip to content

Commit 8be1f68

Browse files
committed
lua: small filetype/style setting cleanup
Filetype extension mapping already needs to match regular expressions so we might as well us it to simplify things. set_syntax doesn't need to handle pseudo scintilla style definitions. I couldn't even find any examples of table style definitions anywhere let alone references to other definitions as $(style.myvarname) (hint: variables in lua already handle this).
1 parent 1fc1756 commit 8be1f68

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

lua/plugins/filetype.lua

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ vis.ftdetect.filetypes = {
178178
ext = { "%.gleam$" },
179179
},
180180
glsl = {
181-
ext = { "%.glslf$", "%.glslv$" },
181+
ext = { "%.glsl[fv]?$" },
182182
},
183183
gnuplot = {
184184
ext = { "%.dem$", "%.plt$" },
@@ -200,7 +200,7 @@ vis.ftdetect.filetypes = {
200200
mime = { "text/x-haskell" },
201201
},
202202
html = {
203-
ext = { "%.htm$", "%.html$", "%.shtm$", "%.shtml$", "%.xhtml$" },
203+
ext = { "%.[sx]?htm[l]?$" },
204204
mime = { "text/x-html" },
205205
},
206206
icon = {
@@ -272,12 +272,7 @@ vis.ftdetect.filetypes = {
272272
mime = { "text/x-makefile" },
273273
},
274274
man = {
275-
ext = {
276-
"%.1$", "%.2$", "%.3$", "%.4$", "%.5$", "%.6$", "%.7$",
277-
"%.8$", "%.9$", "%.1x$", "%.2x$", "%.3x$", "%.4x$",
278-
"%.5x$", "%.6x$", "%.7x$", "%.8x$", "%.9x$",
279-
"%.ms$", "%.me$", "%.mom$", "%.mm$", "%.tmac$"
280-
},
275+
ext = { "%.[1-9][xp]?$", "%.ms$", "%.me$", "%.mom$", "%.mm$", "%.tmac$" },
281276
},
282277
markdown = {
283278
ext = { "%.md$", "%.markdown$" },

lua/vis.lua

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -283,25 +283,15 @@ vis.types.window.set_syntax = function(win, syntax)
283283
local style = lexers['STYLE_' .. token_name:upper():gsub("%.", "_")] or ''
284284
if type(style) == 'table' then
285285
local s = ''
286-
if style.bold then
287-
s = string.format("%s,bold", s)
288-
elseif style.italics then
289-
s = string.format("%s,italics", s)
290-
elseif style.underlined then
291-
s = string.format("%s,underlined", s)
286+
if style.attr then
287+
s = string.format("%s,%s", s, attr)
292288
elseif style.fore then
293289
s = string.format("%s,fore:%s", s, style.fore)
294290
elseif style.back then
295291
s = string.format("%s,back:%s", s, style.back)
296292
end
297293
style = s
298294
end
299-
local pattern = "%$%(style%..*%)"
300-
local prop_name = style:match(pattern)
301-
if prop_name ~= nil then
302-
local real_value = tostring(lexers["STYLE_" .. string.upper(prop_name:sub(9,string.len(prop_name)-1))])
303-
style = string.gsub(style, pattern, real_value)
304-
end
305295
if style ~= nil then win:style_define(id, style) end
306296
end
307297

0 commit comments

Comments
 (0)