Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua syntax highlighting changes #2485

Closed
wants to merge 2 commits into from
Closed

Conversation

HybridDog
Copy link

@HybridDog HybridDog commented Apr 26, 2020

I didn't like how geany highlights things in lua code which are undefined unless the user defines them:

messages = {
	floor = "You can walk on it",
	ceiling = "It's above you",
	type = "type should also not be highlighted here",
}

tmp_screenshot

I have removed some keywords which are undefined in Lua 5.1+. 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()

Edit: mention Lua 5.1+

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's also shown in myfile:read()
@HybridDog HybridDog changed the title Change Lua syntax highlighting Lua syntax highlighting changes Apr 26, 2020
@elextr
Copy link
Member

elextr commented Apr 26, 2020

Needs a Luaist to comment.

@diazvictor
Copy link

Excellent, I was about to report an issue, I hope this solves

@Miqueas
Copy link

Miqueas commented May 29, 2020

hmm... yes, the correct syntax highlight that Lua needs in Geany

@elextr
Copy link
Member

elextr commented May 29, 2020

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.

@Skif-off
Copy link
Contributor

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.

@HybridDog
Copy link
Author

HybridDog commented Sep 29, 2020

Thanks for the information. I have never used Lua 4. In my opinion it is better to not highlight keywords which exist only in an old version, e.g. version 4.x.x.
Is there a formal way to define the minimum Lua version for the syntax highlighting?

@elextr
Copy link
Member

elextr commented Sep 29, 2020

@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.

@HybridDog
Copy link
Author

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.

@HybridDog HybridDog closed this Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants