Giter VIP home page Giter VIP logo

prisma / language-tools Goto Github PK

View Code? Open in Web Editor NEW
249.0 17.0 32.0 484.62 MB

🌐 Prisma Language Tools = Language Server and Prisma's VS Code extension.

Home Page: https://marketplace.visualstudio.com/items?itemName=Prisma.prisma

License: Apache License 2.0

TypeScript 90.34% Shell 1.45% JavaScript 6.96% Nix 1.25%
prisma language-server-protocol vscode-extension vscode langauge-server syntax-highlighting

language-tools's Introduction

Prisma Language Tools

Using the Language Server Protocol to improve Prisma's developer experience.

Repository Structure

.
β”œβ”€β”€ packages
β”‚Β Β  └── vscode
β”‚Β Β   Β Β  └── src
|           └── extension.ts // Language Client entry point
|   └── language-server      // Language Server
β”‚Β Β      └── src
β”‚Β Β   Β Β      └── cli.ts    // Language Server CLI entry point
└── package.json         // The extension manifest

Build Status

  • E2E Tests Status
    • E2E tests after release on VSIX
    • E2E tests before Insider release
  • Language Server Tests Status
    • Tests for Language Server on main

language-tools's People

Contributors

alhadis avatar carmenberndt avatar depasqualeorg avatar dependabot[bot] avatar druue avatar edilsonalves avatar ejoebstl avatar janpio avatar jjangga0214 avatar jolg42 avatar lumakernel avatar matinsasan avatar matthewmueller avatar miccwan avatar millsp avatar pantharshit00 avatar prisma-bot avatar queq1890 avatar renovate-bot avatar renovate[bot] avatar schickling avatar sebthom avatar sevinf avatar sytten avatar timsuchanek avatar tomhoule avatar ultra-instinct-05 avatar williamluke4 avatar yume-chan avatar zhyupe 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

language-tools's Issues

Automated testing

Is there a way to automatically test new builds of this in VSCode somehow?

Highlight syntax error in Ubuntu vscode

works on windows vscode well.
but I moved project to ubuntu and installed same plugin prisma extension.

but all type and fileds shows error even if it is correct.

Add support for /* Prisma */ syntax highlighting

When having inline strings of GraphQL like this:

const gql = /* GraphQL */`
  query {
    isHealthy
  }
`

The VSCode GraphQL extensions enable syntax highlighting for that multiline string.

It would be great to have the same for a Prisma schema:

const schema = /* Prisma */`
  model User {
    id Int @id 
  }
`

Support For @@Id

Currently the @@id block attribute for compound ids does not seem to be supported.

Screen Shot 2019-11-07 at 13 38 11

Recognize Prisma1 schemas and tell user to install the other extension and rename file

Right now, many Prisma1 users accidentally install this extension and then get a lot of errors because the content of the file of course is not valid.

The solution to their problem is to install https://marketplace.visualstudio.com/items?itemName=Prisma.vscode-graphql and change their file extension to .graphql so the new extension does not get triggered by default.

Maybe we can recognize GraphQL files and instead of just underlining everything as invalid, give the user some feedback what is going on and point them in the right direction?

Windows support

Cannot install prisma-fmt: prisma-fmt: Unsupported OS platform: win32

Relation workflows

When modeling your schema, dealing with relations is a very common workflow. There are multiple ways how the Prisma VSC extension could be helpful:

  • Code action to add missing back-relation
  • Linting + code action when a relation is ambiguous
    • When there are multiple relations between the same types and/or self-relations
    • In the case of a 1:1 relation and the referencing key is not specified
  • Show implicit/default values

Comments being shown as invalid in VSCode

Hi. I had comments in my schema file which use to be fine a month ago but now, these come up as errors. Screenshot below. It shows it as unexpected end of block and if I remove the comment, the error goes away. Feels like a bug. Or am I doing anything wrong?

Screenshot from 2020-03-20 00-21-51

Auto-formatting Incorrectly formats enums

This issue is related to the auto-format feature, which formats the .prisma file every time I press save in VS Code.

Previously an enum would be auto-formatted so that each option is one a separate line (see "expected behavior" below) but lately it seems to format it so that all options are on one line (see "actual behavior" below).

Even when I manually format it the expected way, when I press save the auto-formatter will change all my enums to the other format.

[Expected Behavior]
Screen Shot 2020-02-24 at 09 56 54

[Actual Behavior]
Screen Shot 2020-02-24 at 10 01 03

I'm using version 0.0.23 of the plugin, with latest version of VS Code at the time of writing.

Trailing comments are broken to the next line when formatting

When formatting,

id Int @id // This is the ID

becomes

id Int @id
// This is the ID

The comment should stay at the end of the line.

Proposed solution

Modify prisma-fmt grammar: To the end of field delarations (and similar), add - SPACE* - COMMENT? - NEWLINE?, where - is the non-trivia concatenation operator as discussed here.

Then, we can safely distinguish between comments in the same line (i.e. belongs to the field) and other comments when formatting.

Function signature hides JSDoc of Prisma Client

When you already have entered a select or include statement in Prisma Client, you can't see the JSDoc anymore without scrolling, as it gets pushed down.

image

I created this issue in this repo, because this is something we could fix in our VSCode extension.

Need a .prismarc or .prisma-version as a syntax version setup

This is more a feature request than a bug
Right now the Extension says:

This plugin is designed for Prisma 2. Information about the new datamodel syntax can be found....

But i think it would be awesome to have some rc file to specify the Prisma version so that the extension will load the proper Syntax and formatting, and if no one is specified, take the last one.

I think it would be great for the community and also is scalable for future major releases

`alpha` version of extension

Is there a way to use the alpha version of this extension, that has the same validation as the current prisma2@alpha?

Display relation fields differently than scalar fields

It would be nice if you could visually differentiate scalar from non scalar fields, as they are quite different.

Ideas:

  • Slightly different text color
  • Maybe we can render a an icon next to it? Something like the link icon here on GH maybe
    image

image

Related: #45

Clickable Schema (Types)

The idea is to be able to Cmd + Click on the types in a .prisma file, to go to some information of what they actually mean (e.g. postgres.schema).

We should investigate how this could work.

Handle multiple prisma datamodel files

Big project requires to split models into multiple files. But sometimes models use other models in definition (you're right, for relations!).

Now:

Π‘Π½ΠΈΠΌΠΎΠΊ экрана 2019-06-18 Π² 16 37 18

Should be:

Import models or extension should look at prisma.yml and found related models:
Π‘Π½ΠΈΠΌΠΎΠΊ экрана 2019-06-18 Π² 16 45 43

Automatic alignment no longer works

Hi. I am not sure if I am doing something wrong, but since today, automatic formatting/alignment of schema.prisma file no longer works. It used to work properly before.

Noticed that there is some version upgrade. Any configuration to change from my end or is it a bug?

Invalid line in a Prisma file breaks error highlighting

Open this file in VSCode and apply "Prisma" highlighting:

$ /Users/runner/runners/2.164.0/work/introspection-engine-output/introspection-engine-output/node_modules/.bin/prisma2 introspect --url mysql://prisma:qd58rcCywPRS4Stk@mysql127-divy.cg7tbvsdqlrs.eu-central-1.rds.amazonaws.com:3306/Basketball_men --print
datasource db {
  provider = "mysql"
  url      = "mysql://prisma:qd58rcCywPRS4Stk@mysql127-divy.cg7tbvsdqlrs.eu-central-1.rds.amazonaws.com:3306/Basketball_men"
}

model awards_coaches {
  award   String?
  id      Int      @default(autoincrement()) @id
  lgID    String?
  note    String?
  coaches coaches? @map(["coachID", "year"]) @relation(references: [coachID, year])

  @@index([coachID], name: "coachID")
  @@index([coaches], name: "coachID_2")
  @@index([coaches], name: "coachID_3")
  @@index([year, coachID], name: "year")
  @@index([year, coachID], name: "year_2")
  @@index([year, coachID, lgID], name: "year_3")
}

model awards_players {
  award    String
  lgID     String?
  note     String?
  pos      String?
  year     Int
  playerID players

  @@id([playerID, year, award])
  @@index([playerID], name: "playerID")
}

model coaches {
  coachID          String
  lgID             String?
  lost             Int?
  post_losses      Int?
  post_wins        Int?
  stint            Int
  won              Int?
  teams            teams            @map(["tmID", "year"])
  awards_coacheses awards_coaches[]

  @@id([coachID, year, tmID, stint])
  @@index([coachID], name: "coachID")
  @@index([teams], name: "tmID")
  @@index([teams], name: "tmID_2")
  @@index([year, coachID], name: "year")
  @@index([year, coachID, lgID], name: "year_2")
  @@index([year, tmID], name: "year_3")
  @@index([year, tmID], name: "year_4")
}

model draft {
  draftFrom      String?
  draftOverall   Int?
  draftRound     Int?
  draftSelection Int?
  firstName      String?
  id             Int     @default(0) @id
  lastName       String?
  lgID           String?
  playerID       String?
  suffixName     String?
  teams          teams?  @map(["tmID", "draftYear"])

  @@index([teams], name: "tmID")
}

model players {
  birthCity        String?
  birthCountry     String?
  birthDate        DateTime?
  birthState       String?
  college          String?
  collegeOther     String?
  deathDate        DateTime?
  firstName        String?
  firstseason      Int?
  fullGivenName    String?
  height           Float?
  highSchool       String?
  hsCity           String?
  hsCountry        String?
  hsState          String?
  lastName         String?
  lastseason       Int?
  middleName       String?
  nameGiven        String?
  nameNick         String?
  nameSuffix       String?
  playerID         String           @id
  pos              String?
  race             String?
  useFirst         String?
  weight           Int?
  awards_playerses awards_players[]
  players_teamses  players_teams[]  @relation(references: [playerID])
  player_allstars  player_allstar[]
}

model players_teams {
  assists            Int?
  blocks             Int?
  dRebounds          Int?
  fgAttempted        Int?
  fgMade             Int?
  ftAttempted        Int?
  ftMade             Int?
  GP                 Int?
  GS                 Int?
  id                 Int     @default(autoincrement()) @id
  lgID               String?
  minutes            Int?
  note               String?
  oRebounds          Int?
  PF                 Int?
  points             Int?
  PostAssists        Int?
  PostBlocks         Int?
  PostdRebounds      Int?
  PostfgAttempted    Int?
  PostfgMade         Int?
  PostftAttempted    Int?
  PostftMade         Int?
  PostGP             Int?
  PostGS             Int?
  PostMinutes        Int?
  PostoRebounds      Int?
  PostPF             Int?
  PostPoints         Int?
  PostRebounds       Int?
  PostSteals         Int?
  PostthreeAttempted Int?
  PostthreeMade      Int?
  PostTurnovers      Int?
  rebounds           Int?
  steals             Int?
  stint              Int?
  threeAttempted     Int?
  threeMade          Int?
  turnovers          Int?
  playerID           players
  teams              teams?  @map(["tmID", "year"])

  @@index([fgAttempted], name: "fgAttempted")
  @@index([fgAttempted], name: "fgAttempted_2")
  @@index([playerID], name: "playerID")
  @@index([teams], name: "tmID")
  @@index([teams], name: "tmID_2")
  @@index([teams], name: "tmID_3")
  @@index([year, tmID], name: "year")
}

model player_allstar {
  assists         Int?
  blocks          Int?
  conference      String?
  d_rebounds      Int?
  fg_attempted    Int?
  fg_made         Int?
  first_name      String?
  ft_attempted    Int?
  ft_made         Int?
  games_played    Int?
  last_name       String?
  league_id       String?
  minutes         Int?
  o_rebounds      Int?
  personal_fouls  Int?
  points          Int?
  rebounds        Int?
  season_id       Int
  steals          Int?
  three_attempted Int?
  three_made      Int?
  turnovers       Int?
  playerID        players

  @@id([playerID, season_id])
  @@index([playerID], name: "player_id")
}

model series_post {
  id         Int     @default(autoincrement()) @id
  L          Int?
  lgIDLoser  String?
  lgIDWinner String?
  round      String?
  series     String?
  W          Int?
  teams      teams?  @map(["tmIDLoser", "year"]) @relation("series_post_tmIDLoser_yearToteams")
  teams      teams?  @map(["tmIDWinner", "year"]) @relation("series_post_tmIDWinner_yearToteams")

  @@index([teams], name: "tmIDLoser")
  @@index([teams], name: "tmIDWinner")
}

model teams {
  arena                                           String?
  attendance                                      Int?
  awayLost                                        Int?
  awayWon                                         Int?
  bbtmID                                          String?
  confID                                          String?
  confLoss                                        Int?
  confRank                                        Int?
  confWon                                         Int?
  divID                                           String?
  divLoss                                         Int?
  divWon                                          Int?
  d_3pa                                           Int?
  d_3pm                                           Int?
  d_asts                                          Int?
  d_blk                                           Int?
  d_dreb                                          Int?
  d_fga                                           Int?
  d_fgm                                           Int?
  d_fta                                           Int?
  d_ftm                                           Int?
  d_oreb                                          Int?
  d_pf                                            Int?
  d_pts                                           Int?
  d_reb                                           Int?
  d_stl                                           Int?
  d_tmRebound                                     Int?
  d_to                                            Int?
  franchID                                        String?
  games                                           Int?
  homeLost                                        Int?
  homeWon                                         Int?
  lgID                                            String?
  lost                                            Int?
  min                                             Int?
  name                                            String?
  neutLoss                                        Int?
  neutWon                                         Int?
  o_3pa                                           Int?
  o_3pm                                           Int?
  o_asts                                          Int?
  o_blk                                           Int?
  o_dreb                                          Int?
  o_fga                                           Int?
  o_fgm                                           Int?
  o_fta                                           Int?
  o_ftm                                           Int?
  o_oreb                                          Int?
  o_pf                                            Int?
  o_pts                                           Int?
  o_reb                                           Int?
  o_stl                                           Int?
  o_tmRebound                                     Int?
  o_to                                            Int?
  pace                                            Int?
  playoff                                         String?
  rank                                            Int?
  tmID                                            String
  won                                             Int?
  year                                            Int
  coacheses                                       coaches[]
  drafts                                          draft[]
  players_teamses                                 players_teams[]
  series_posts_series_post_tmIDLoser_yearToteams  series_post[]   @relation("series_post_tmIDLoser_yearToteams")
  series_posts_series_post_tmIDWinner_yearToteams series_post[]   @relation("series_post_tmIDWinner_yearToteams")

  @@id([year, tmID])
  @@index([tmID], name: "tmID")
  @@index([tmID, year], name: "tmID_2")
}


Then remove the first line, to see the actual errors.

It would be nice if you could still see these errors even with an invalid first line.
(The invalidity of the first line is also super easy to muss unfortunately as only the first character is highlighted)

Incorrect error indicator for optional list?

VSC indicates an error for the question mark in Post[]?, even though Prisma2 docs allows it.

model User {
  ...
  posts   Post[]?   @relation(name:"OneUserToManyOptionalPosts")
}

model Post {
  ...
  User   User!   @relation(name:"OneUserToManyOptionalPosts")
}

v1 compatible version

Hey guys,

as much as I am looking forward to using Prisma 2 and especially the new datamodel since it includes much needed features, I am a bit aghast about the way the transition is handled.

Let's be honest, Prisma 2 is not even a mature thing yet and production-readiness is also a thing for the future. Right now we have .prisma files in the v1 schema and are definitely stuck with them for a while, but since you are updating this plugin to match the v2 schema already, wouldn't it be nice to leave a v1-compatible version out here?

VSCode plugin: Empty lines within a model definition breaks auto-formatting

I like to separate out scalars and relations in a model definition, but then, the auto-formatter messes up the spacing.

Steps to reproduce:

In a model with two fields, id & name, I'd expect the formatted output to be:

model User {
  id    Int     @id

  name  String
}

But instead, the auto-formatter changes it to:

model User {
  id Int @id

  name String
}

EACCESS error for prisma-fmt

Hi, I'm running on Mac OS 10.14.6 with prisma2 installed globally via yarn. When I install and run the vscode extension on a prisma2-formatted schema.prisma, I get this error in my vscode output:

[2019-08-14 11:51:05.192] [renderer1] [error] spawn /Users/nelsonpecora/.vscode/extensions/prisma.prisma-0.0.15/out/prisma-fmt EACCES: Error: spawn /Users/<user>/.vscode/extensions/prisma.prisma-0.0.15/out/prisma-fmt EACCES
	at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
	at onErrorNT (internal/child_process.js:407:16)
	at process._tickCallback (internal/process/next_tick.js:63:19)

Screen Shot 2019-08-14 at 11 58 44

Pin binary version on release

The released version of this extension should pin to a version/hash of the binary that is also used in the release of the CLI.

Hook into format on save options

Right now I believe we're formatting whenever the document has changed. We should probably hook into VSCode better to support:

  1. Adherence to "Format on Save" option
  2. Format document command

critical syntax error)this plug-in not suitable for prisma users.

type Link {
id: ID! @id
createdAt: DateTime! @createdat
description: String!
url: String!
}

above query works.

model Link {
id Int @id
createdAt DateTime
description String
url String
}

above query emit error

ERROR: Syntax error while parsing GraphQL query. Invalid input '/', expected OperationDefinition, FragmentDefinition or TypeSystemDefinition (line 1, column 1):
// type Link {
^

{
"data": {
"deploy": null
},
"errors": [
{
"locations": [
{
"line": 2,
"column": 9
}
],
"path": [
"deploy"
],
"code": 3017,
"message": "Syntax error while parsing GraphQL query. Invalid input '/', expected OperationDefinition, FragmentDefinition or TypeSystemDefinition (line 1, column 1):\n// type Link {\n^",
"requestId": "local:cjyq4fxd4001b0739xws5xc59"
}
],
"status": 200
}

VSCode Prisma extension: Autocompletion for inline snippets

The GraphQL VSCode extension has a nice feature:
In JS code you can activate syntax highlighting of a multiline string like so:

const gql = /* GraphQL */ `
{
  users {
    id
  }
}
`

I would like to have that also for the Prisma definition language:

const gql = /* Prisma */ `
model User {
  id    Int @id
}
`

I think supporting both lowercase prisma and uppercase Prisma makes sense here.

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.