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

Update language_python.lua #1723

Merged
merged 17 commits into from
Jun 20, 2024
Merged

Conversation

Gaspartcho
Copy link
Contributor

@Gaspartcho Gaspartcho commented Feb 14, 2024

Added highlighting for type declarations (set them as keyword 2 (both for functions and variables))

Added f-string support

image

Will break the syntax highlighting of some one-liners

image

@Gaspartcho Gaspartcho marked this pull request as draft February 14, 2024 21:21
@Gaspartcho Gaspartcho marked this pull request as ready for review March 6, 2024 19:07
Copy link
Member

@Guldoman Guldoman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind also posting some "before" screenshots?

{ pattern = ":%s*[%a_][%w_]*[:%]]", type = "normal" },
{ pattern = "lambda().*:[%s%a_]", type = {"keyword, normal"} },
{ pattern = { ":", "[,%)\n]"}, type = "normal", syntax = python_type },
{ pattern = { "->()", ":" }, type = {"operator", "normal"}, syntax = python_type },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ pattern = { "->()", ":" }, type = {"operator", "normal"}, syntax = python_type },
{ pattern = { "->", ":" }, type = "operator", syntax = python_type },

data/plugins/language_python.lua Outdated Show resolved Hide resolved
data/plugins/language_python.lua Outdated Show resolved Hide resolved
data/plugins/language_python.lua Outdated Show resolved Hide resolved
data/plugins/language_python.lua Show resolved Hide resolved
@Gaspartcho
Copy link
Contributor Author

Would you mind also posting some "before" screenshots?

Before:

image
image

After:

image
image

Gaspartcho and others added 2 commits April 5, 2024 08:41
Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
@Gaspartcho
Copy link
Contributor Author

So, in this last commit, I fixed the one-liner syntax bug (see before and after pictures)

I also made some changes to how the minus sign registers as a number or as a operator which, at least I think, makes more sense.

Note: While testing the syntax, I noticed that it was becoming a bit too complicated and that some python files took several seconds to open. I will welcome any advice to optimize this mess.

After:

image

@takase1121
Copy link
Member

Note: While testing the syntax, I noticed that it was becoming a bit too complicated and that some python files took several seconds to open. I will welcome any advice to optimize this mess

Do you have example files for us to confirm if this is the case? I cannot replicate this when opening https://github.com/emscripten-core/emscripten/blob/main/tools/file_packager.py

@Gaspartcho
Copy link
Contributor Author

I actually fixed this problem by reducing to the maximum any cyclic sub-syntax reference (and especially removed the cyclic reference to the main syntax table) in the last few commits.

The performances are much better now

@takase1121 takase1121 merged commit c866778 into lite-xl:master Jun 20, 2024
1 check passed
takase1121 pushed a commit to takase1121/lite-xl that referenced this pull request Jun 21, 2024
* Update language_python.lua

* Update language_python.lua

* Update language_python.lua

* implemented a better `python_type` subsyntax

* Update language_python.lua

* fixed a small error where you couldn't hint a type at a var and guive it a value at the same time

* Update language_python.lua

* Update language_python.lua

Dictionaries appear now normally

* Update language_python.lua

* added suggestions concerning strings

* commited suggestion

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

* Various changes

* Update language_python.lua

Syntax more optimized but a tiny bit more complex...

* Simplified everything

---------

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
takase1121 pushed a commit that referenced this pull request Jun 23, 2024
* Update language_python.lua

* Update language_python.lua

* Update language_python.lua

* implemented a better `python_type` subsyntax

* Update language_python.lua

* fixed a small error where you couldn't hint a type at a var and guive it a value at the same time

* Update language_python.lua

* Update language_python.lua

Dictionaries appear now normally

* Update language_python.lua

* added suggestions concerning strings

* commited suggestion

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

* Various changes

* Update language_python.lua

Syntax more optimized but a tiny bit more complex...

* Simplified everything

---------

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants