编辑器设置
本页介绍了如何在使用 Prisma ORM 时配置编辑器以获得最佳的开发者体验。
¥This page describes how you can configure your editor for an optimal developer experience when using Prisma ORM.
如果你在这里没有看到你的编辑器,请 打开功能请求 并请求为你的编辑器提供专门支持(例如语法高亮和自动格式设置)。
¥If you don't see your editor here, please open a feature request and ask for dedicated support for your editor (e.g. for syntax highlighting and auto-formatting).
VS Code 扩展
¥VS Code extension
你可以安装官方的 Prisma VS Code 扩展。在使用 Prisma ORM 开发应用时,它为 VS Code 添加了额外的功能:
¥You can install the official Prisma VS Code extension. It adds extra capabilities to VS Code when developing applications with Prisma ORM:
-
schema.prisma
的语法高亮¥Syntax highlighting of
schema.prisma
-
Linting
-
诊断工具用于在你键入时显示架构文件中的错误和警告。
¥Diagnostic tools are used to surface errors and warnings in your schema file as you type.
-
-
代码补全
¥Code Completion
-
输入完成后,系统会显示符号的完成结果。
¥Completion results appear for symbols as you type.
-
你可以使用
Ctrl+Space
快捷方式手动触发此操作。¥You can trigger this manually with the
Ctrl+Space
shortcut.
-
-
文档帮助
¥Documentation help
-
提供完成结果时,会弹出完成结果的文档。
¥Documentation of a completion result pops up as completion results are provided.
-
-
悬停时快速显示信息
¥Quick info on hover
-
将鼠标悬停在模型和枚举的用法上时,它们的文档注释 (
///
) 会显示出来。¥Documentation Comments (
///
) of models and enums appear anywhere you hover over their usages.
-
-
转到定义
¥Go to Definition
-
跳转到或查看模型或枚举的声明。
¥Jump to or peek a model or enum's declaration.
-
-
格式化
¥Formatting
-
手动或在保存时格式化代码(如果已配置)。
¥Format code either manually or on save (if configured).
-
要在保存时自动格式化,请将以下内容添加到你的
settings.json
文件中:¥To automatically format on save, add the following to your
settings.json
file:"editor.formatOnSave": true
-
要启用与
prettier
结合的格式化,请将以下内容添加到你的settings.json
文件中:或使用 Prisma 的 Prettier 插件¥To enable formatting in combination with
prettier
, add the following to yoursettings.json
file:or use the Prettier plugin for Prisma"[prisma]": {
"editor.defaultFormatter": "Prisma.prisma"
},
-
-
-
重命名
¥Rename
-
重命名模型、枚举、字段和枚举值
¥Rename models, enums, fields and enum values
-
点击模型或枚举,按
F2
,然后输入所需的新名称并按Enter
¥Click into the model or enum, press
F2
and then type the new desired name and pressEnter
-
所有使用都将被重命名
¥All usages will be renamed
-
在模式上自动应用
@map
或@@map
¥Automatically applies
@map
or@@map
on the schema
-
-
-
快速修复
¥Quick-fixes
-
快速修复模型和枚举名称中的拼写错误
¥Quickly fix typos in model and enum names
-
一键创建新模型和枚举
¥Create new models and enums with a single click
-
如果你使用 VS Code,则可以使用 VS Code 代理模式 直接在聊天中输入诸如“创建 Postgres 数据库”或“应用架构迁移”之类的提示。VS Code 代理会自动处理所有底层 Prisma CLI 调用和 API 调用。有关更多详细信息,请参阅我们的 VS Code 代理文档。
¥If you're using VS Code, you can use VS Code agent mode to enter prompts such as “create Postgres database” or “apply schema migration” directly in the chat. The VS code agent handles all underlying Prisma CLI invocations and API calls automatically. See our VS Code Agent documentation for more details.
社区项目
¥Community projects
注意:Prisma 不维护或正式支持社区项目,并且某些功能可能不同步。请自行决定使用。
¥Note: Community projects are not maintained or officially supported by Prisma and some features may by out of sync. Use at your own discretion.
Emacs
-
emacs-prisma-mode 提供 Prisma Schema Language 的语法高亮并使用 Prisma Language Server。
¥emacs-prisma-mode provides syntax highlighting of the Prisma Schema Language and uses the Prisma Language Server.
Vim
-
vim-prisma 提供 Prisma Schema Language 的文件检测和语法高亮。
¥vim-prisma provides file detection and syntax highlighting of the Prisma Schema Language.
neovim
-
coc-prisma 实现了 Prisma 语言服务器。
¥coc-prisma implements the Prisma Language Server.
JetBrains IDE
-
Prisma ORM 由 JetBrains 提供。该插件提供 PSL 语法、语法高亮、LSP 等。
¥Prisma ORM Provided by JetBrains. This plugin provides PSL grammar, syntax highlighting, LSP, and more.
Sublime Text
-
Prisma - 对于 Sublime Text 3 和 4 - 为 Prisma 架构语言提供语法高亮。(源代码)
¥Prisma - For Sublime Text 3 & 4 - Provides syntax highlighting for the Prisma Schema Language. (Source Code)
-
LSP Prisma - 对于 Sublime Text 4 - Prisma 模式文件的语言服务器辅助程序包,使用 Prisma 的语言服务器提供 linting、错误检查、格式化、自动补齐、重命名等。 注意:它需要安装 Prisma 软件包。(源代码)
¥LSP-prisma - For Sublime Text 4 - Language Server helper package for Prisma schema files that uses Prisma's Language Server to provide linting, error checking, formatting, autocompletion, renaming etc. Note: It requires the Prisma package to be installed. (Source Code)
nova
-
nova 提供 Prisma Schema Language 的语法高亮并使用 Prisma Language Server。
¥nova provides syntax highlighting of the Prisma Schema Language and uses the Prisma Language Server.
Helix
-
Helix(从版本 22.08 开始)提供 Prisma 架构语言的语法高亮并使用 Prisma 语言服务器。
¥Helix (from version 22.08) provides syntax highlighting of the Prisma Schema Language and uses the Prisma Language Server.
CLI 自动补齐
¥CLI autocomplete
inshellisense
你可以使用 inshellisense
为 Prisma CLI 获得 IDE 风格的自动补齐功能。它支持:bash、zsh、fish、pwsh、powershell (Windows Powershell)。
¥You can get IDE-style autocompletion for Prisma CLI using inshellisense
. It supports: bash, zsh, fish, pwsh, powershell (Windows Powershell).
要安装,请运行:
¥To install, run:
npm install -g @microsoft/inshellisense
Fig
inshellisense
建立在 Fig 之上,你也可以直接使用。它适用于 bash、zsh 和 Fish。
¥inshellisense
is built on top of Fig which you can also use directly. It works in bash, zsh, and fish.
要安装,请运行:
¥To install, run:
brew install fig