{"id":15564139,"url":"https://github.com/and3rson/nice65","last_synced_at":"2025-04-09T17:04:49.847Z","repository":{"id":184842128,"uuid":"672564641","full_name":"and3rson/nice65","owner":"and3rson","description":"Code formatter for 6502 assembly (cc65 syntax)","archived":false,"fork":false,"pushed_at":"2024-01-18T16:46:48.000Z","size":73,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T17:04:44.411Z","etag":null,"topics":["6502","6502-assembly","ca65","cc65"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/and3rson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-30T14:13:36.000Z","updated_at":"2025-03-09T04:01:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"c0bb2d53-1637-420a-a08a-c860e4b2f0ba","html_url":"https://github.com/and3rson/nice65","commit_stats":null,"previous_names":["and3rson/nice65"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/and3rson%2Fnice65","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/and3rson%2Fnice65/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/and3rson%2Fnice65/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/and3rson%2Fnice65/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/and3rson","download_url":"https://codeload.github.com/and3rson/nice65/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248074976,"owners_count":21043490,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["6502","6502-assembly","ca65","cc65"],"created_at":"2024-10-02T16:38:22.640Z","updated_at":"2025-04-09T17:04:49.808Z","avatar_url":"https://github.com/and3rson.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nice65\nCode formatter for CC65 assembly (WIP).\n\nRequirements:\n\n- Python 3.x\n- [Lark](https://github.com/lark-parser/lark)\n\nFeatures:\n- Makes ugly code less ugly\n- Fixes indentation and letter cases (mnemonics, registers)\n- Understands weird labels, such as colon-less (C64 style) and unnamed (`:`, `:+++`)\n- Preserves indentation level of comments\n- Supports basic macros\n- Skips files with `; nice65: ignore` comment\n- Tested with [C64 Kernal/Basic](https://github.com/mist64/c64rom) and [my 6502-based SBC ROM code](https://github.com/and3rson/deck65)\n\nImprovements to do:\n- Complex macros\n- Proper formatting of arithmetic expressions\n\nNotes:\n- Colon-less label mode (`-l`) breaks macros due to [ambiguity of the syntax](https://github.com/cc65/cc65/discussions/2158#discussioncomment-6644905). Use this option only with legacy code that contains no macros (such as C64 source code).\n\n# Installation\n\n```sh\npip install nice65\n```\n\n## Example usage\n\n```sh\n# Reformat and print to STDOUT\nnice65 samples/example.s\n\n# Modify file in-place\nnice65 samples/example.s -m\n\n# Write result to another file\nnice65 samples/example.s -o samples/clean.s\n# or\nnice65 samples/example.s \u003e samples/clean.s\n\n# Recursively reformat all files in directory with extension \".s\"\nnice65 ./samples/ -r\n\n# Recursively reformat all files in directory with extension \".asm\"\nnice65 ./samples/ -r -p '*.asm'\n```\n\nBefore:\n```asm\n.macro ldax aa, bb ; do stuff\nlda aa\nldx bb ; load bb\n.endmacro\n\nfour .set 9\nvar = 1337 + four\nfour .set 4\n\n.macro push_all\n    phA\n    phX\n    PHy\n.endmacro\n\n.data\nfoo:.byte 1\n\n.code\n;  Fill zeropage with zeroes\nfill:\n   ; save registers\n   push_all\n\n@start: ldax #0, #0\n@again: sta     $00   ,x      ;Yeah, we can use stz, but I just need some code to test nice65!\n   inx\nbne @again  ; Repeat\n\n  ; Do unnecessary throwaway stuff to test expressions\n  ;\n  lda #\u003c($42  +  %10101010- (foo*2))\n  cmp foo+2\n  jmp :+\n: lda $1234\n\n@ridiculously_long_label_just_for_the_sake_of_it:PLX\npla\n\nend:rts\n```\n\nAfter:\n```asm\n.macro  ldax aa, bb     ; do stuff\n        LDA aa\n        LDX bb          ; load bb\n.endmacro\n\nfour    .set 9\nvar = 1337 + four\nfour    .set 4\n\n.macro  push_all\n        PHA\n        PHX\n        PHY\n.endmacro\n\n.data\nfoo:    .byte 1\n\n.code\n; Fill zeropage with zeroes\nfill:\n        ; save registers\n        push_all\n\n    @start:\n        ldax #0, #0\n    @again:\n        STA $00, X      ; Yeah, we can use stz, but I just need some code to test nice65!\n        INX\n        BNE @again      ; Repeat\n\n        ; Do unnecessary throwaway stuff to test expressions\n        ;\n        LDA #\u003c($42 + %10101010 - (foo * 2))\n        CMP foo + 2\n        JMP :+\n    :   LDA $1234\n\n    @ridiculously_long_label_just_for_the_sake_of_it:\n        PLX\n        PLA\n\nend:    RTS\n```\n\n\n## Using with Vim\n\n```vim\n:nnoremap \u003cM-r\u003e :%! nice65 -\u003cCR\u003e\n```\n\n## Using with NeoVim\n\nIf you want to be fancy, here's an example on how to have nice65 configured as code formatter for NeoVim with null-ls:\n\n1. Make sure you have the following neovim plugins installed:\n    - `maxbane/vim-asm_ca65` - sets filetype for CA65 buffers\n    - `jose-elias-alvarez/null-ls.nvim` - allows to run custom scripts as language servers\n\n2. Add configuration:\n\n    ```lua\n    local null_ls = require(\"null-ls\")\n    null_ls.setup({\n        on_attach = on_attach, -- Remove this line if you don't use on_attach\n    })\n    null_ls.register({\n        method = null_ls.methods.FORMATTING,\n        filetypes = { 'asm_ca65' },\n        generator = null_ls.formatter({\n            command = 'nice65',\n            args = {'-'},\n            to_stdin = true,\n            from_stdout = true,\n        }),\n    })\n    ```\n\n3. Trigger the formatting:\n\n    ```vim\n    :lua vim.lsp.buf.format()\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fand3rson%2Fnice65","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fand3rson%2Fnice65","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fand3rson%2Fnice65/lists"}