Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide SQLPage syntax for code completion / IDEs #735

Open
guspower opened this issue Dec 12, 2024 · 5 comments
Open

Provide SQLPage syntax for code completion / IDEs #735

guspower opened this issue Dec 12, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@guspower
Copy link

What are you building with SQLPage ?

All sorts of little tools ;) The latest is a simple system for storing and sharing diagrams using mermaid.

What is your problem ? A description of the problem, not the solution you are proposing.

I use different variants of IntelliJ and CoC with vim. Thanks to all the progress with language servers, autocompletion has really come on in the past few years. If sqlpage could somehow provide additional code completion / language server bindings that would be a real improvement to the developer experience. For example:

sqlpage.run_sql('chart/shell.sql')

gives a nasty red error in IntelliJ.

What are you currently doing ? Since your solution is not implemented in SQLPage currently, what are you doing instead ?

Trying to ignore the editor warnings.

A clear and concise description of what you want to happen.

The editor shows autocomplete / hinting for sqlpage along with those for the SQL type in question (I usually use postgresql).

A clear and concise description of any alternative solutions or features you've considered.

Creating a separate sqlpage schema, creating mimic functions and adding it to the editor schema resolution path.

Additional context
image
Intellij (rustrover) screenshot

@guspower guspower added the enhancement New feature or request label Dec 12, 2024
@lovasoa
Copy link
Collaborator

lovasoa commented Dec 12, 2024

Yes, a sqlpage language server would be great ! But it would also be a lot of work, with few people ready to sponsor such work, so it is not something I am currently prioritizing...

@accforgithubtest
Copy link

The latest is a simple system for storing and sharing diagrams using mermaid

@guspower - I would be very keen to see how this is working out. Any chance you will be sharing this project on github ?

@guspower
Copy link
Author

@accforgithubtest it's not on github, and it's very simple. It uses mermaid along with svg-pan-zoom. Here are the bits:

SQL: Chart Table

CREATE TABLE chart
(
    id          bigserial
        PRIMARY KEY,
    code        varchar                                 NOT NULL,   # <= where the mermaid diagram text lives
    created     timestamp DEFAULT NOW(),
    updated     timestamp,
    deleted     boolean   DEFAULT FALSE,
    title       varchar   DEFAULT ''::character varying NOT NULL,
    version     integer   DEFAULT 0                     NOT NULL,
    description varchar
);

The chart view just uses the html component at the moment:

SELECT
    'html' AS component,
    '<pre class="mermaid">' || code || '</pre>' AS html
FROM
    chart.chart
WHERE
    id = $id::bigint;

and then a javascript module loads it via the shell:

import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';

mermaid.run({
    querySelector: '.mermaid',
    postRenderCallback: (id) => {
        var chart = document.getElementById(id);
        var height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
        chart.style.height = "" + height + "px";

        svgPanZoom('.mermaid svg', { controlIconsEnabled: true, fit: false, contain: false });
    }
});

Annoyingly you have to set the height explicitly when using svg-pan-zoom as you can see above.

There's not a whole lot more to it beyond that :)

@accforgithubtest
Copy link

Thank you for the share @guspower ! Gonna give this a try soon!

@guspower
Copy link
Author

@accforgithubtest if you need more details let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants