Syntax highlighting languages (OD-982)
Released
Jerome St-Louis opened 1 year ago

How can we add support for a particular programming language?

Our codebase is in eC which is supported by Linguist and pygments, including on GitHub.

Thank you.

Robin Shen commented 1 year ago

Had to write a eC antlr grammar, and then parse it to get all symbols. Also works if it has a Java parser.

Robin Shen commented 1 year ago

Just note that you are referring to syntax highlighting. In this case, a codemirror language mode is necessary. Unfortunately eC is not in its supported language list yet:

https://codemirror.net/5/mode/

Jerome St-Louis commented 1 year ago

Thank you very much @robin . We will try to contribute support for eC in Code Mirror. eC is a superset of C, with a few extra keywords.

I think we can add it to the C-Like mode.

Just enabling C-style syntax highlighting for .ec and .eh files would already be a big improvement.

See also:

  • full set of keywords (in addition to those from C) for eC in the syntax highlighter within our own IDE code editor:
    • "class", "private", "public", "property","import", "delete", "new", "new0", "renew", "renew0", "define", "get", "set", "remote", "dllexport", "dllimport", "stdcall", "subclass", "__on_register_module", "namespace", "using", "typed_object", "any_object", "incref", "register", "watch", "stopwatching", "firewatchers", "watchable", "class_designer", "class_fixed", "class_no_expansion", "isset", "class_default_property", "property_category", "class_data", "class_property", "virtual", "thisclass", "dbtable", "dbindex", "database_open", "dbfield"
    • additional types: "uint", "uint32", "uint16", "uint64", "bool", "byte", "int64", "uintptr", "intptr", "intsize", "uintsize","unichar",
    • highlighted identifiers: "this", "true", "false", "null", "value"
  • rail-road grammar
  • grammar summary
  • Bison grammar in eC compiler (with extra rules for error tolerance), and Flex lexer
  • Hand-written Recursive Descent parser (written in eC)
  • Pygments lexer for eC
  • Linguist TextMate bundle for eC
Robin Shen commented 1 year ago

As long as eC support is in CodeMirror, I will upgrade to take the chagne. As to symbol navigation which requires to parse eC source, a pure-java approach will be preferred to avoid creating multiple processes to increase memory foot print and sacrifying cross-platform nature of JVM.

Jerome St-Louis commented 1 year ago

I have this patch here that enhances the C-like mode to support eC:

https://github.com/jerstlouis/codemirror5/commit/9621f326027face2ec175225130e2d0811e87a60

However, they explicitly state that they don't accept Pull Requests for new modes, but instead suggest to create stand-alone npm packages for them, and point to the Elixir mode as an example. Not sure what the best way to go about it would be.

Robin Shen commented 1 year ago

This is great. I will add this mode separately into OneDev.

Robin Shen commented 1 year ago
Jerome St-Louis commented 1 year ago

@robin Thanks a lot, how can I do a Pull Request on OneDev itself? Do I need to be given access? I can't push new branches.

Robin Shen commented 1 year ago

You may fork the repository, and then submit pull request there.

2022-11-14_15-27-39.png

Thanks for your help on this!

Jerome St-Louis commented 1 year ago

https://code.onedev.io/projects/599/pulls/51

EDIT: Figured out the mapping is done in mode/meta.js

Thank you very much @robin ! We are already so happy with OneDev, but eC highlighting will be the cherry on top! :)

OneDev changed state to 'Closed' 1 year ago
Previous Value Current Value
Open
Closed
OneDev commented 1 year ago

State changed as code fixing the issue is committed

OneDev changed state to 'Released' 1 year ago
Previous Value Current Value
Closed
Released
OneDev commented 1 year ago

State changed as build #3112 is successful

issue 1 of 1
Type
Question
Priority
Minor
Assignee
Issue Votes (0)
Watchers (3)
Reference
OD-982
Please wait...
Page is in error, reload to recover