ridlfmt

command module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 7 Imported by: 0

README

RIDLFMT

RIDLFMT is a tool for formatting files written in the RIDL format, used by webrpc.

It uses similiar API as gofmt

ridlfmt -h
usage: ridlfmt [flags] [path...]

    -h    show help
    -s    sort errors by code
    -w    write result to (source) file instead of stdout

Installation

You can install RIDLFMT using go install:

go install github.com/webrpc/ridlfmt@latest

Setting in IDE

VSCode

Install these extensions:

  1. RIDL syntax
    • Needed for recognition of .ridl filetype and as a bonus it provides syntax highlighting.
  2. Custom Local Formatters

If the extensions can't be found, install them manually: Stack overflow: How to install VS code extension manually?

Add this to settings.json

"customLocalFormatters.formatters": [
    {
        "command": "ridlfmt -s",
        "languages": ["ridl"]
    }
]

Flag -s is for sorting errors.

Now you should be able to format .ridl, right click and Format Document If you want to format on save, use this settings, but it is global

"editor.formatOnSave": true,

NOTE: If it doesn't work, check the logs (Developer: Show logs... -> Extension Host), if you see this error: /bin/sh: line 1: ridlfmt: command not found then ridlfmt is not seen by /bin/sh, you can copy the binary there with this command:

sudo cp $(go env GOPATH)/bin/ridlfmt /usr/local/bin/
Neovim using null-ls/none-ls

Define .ridl filetype, so Neovim would know about it (without this the .ridl files wouldn't be detected)

vim.cmd('autocmd BufRead,BufNewFile *.ridl set filetype=ridl')

Define custom source and register it same as builtins formatters:

local ridl_formatter = {
    name = "ridlfmt",
    filetypes = { "ridl" },
    method = null_ls.methods.FORMATTING,
    generator = null_ls.formatter({
        command = "ridlfmt",
        args = { "-s" },
        to_stdin = true,
        from_stderr = true,
    }),
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL