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

Add modeline magic for file type etc. #86

Open
mjf opened this issue Nov 18, 2020 · 1 comment
Open

Add modeline magic for file type etc. #86

mjf opened this issue Nov 18, 2020 · 1 comment

Comments

@mjf
Copy link

mjf commented Nov 18, 2020

At least for file types you should provide modeline magic:

$ cat script
#! /bin/sh

echo "Hello, world!"
exit 0

# ox: ft=sh

Not everyone likes to add file extension to determine the file type! Therefor modeline magic can help to force it.
Also the #! ... shebang can be split to get the interpreter name (i.e. sh). You can also add some sort
of aliases for it. For example (for syntax etc. for some "shell" and "c"):

(
    filetypes: {
        "shell": {
            files: [".bash*", ".profile"],
            extensions: [".sh", ".bash", ".dash", ".sh.inc"],
            interpreters: ["sh", "bash", "dash"],
            modeline: {
                keywords: ["filetype", "ft"],
                values: ["shell", "sh"],
            },
        },
        "c": {
            files: ["~/dev/c/**"],
            extensions: [".c", ".h", ".cpp"],
            interpreters: ["tcc"],
            modeline: {
                keywords: ["filetype", "ft"],
                values: ["c", "c++"],
            },
        },
    },
)

Where the files, extensions, interpreters and modeline are "or-ed" (any of them can match). Just an idea... May be related to #76.

@curlpipe
Copy link
Owner

I'll look into this

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

No branches or pull requests

2 participants