no syntax highlighting option - #1390
Conversation
3acf821 to
d6d0881
Compare
9f37b8d to
9017ce1
Compare
|
This also adds the feature of #1311 |
f119662 to
7ac5f36
Compare
|
@rnpnr This is ready for merging, functionality didn't change either so nothing should break... I hope |
rnpnr
left a comment
There was a problem hiding this comment.
Hi thank you for working on this! Overall I think the idea is sound but there are few things that should be changed.
Also can you address the case of the user manually specifying a syntax and then that getting overwritten in FILE_SAVE_POST. Basically if the user ever enters :set syntax off (doesn't have to be off), FILE_SAVE_POST should not set the syntax again.
PS: sorry to be a little bit more nitpicky about style then usual but I don't anything near the horrendous style I have to look at every day at work making its way into vis.
|
|
||
| return 'text' | ||
| return M.default_syntax | ||
| end M.Detect = Detect |
There was a problem hiding this comment.
I don't really get the point of this over M.Detect = function(...) ... end. Is there a reason?
There was a problem hiding this comment.
So when localizing variables, the linter I use (luacheck) picks it up in the file, so if I make a typo like DEtect(), it will warn me there is no such thing as DEtect(), but it wont pick up typos inside tables like M.DEtect, probably because tables could be a metatable so they could return anything.
This has a drawback, both a bug and also a feature depending on how you see it, if anybody decides to replace vis.ftdetect.Detect = theirfunction then all the other functions that use localized Detect will still use it and not the other version.
it also saves a GETTABLE call which is... honestly just a non noticeable 1 ns speedup.
| return false | ||
|
|
||
| -- syntax_highlight is on by default, unless $NO_COLOR is set | ||
| vis.options.SYNTAX_HIGHLIGHT = not(os.getenv"NO_COLOR" or os.getenv"VIS_NOCOLOR") |
There was a problem hiding this comment.
Please just set the default to true. I don't want any more vis or platform specific environment variable usage.
There was a problem hiding this comment.
Right, no VIS_NOCOLOR, I do think supporting NO_COLOR is good, for the colorblind at least, but I'm not colorblind, and I never disable syntax highlighting anyway.
It's also a good workaround for now for the lexer recursivity limit, so vis doesn't crash.
| -- NOTE: .options.SYNTAX_HIGHLIGHT is used as the real option because modifying | ||
| -- .options.syntax_highlight leads to a C stack overflow, possible BUG? |
There was a problem hiding this comment.
This needs to be investigated before this can be merged. We don't want extra and inconsistent public API just to workaround an unexplored issue.
There was a problem hiding this comment.
its not just vis.options but win.options as well, win.options doesn't even exist sometimes.
| local FindSyntax | ||
| = function --> syntax: string -- | ||
| ( | ||
| win -- vis.win|nil | ||
| ) |
There was a problem hiding this comment.
This is really ugly and difficult to read. If you need to include these put it in a comment above the function declaration.
There was a problem hiding this comment.
How should it look? I want it to keep parameter and return type information
-- (win: window|nil): syntax: string
local FindSyntax = function(win)
I should probably switch to ldoc, but I'll have to read the docs.
vis-std.lua: set syntax_highlight option. set syntax is now per window and overrides global syntax_highlight option statusbar: added win.SYNTAX to the statusbar Also always displays a file.name if it can, uses file.path or file.name filetype.lua: added M.default_syntax Detect() uses file.path or file.name instead of just file.name WIN_OPEN takes into account global highlight option FILE_SAVE_POST doesn't constantly reset the syntax on each save
Changes:
Environmental Variables:
Identifies
$NO_COLORand$VIS_NOCOLORAdds
set syntax_highlight BOOLEANChanges functionality of syntax option
set syntax on-- sets syntax on of the windowset syntax off-- sets syntax off of the windowset syntax X-- changes syntax of current window to XFILE_SAVE_POST only triggers once