Skip to content

Latest commit

 

History

History
93 lines (73 loc) · 12.3 KB

README.md

File metadata and controls

93 lines (73 loc) · 12.3 KB

uroboroSQL-fmt for VSCode

logo

demo

A Visual Studio Code extension for uroboroSQL-fmt that is a tool that formats SQL statements according to SQL coding standards created by Future Corporation (Japanese only).

Usage

Once installed in Visual Studio Code, "uroborosql-fmt" will be available as a formatter for SQL files. Please select "uroborosql-fmt" (extension id:Future.uroborosql-fmt) as the default formatter. You can do this either by using the context menu (right click on a open SQL file in the editor) and select "Format Document With...", or you can add the following to your settings:

{
  "[sql]": {
    "editor.defaultFormatter": "Future.uroborosql-fmt"
  }
}

Format on save

You can enable format on save for SQL by having the following values in your settings:

{
  "[sql]": {
    "editor.defaultFormatter": "Future.uroborosql-fmt",
    "editor.formatOnSave": true
  }
}

Settings

Settings Defaults Description
uroborosql-fmt.configurationFilePath null The path of configuration file. File extension must be .json. If you don't specify the path and ./.uroborosqlfmtrc.json exists, formatter will use ./.uroborosqlfmtrc.json. If you doesn't specify and .uroborosqlfmtrc.json doesn't exist, formatter will use formatters default configurations.

Configuration options

{
  "debug": false,
  "tab_size": 4,
  "complement_alias": true,
  "trim_bind_param": false,
  "keyword_case": "preserve",
  "identifier_case": "preserve",
  "max_char_per_line": 50,
  "complement_outer_keyword": true,
  "complement_column_as_keyword": true,
  "remove_table_as_keyword": true,
  "remove_redundant_nest": true,
  "complement_sql_id": true,
  "convert_double_colon_cast": false,
  "unify_not_equal": true
}

Create .uroborosqlfmtrc.json in the directory where you run the command and write the configuration there.

If there is no configuration file, the default values are used.

name type description default
debug bool Run in debug mode. false
tab_size int Tab size used for formatting. 4
complement_alias bool Complement aliases. Currently, column names are auto-completed with the same name. (e.g. COL1COL1 AS COL1) true
trim_bind_param bool Trim the contents of the bind parameters. (e.g. /* foo *//*foo*/) false
keyword_case ["upper", "lower", "preserve"] Unify the case of keywords. (No conversion in case of "preserve") lower
identifier_case ["upper", "lower", "preserve"] Unify the case of identifiers. (No conversion in case of "preserve") lower
max_char_per_line int If the total number of characters in the function name and arguments exceeds max_char_per_line, the arguments are formatted with new lines. 50
complement_outer_keyword bool Complement the optional OUTER. (e.g. LEFT JOINLEFT OUTER JOIN) true
complement_column_as_keyword bool Complement AS in column aliases. true
remove_table_as_keyword bool Remove AS in table aliases. true
remove_redundant_nest bool Remove redundant parentheses. (e.g. (((foo)))(foo)) true
complement_sql_id bool Complement SQL ID. false
convert_double_colon_cast bool Convert casts by X::type to the form CAST(X AS type). true
unify_not_equal bool Convert comparison operator <> to != true

Available Commands

command title description
Format SQL You can trigger formatting by executing this command.
Export workspace config to uroborosql-fmt config file You can export workspace configurations to formatter's configuration file (specified in uroborosql-fmt.configurationFilePath). Only the non-null configurations in settings.json will overwrite those in .uroborosqlfmtrc.json.
Import uroborosql-fmt config file config to workspace config You can import formatter's configuration into workspace configuration. Configuration values that exist in settings.json, but not in .uroborosqlfmtrc.json, will be set to null.
Import uroborosql-fmt config file config to global config You can import formatter's configuration into global configuration. Configuration values that exist in settings.json, but not in .uroborosqlfmtrc.json, will be set to null.

License

Business Source License 1.1