Replies: 2 comments 3 replies
-
I think mixing editor configuration with source code / configuration is a bad idea so I wouldn't want this feature built in to the editor. But you can rather easily implement it as a plugin. Add this to your function onBufferOpen(buf)
local firstLine = buf:Line(0)
local _, _, filetype = string.find(firstLine, "# micro: filetype=([%w%p]*)")
if filetype ~= nil then
buf:SetOption("filetype", filetype)
end
end |
Beta Was this translation helpful? Give feedback.
3 replies
-
When I finish the plugin, I'll post it here. For now, I'll close the discussion as resolved. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Before you raise your pitchforks and torches, hear me out for a second...
I'm just talking of a modeline to set the filetype syntax for ambiguous file extensions.
For example: Apache vs Nginx .conf files
I'm aware that Vim modelines were/are a source of security issues, that's why I'm not suggesting to add the rest of Micro options to the modeline, just the filetype one.
Something like:
# micro: filetype=nginx :
and
# micro: filetype=apacheconf :
That way, even if I have a Vim modeline at the top of a file, Micro will read its own modeline and will use the correct syntax.
What you guys think?
P.S.
Maybe we can use existing Vim modelines maybe? /s
Beta Was this translation helpful? Give feedback.
All reactions