Created attachment 122631 [details] First take on Solidity highlighting rules Kate has no syntax highlighting for Ethereum's Solidity language yet, but it would be really nice to have for people who work with Smart Contracts on that popular blockchain. Language docs are at https://solidity.readthedocs.io/en/latest/index.html I have a very preliminary XML I just created in the last few hours (attached), it may not be optimal but it seems to work decent with the Solidity files I tried so far. There may be things missing (though I read through all the docs to try and catch all keywords, units, and built-ins at least) or things not detected in the right way, but this should be a start. I'll keep trying and testing that XML in my ~/.local/share/org.kde.syntax-highlighting/syntax/ directories and I'm happy for any suggestions, improvements and help in maybe getting this into Kate proper.
I don't know this language, however I have tested with the GitHub sample files (https://github.com/ethereum/solidity/) and it looks good. If you want, you can send it to the repository to include it. In that case, it's necessary that you also add a test file in "autotests/input/". This is the KSyntaxHighlighting repository: https://phabricator.kde.org/source/syntax-highlighting/ The XML files are located in "data/syntax/". Here is the documentation for publishing patches: https://community.kde.org/Infrastructure/Phabricator If you think the highlighting file can be improved, you can publish patches in the future, modifying it without problems. In case you don't have time to do all that, you can upload the test file here and I will publish the highlighter file. Some recommendations: * On line 284, add `<IncludeRules context="##Doxygen" />` to also highlight comments with documentation. * If possible, use the MIT license in the .xml file.
Also, the keywords "reserved" are highlighted with "Error", I don't know if it's intentional, but I think it's good
(In reply to Nibaldo G. from comment #2) > Also, the keywords "reserved" are highlighted with "Error", I don't know if > it's intentional, but I think it's good That is intentional as it's an error if you use them in your code right now. Of course, the highlighting will need to be updated if/when any words may move from that list to language keywords in future versions. I will look into your comment #1 as soon as I get to it, hopefully in the next few weeks, thanks for the pointers!
Created attachment 125043 [details] Updated Solidity highlighting rules OK, I have worked with those rules for a while and they perform very well for me, so I updated the file and attached it here. I tried to do a patch but stumbled fast because I can't get my home directory "polluted" by a kde subdirectory, I'd need to have the build in a different directory/disk if I would build - and I also doN't want my default .bashrc filled up with any project I contribute a single patch to (as much as I like KDE). But I don't want to complain here, rather get to a productive result. So, it would be preferred if someone other than me can drive this into the repository, but I'm happy to provide anything needed. What should be in the test file? Should it touch all syntax cases or just an example?
Thanks for working on this. Yes, we can take care on commiting this file. As for the test: ideally, a MIT licensed example file that touches as much of the syntax as possible would be nice, to see if we regress some when.
Hi, have you some small test file?
I can add a test file
https://phabricator.kde.org/D27313
Thanks, I wanted to get back to it, but it's always a time issue. ;-) That file from the docs probably does not use the majority of the language features but it should be a decent test for the most common things being used. Thanks for picking this up!
Git commit fd345c7338fb88f668b7341faaca0ab1913a6894 by Christoph Cullmann, on behalf of Nibaldo González. Committed on 11/02/2020 at 19:03. Pushed by cullmann into branch 'master'. Add syntax highlighting for Solidity Summary: The XML file was created by Robert Kaiser and attached in: https://bugs.kde.org/show_bug.cgi?id=411867 I took the test file from the Solidity documentation: https://solidity.readthedocs.io/en/latest/solidity-by-example.html Reviewers: #framework_syntax_highlighting, dhaumann, cullmann Reviewed By: #framework_syntax_highlighting, cullmann Subscribers: kwrite-devel, kde-frameworks-devel Tags: #kate, #frameworks Differential Revision: https://phabricator.kde.org/D27313 A +153 -0 autotests/folding/test.sol.fold A +160 -0 autotests/html/test.sol.html A +153 -0 autotests/input/test.sol A +153 -0 autotests/reference/test.sol.ref A +357 -0 data/syntax/solidity.xml https://commits.kde.org/syntax-highlighting/fd345c7338fb88f668b7341faaca0ab1913a6894