I didn't like how geany highlights things in lua code which are undefined unless the user defines them: ```lua messages = { floor = "You can walk on it", ceiling = "It's above you", type = "type should also not be highlighted here", } ``` ![tmp_screenshot](https://user-images.githubusercontent.com/3192173/80305553-aaa91d80-87bd-11e...)
I have removed some keywords which are undefined in Lua; it's a simple change, so `type` in the above example and other things are still highlighted even when they shouldn't. # Add goto to the basic functions Remove math and os fields; for example, still highlight math.sin but not sin because sin is not defined by default. I did not remove fields which are methods, so for example read is still highlighted so that it is shown in myfile:read() You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/2485
-- Commit Summary --
* Change Lua syntax highlighting
-- File Changes --
M data/filedefs/filetypes.lua (6)
-- Patch Links --
https://github.com/geany/geany/pull/2485.patch https://github.com/geany/geany/pull/2485.diff
Needs a Luaist to comment.
@HybridDog pushed 1 commit.
420a10e4b4807cbd1b575c39e02b688b75d90ec5 move goto so that keywords are sorted alphabetically
Excellent, I was about to report an **issue**, I hope this **solves**
hmm... yes, the correct syntax highlight that Lua needs in Geany
To everybody commenting, why don't you try it and let us know if its an improvement or has major (new) bugs? Geany devs can't be experts on all languages, they rely on community members to test stuff they don't use themselves. But so far @HybridDog has been left hanging because nobody will test this.
In the first, we needs to define a minimum Lua version. Maybe 5.1+?
Because:
which are undefined unless the user defines them:
`floor` is valid and defined, see Lua 4.x.x documentation.
for example, still highlight math.sin but not sin because sin is not defined by default.
it's not true too: see Lua 4.x.x documentation.
Why did I think and write about Lua 4.x.x? It's simple: I see `strlen`, `strlower`, `strrep`, `strsub` and other.
P.S. `type` is a bad example: this is a function from the basic library.
Thanks for the information. I have never used Lua 4. In my opinion it is better to not highlight keywords which exist only in version 4.x.x than highlighting the keywords which were removed in a later Lua version. Is there a formal way to define the minimum Lua version for the syntax highlighting?
@HybridDog to have different versions of highlighting you would have to have two different filetypes.
But do Lua source files specify which version of Lua they use, by some marker in the file? by file extension? If not how would the specific filetype be chosen when a file is opened?
Most other languages highlight all keywords of all versions, but many of them only add keywords not remove keywords, Lua would be unusual in removing them.
The same goes for built-in functions that won't be found by tags.
But do Lua source files specify which version of Lua they use, by some marker in the file? by file extension? If not how would the specific filetype be chosen when a file is opened?
The lua version is not included in the script. (An exception is a file with a shebang, but such a file is uncommon and can only be executed directly and not included with dofile.)
Most other languages highlight all keywords of all versions, but many of them only add keywords not remove keywords, Lua would be unusual in removing them.
I assume that for consistency it should also highlight old keywords and my changes are too simple.
Closed #2485.
github-comments@lists.geany.org