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

.omnijs - .json #33360

Open
bulava92 opened this issue Jan 22, 2025 · 11 comments
Open

.omnijs - .json #33360

bulava92 opened this issue Jan 22, 2025 · 11 comments
Labels
issue/workaround it is or has a workaround type/upstream This is an issue in one of Gitea's dependencies and should be reported there

Comments

@bulava92
Copy link

Description

I have files with the extension .omnijs

In gitea they are displayed as plaintext, how can I make the display in json or javascript format? I tried different options, but it doesn't work

Here is an example of a file:

/*{
    "author": "Mark Kats",
    "targets": ["omnigraffle"],
    "type": "action",
    "identifier": "com.example.sl",
    "version": "1.0",
    "description": "text",
    "label": "SL(4)",
    "mediumLabel": "text",
    "longLabel": "text",
    "paletteLabel": "text"
}*/

(() => {
    const preferences = new Preferences("sl");
    var action = new PlugIn.Action(async function(selection, sender) { 
        var canvas = document.windows[0].selection.canvas;

        const currentZoom = document.windows[0].zoom * 100; 
        
        if (selection.graphics.length === 1) {
            const zoomFactor = 3; 
            const selectedObject = selection.graphics[0]; 
            
            const objectCenterX = selectedObject.geometry.center.x;
            const objectCenterY = selectedObject.geometry.center.y;
            
            var w = document.windows[0];
            w.setViewForCanvas(canvas, zoomFactor, new Point(objectCenterX, objectCenterY));
            w.centerVisiblePoint = new Point(objectCenterX, objectCenterY); 
            return;
        }

Gitea Version

1.23.1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

docker

Database

None

@techknowlogick techknowlogick added type/upstream This is an issue in one of Gitea's dependencies and should be reported there and removed type/bug labels Jan 22, 2025
@techknowlogick
Copy link
Member

could you request handling of this filetype in the syntax highlighter we use: https://github.com/alecthomas/chroma ?

@bulava92
Copy link
Author

could you request handling of this filetype in the syntax highlighter we use: https://github.com/alecthomas/chroma ?

Do you mean that? Screen - https://www.dropbox.com/scl/fi/goa9w55piklfdya3h1evo/2025-01-23-01.12.28.png?rlkey=vk5l3xdgwfij767glmjlgzqz5&dl=0

@TheFox0x7
Copy link
Contributor

You can also add:
*.omnijs linguist-language=javascript in repository .gitattributes file
It will use javascript highlighting for the file:

Image

@bulava92
Copy link
Author

It works as a viewing, but unfortunately it doesn't work in editing mode. This is the only progress I was able to achieve

@silverwind
Copy link
Member

Recommend to send a PR to chroma to add the file extension here, it's a 1-line change:

https://github.com/alecthomas/chroma/blob/79621af0ab93bb11ac72b35d97893b8787cd52c2/lexers/embedded/json.xml#L5-L7

@silverwind
Copy link
Member

As for the code editor, it's more complicated. We rely on the mapping provided by Monaco, which I think may be sourced from VSCode data:

function initLanguages(monaco: Monaco): void {

I think we may be able to make it fall back to chroma-detected language if monaco's detection fails, but one problem is that the chroma lexer name may not always match the monaco language name.

@wxiaoguang
Copy link
Contributor

You could also use app.ini to set highlight mapping

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;[highlight.mapping]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Extension mapping to highlight class
;; e.g. .toml=ini

@wxiaoguang wxiaoguang added the issue/workaround it is or has a workaround label Jan 23, 2025
@bulava92
Copy link
Author

Thank you, I wrote in chroma
alecthomas/chroma#1043

I did it, but it didn't help, maybe I wrote it wrong?
[highlight.mapping]
Extension mapping to highlight class
e.g. .omnijs=json

@TheFox0x7
Copy link
Contributor

If you wrote:

[highlight.mapping]
Extension mapping to highlight class
e.g. .omnijs=json

in your config, that won't work because that's just example lines telling you how to add new ones.

[highlight.mapping]
.omnijs=json

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jan 23, 2025

Also I made a test:

In the app.ini:

[highlight.mapping]
.omnijs = JavaScript

Then the UI:

screenshot

Image

@bulava92
Copy link
Author

Thank you very much, this option worked great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/workaround it is or has a workaround type/upstream This is an issue in one of Gitea's dependencies and should be reported there
Projects
None yet
Development

No branches or pull requests

5 participants