Skip to content

HearseDev/logos-format

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

logos-format

logos-format is a project that allows for logos to be formatted with the help of clang-format

Before:

image

After(BasedOnStyle: Chromium):

image

Features

  • Uses clang-format to format, therefore performs exactly like it.
  • You can also specify arguments to be passed to clang-format.
  • Check out https://clang.llvm.org/docs/ClangFormatStyleOptions.html for possible options.
  • There is an example .clang-format file provided in this project as a starting point.
  • You do not need a .clang-format file, although clang-format will look through your project directory structure to see if you do have one present.
  • An example .clang-format file would look something like this, I picked the style chromium because of their extensive docs
BasedOnStyle: Chromium
...

Check out more about Chromium Objective-C style guide here https://google.github.io/styleguide/objcguide.html

How to use

  • clang-format is required to be installed on your machine
    On Macs:

    brew install clang-format
    
  • python3 is required to be installed on your machine
    On Macs:

    brew install python
    
  • Download logos-format.py and place in desired directory
    curl -JLO https://github.com/HearseDev/logos-format/raw/main/logos-format.py

To use it with CLI

python3 /path/to/logos-format.py --assume-filename objc < /path/to/Tweak.xm

To use it with VSCode

For now this is just a method for testing
"externalFormatters.languages": {
    "logos": {
        "command": "python3",
        "arguments": [
            "/path/to/logos-format.py",
            "--assume-filename",
            "objc",
        ]
    },
}
  • You can format using the default VSCode option to format, you can have it format on save as well

To use it with neovim

autocmd BufNewFile,BufRead *.xm,*.x :set filetype=logos
nnoremap <silent> <space>f :Format<CR>
lua << EOF
require('formatter').setup {
  filetype = {
    logos = {
      -- clang-format
      function()
        return {
          --change this
          exe = 'python3',
          args = {"/path/to/logos-format.py","--assume-filename", "objc"},
          stdin = true,
          cwd = vim.fn.expand '%:p:h',  -- Run clang-format in cwd of the file.
        }
      end,
    },
  },
}
EOF
  • Now you can format the file using your keybind, in this case, using space + f

To use with others

  • Logos-format works with any text editor that allows the use of external formatters. This is because logos-format works like any traditional formatter, it reads input from stdin and spits out formatted code to stdout. Just look up how to set up an external formatter for your text editor. I will be adding popular options here once i have finished testing.

Special Thanks

  • uroboro for his immense help

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages