-
Notifications
You must be signed in to change notification settings - Fork 761
PrismaFmt built-in replaces the content of schema.prisma file #1612
Description
FAQ
- I have checked the FAQ and it didn't resolve my problem.
Issues
- I have checked existing issues and there are no issues with the same problem.
Neovim Version
v0.10.0-dev-601+gd55d7646c
Dev Version?
- I am using a stable Neovim release version, or if I am using a dev version of Neovim I have confirmed that my issue is reproducible on a stable version.
Operating System
Windows 11 Home 22H2
Minimal Config
-- this template is borrowed from nvim-lspconfig
local on_windows = vim.loop.os_uname().version:match("Windows")
local function join_paths(...)
local path_sep = on_windows and "\\" or "/"
local result = table.concat({ ... }, path_sep)
return result
end
vim.g.loaded_remote_plugins = ""
vim.cmd([[set runtimepath=$VIMRUNTIME]])
local temp_dir = vim.loop.os_getenv("TEMP") or "/tmp"
vim.cmd("set packpath=" .. join_paths(temp_dir, "nvim", "site"))
local package_root = join_paths(temp_dir, "nvim", "site", "pack")
local install_path = join_paths(package_root, "packer", "start", "packer.nvim")
local compile_path = join_paths(install_path, "plugin", "packer_compiled.lua")
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
local null_ls_config = function()
local null_ls = require("null-ls")
-- add only what you need to reproduce your issue
null_ls.setup({
sources = {null_ls.builtins.formatting.prismaFmt},
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({
group = augroup,
buffer = bufnr
})
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({
async = false
})
end
})
end
end,
debug = true,
})
end
local function load_plugins()
-- only add other plugins if they are necessary to reproduce the issue
require("packer").startup({
{
"wbthomason/packer.nvim",
{
"jose-elias-alvarez/null-ls.nvim",
requires = { "nvim-lua/plenary.nvim" },
config = null_ls_config,
},
'neovim/nvim-lspconfig' -- LSP
},
config = {
package_root = package_root,
compile_path = compile_path,
},
})
end
if vim.fn.isdirectory(install_path) == 0 then
vim.fn.system({ "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path })
load_plugins()
require("packer").sync()
require('lspconfig').prismals.setup({})
else
load_plugins()
require("packer").sync()
endSteps to Reproduce
- Create a schema.prisma file with default content:
""" schema.prisma
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
"""
- Open the file and save it.
- An warning should appear not long after
- yes or no, it will replace the content with the output of prisma format instead
Reproducibility Check
- I confirm that my minimal config is based on the
minimal_init.luatemplate and that my issue is reproducible by runningnvim --clean -u minimal_init.luaand following the steps above.
Expected Behavior
Formatting the schema.prisma file just like the vscode extension or by running the prisma format
Actual Behavior
The content of schema.prisma is replaced with the actual output of prisma format
Debug Log
[TRACE Sat Jul 1 03:47:00 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/rpc.lua:102: received LSP request for method shutdown
[TRACE Sat Jul 1 03:47:00 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/rpc.lua:127: received LSP notification for method exit
[TRACE Sat Jul 1 03:47:01 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/client.lua:97: starting null-ls client
[TRACE Sat Jul 1 03:47:01 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/rpc.lua:102: received LSP request for method initialize
[DEBUG Sat Jul 1 03:47:01 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/client.lua:152: unable to notify client for method textDocument/didOpen (client not active): {
textDocument = {
uri = "file:///C:/Users/storm/Desktop/schema.prisma"
}
}
[TRACE Sat Jul 1 03:47:01 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/rpc.lua:127: received LSP notification for method initialized
[TRACE Sat Jul 1 03:47:01 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/rpc.lua:127: received LSP notification for method textDocument/didOpen
[TRACE Sat Jul 1 03:47:01 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS_ON_OPEN
[DEBUG Sat Jul 1 03:47:01 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
[TRACE Sat Jul 1 03:47:08 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/rpc.lua:102: received LSP request for method textDocument/formatting
[TRACE Sat Jul 1 03:47:08 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_FORMATTING
[DEBUG Sat Jul 1 03:47:08 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:321: spawning command "prisma" at C:\Users\storm\Desktop with args { "format", "C:\Users\storm\Desktop\schema.prisma" }
[TRACE Sat Jul 1 03:47:08 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:205: error output: nil
[TRACE Sat Jul 1 03:47:08 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:206: output: Prisma schema loaded from schema.prisma
Formatted C:\Users\storm\Desktop\schema.prisma in 8ms 🚀
[DEBUG Sat Jul 1 03:47:08 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/formatting.lua:89: received edits from generators
[TRACE Sat Jul 1 03:47:08 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/formatting.lua:90: {
newText = "Prisma schema loaded from schema.prisma\nFormatted C:\Users\storm\Desktop\schema.prisma in 8ms 🚀",
range = {
["end"] = {
character = 1,
line = 10
},
start = {
character = 0,
line = 0
}
},
rangeLength = 230
}
[TRACE Sat Jul 1 03:47:10 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/rpc.lua:127: received LSP notification for method textDocument/didChange
[TRACE Sat Jul 1 03:47:10 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS
[DEBUG Sat Jul 1 03:47:10 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
[TRACE Sat Jul 1 03:47:10 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/rpc.lua:127: received LSP notification for method textDocument/didSave
[TRACE Sat Jul 1 03:47:10 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS_ON_SAVE
[DEBUG Sat Jul 1 03:47:10 2023] C:\Users\storm\AppData\Local\Temp\nvim\site\pack\packer\start\null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
Help
No
Implementation Help
No response
Requirements
- I have read and followed the instructions above and understand that my issue will be closed if I did not provide the required information.

