Giter Site home page Giter Site logo

sztheory / go-inline-pgformatter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from passiolife/go-inline-pgformatter

0.0 1.0 0.0 140 KB

[mirror] A Visual Studio Code Extension for Go that formats SQL strings in go files

License: MIT License

Perl 95.30% TypeScript 4.01% JavaScript 0.68%

go-inline-pgformatter's Introduction

go-inline-pgformatter README

Auto-formatter for postgres style SQL strings within backticks in go. Just run Go - Inline Format pgSQL Strings from the command palette!

Features

Open your command palette and call Go - Inline Format pgSQL Strings to format the current document. All strings between backticks will be looked at, and if it appears to be SQL it will be formatted!

Requirements

You must have perl installed and in your path. This package comes with a version of pg_format by darold. To use an updated or custom version of pg_format, please point the pgFormatPath configuration value to the pg_format in the directory on your disk. Make sure the lib folder is a sibling!

Extension Settings

This extension contributes the following settings:

  • goPgFormat.pgFormatPath: the absolute path to the pg_format perl script on your disk. If blank, the built-in is used.
  • goPgFormat.matchSpacing: when false, the sql strings are fully left justified. If true, they match the indentation level of the start-line.
  • goPgFormat.addTabs: when above 0, and matchSpacing is on, this adds additional tabs after matching the indentation of the first lines first character.
  • goPgFormat.keywordCase: changes the SQL keywords to a specific case

Known Issues

We do not format % symbols, so as not to break any go formatters like %s, %v, %V %.2f etc. Anything with a % should be left as is. It is hard to know when something is a formatter or not, for instance WHERE text LIKE '%s' could mean that at some point you are going to fmt.Sprintf() this line, or it could mean wildcard matching, so that %s matches is.

Release Notes

Enjoy!

1.0.0

First release - recently refactored to format all sql code in one subprocess call to increase speed.

1.0.1

Configuration values fixed

1.0.2

Added more configuration, prevent formatting of % signs

go-inline-pgformatter's People

Contributors

aebranton avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.