Code Monkey home page Code Monkey logo

coc-sql's Introduction

coc-sql

SQL extension for coc.nvim

Features

Install

:CocInstall coc-sql

Commands

  • sql.Format for current file

Configuration

  • sql.lintOnOpen: Lint sql file on opening, default true
  • sql.lintOnChange: Lint sql file on change, default true
  • sql.lintOnSave: Lint sql file on save, default true
  • sql.database: Choose the database syntax flavor, default to guess, valid values: db2, hive, mysql, mariadb, bigquery, postgresql, transactsql
  • sql.formatOptions: Format options passed to sql-formatter, checkout https://github.com/zeroturnaround/sql-formatter

Usage

Format document

  • :call CocAction('format')
  • :CocCommand sql.Format

Format selected content

xmap <leader>f  <Plug>(coc-format-selected)
nmap <leader>f  <Plug>(coc-format-selected)

License

MIT

coc-sql's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar esetnik avatar fannheyward avatar lgtm-com[bot] avatar lucasholder avatar pyrho avatar yaegassy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

coc-sql's Issues

SQL lint error

Hey, I've just installed this extension and it is giving me a lint error. I can't understand why

sql_lint_error

I have very little sql experience, but I ran this script inside mysql> and worked just fine.

This is the first time I'm writing an issue inside github, so I'm sorry if I didn't provide too much details.

Fails at formatting functions.

This seems to do okay formatting with everything but functions. With functions it even adds syntax errors:

  create function site_aggregates_user() returns trigger language plpgsql as $ $ begin IF (TG_OP = 'INSERT') THEN
update
  site_aggregates
set
  users = users + 1;

sql.Format is not showing up in the CocCommand list

I've installed coc-sql with the CocInstall command which shows it is installed successfully. However, when I go to issue the command on a new tab buffer with pasted in sql I don't have the command to format.

image

Do I have to have the file saved as a .sql file?

Support formatting with ':param' params

Hi!
Thank you for the plugin! :)

I'm just wondering if it will be possible to support params in sql, e.g.:
UPDATE some_table SET some_col= :param

:param - often used with NamedParameterJdbcTemplate in java.

I see that it seems like sql-formatter does not support it... maybe there is such lib in nodejs world. :)

Thanks!

Could not locate bindings file

Hi,
from latest release i started getting this error:

[coc.nvim] Error on load extension coc-sql from /home/kristijan/.config/coc/extensions/node_modules/coc-sql/lib/index.js: Error: Could not locate the bindings file. Tried:                                                                     
 → /home/kristijan/.config/coc/extensions/node_modules/coc-sql/node_modules/pg-query-native/build/pg-query.node                                                                                                                                 
 → /home/kristijan/.config/coc/extensions/node_modules/coc-sql/node_modules/pg-query-native/build/Debug/pg-query.node                                                                                                                           
 → /home/kristijan/.config/coc/extensions/node_modules/coc-sql/node_modules/pg-query-native/build/Release/pg-query.node                                                                                                                         
 → /home/kristijan/.config/coc/extensions/node_modules/coc-sql/node_modules/pg-query-native/out/Debug/pg-query.node                                                                                                                             
 → /home/kristijan/.config/coc/extensions/node_modules/coc-sql/node_modules/pg-query-native/Debug/pg-query.node                                                                                                                                 
 → /home/kristijan/.config/coc/extensions/node_modules/coc-sql/node_modules/pg-query-native/out/Release/pg-query.node                                                                                                                           
 → /home/kristijan/.config/coc/extensions/node_modules/coc-sql/node_modules/pg-query-native/Release/pg-query.node                                                                                                                               
 → /home/kristijan/.config/coc/extensions/node_modules/coc-sql/node_modules/pg-query-native/build/default/pg-query.node                                                                                                                         
 → /home/kristijan/.config/coc/extensions/node_modules/coc-sql/node_modules/pg-query-native/compiled/12.2.0/linux/x64/pg-query.node                                                                                                             
 → /home/kristijan/.config/coc/extensions/node_modules/coc-sql/node_modules/pg-query-native/addon-build/release/install-root/pg-query.node                                                                                                      
 → /home/kristijan/.config/coc/extensions/node_modules/coc-sql/node_modules/pg-query-native/addon-build/debug/install-root/pg-query.node                                                                                                        
 → /home/kristijan/.config/coc/extensions/node_modules/coc-sql/node_modules/pg-query-native/addon-build/default/install-root/pg-query.node                                                                                                      
 → /home/kristijan/.config/coc/extensions/node_modules/coc-sql/node_modules/pg-query-native/lib/binding/node-v72-linux-x64/pg-query.node 

Is there some way to fix it?

OS: Manjaro Linux i3
Version: Neovim 0.4.3
Node version: 12.2.0

create database xxx;报错

你好
我出现了这个错误,语句是正常的,我source之后成功执行了。但是xxx.sql文件里面报了这个错误

截图录屏_选择区域_20200518150113.png

Create database

It keeps saying that the command is invalid, but it isn't.

image

image

image

Disable linting completely

Hi,

is there a way to disable linting completely?

How i saw in the code, linting is still done on buf enter and document open events. I don't want to do any linting since it's kinda slow for me.

增加更多sql-formatter的自定义参数

你好 sql-formatter 支持许多自定义参数比如查询之间的空行数,可以考虑在 Coc 配置里面提供一个自定义这些参数的字典么?
在 windows 下格式化整个 sql 文件后查询之间没有空行不太方便。常用的几个格式化工具都不支持 win 想在 Coc 里一起处理了,谢谢。

can't find latest release

getting an error that the latest release cannot be found when trying to install with neovim using the :CocInstall coc-sql command
Screen Shot 2020-04-25 at 1 16 26 AM

Poor documentation about `sql.database` config field.

Currently, README.md says

  • sql.database: Choose the database syntax flavor, default to guess

but it lacks information such as

  • What kind of values are accepted?

  • What is guess? What kind of algorithm is used to guess the database?

  • If the guessing algorithm fails, to what database it falls back?

The answers to all of these questions are found in utils.ts.

Currently I have no time to create a PR, but it would be great if README.md contained these critical information.

NVARCHAR in MySQL is unexpectedly highlighed as an error.

sql:

CREATE TABLE tx (a NVARCHAR (10));

error:

Expected "#", "--", "->", "->>", ".", "/*", "BIGINT", "BIT", "CHAR", "DATE",
"DATETIME", "DECIMAL", "DOUBLE", "ENUM", "FLOAT", "INT", "INTEGER", "JSON",
"LONGTEXT", "MEDIUMTEXT", "NUMERIC", "SMALLINT", "TEXT", "TIME", "TIMESTAMP",
"TINYINT", "TINYTEXT", "VARCHAR", "binary", "blob", "boolean", "longblob",
"mediumblob", "tinyblob", "varbinary", or [ \t\n\r] but "N" found. (sql)

2024-04-08_14_09_20


:CocConfig

{
    /* ... */
    "sql.database": "mysql",
    /* ... */
}

UUID (default type for PostgreSQL) highlited as an error

I have no separate CoC-SQL configuration and default just copypasted from CoC's readme config to setup CoC intself.
I just installed CoC-SQL with CocInstall coc-sql

My SQL migration with the name 0_initial.up.sql

CREATE TABLE IF NOT EXISTS users (
	id            UUID DEFAULT gen_random_uuid() NOT NULL UNIQUE,
	name          TEXT NOT NULL,
	public_key    BYTEA NOT NULL,
	password_hash BYTEA NOT NULL,
	password_salt BYTEA NOT NULL,
	created_at    TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
);

The error I'm getting (highlighted near UUID)

Expected "#", "--", "->", "->>", ".", "/*", "BIGINT", "BIT", "CHAR", "DATE", "DATETIME", "DECIMAL", "DOUBLE", "ENUM", "FLOAT", "INT", "INTEGER", "JSON", "LONGTEXT", "MEDIUMTEXT", "NUMERIC", "SMALLINT", "TEXT", "TIME", "TIMESTAMP", "TINYINT", "TINYTEXT", "VARCHAR", "binary", "blob", "boolean", "longblob", "mediumblob", "tinyblob", "varbinary", or [ \t\n\r] but "U" found. (sql)

Similar thing happens with BYTEA type when I'm removing line with UUID or replacing UUID with TEXT.

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.