Disable lsp in diff

When I start diff using

nvim -d fileA fileB

my lsp shows a ton of errors. I am not interested in lsp errors when I diff; I would like them to disappear. I can stop lsp in the first window with :LspStop then I need to jump right <C-w>l and type again :LspStop. How can I automate it? Preferably in a way that I don’t need to type anything when I run diff.

Thanks

What I have for now is this remap

vim.keymap.set("n", "<leader>diff", "<cmd>LspStop<CR><cmd>set signcolumn=no<CR><C-w>l<cmd>LspStop<CR><cmd>set signcolumn=no<CR>");

It does the job. The signcolumn=no hides the space where lsp would display error signs. My leader is space

vim.g.mapleader = " "

It’s okay but I would like to have something like the autocmd BufNewFile except that the command is not issued at the loading of a new file but when nvim starts in the diff mode.

Thanks

Sry for answering an old post - but this was the only search result I found when trying to solve a problem similar to yours.

I was having an issue with Neovim Diff and Golang GOPLS.
It caused very high CPU usage when using “git difftool” which is configured to use nvim -d

I use mason and mason-lspconfig. I added the following to my config to stop it from loading Mason when opening Diff mode. Basically, it checks if NeoVim is in Diff-mode.

       -- If diff mode is selected don't load any LSP Configs
	if (vim.opt.diff:get()) then
   		 return
	end

Here is my config:

{
"williamboman/mason.nvim",
config = function()
              -- If Diff mode is selected don't load any LSP Configs
              if (vim.opt.diff:get()) then
   	           return
              end

              require("mason").setup()
	end,
},
{
  "williamboman/mason-lspconfig.nvim",
   dependenies = {"mason.nvim"},
   config = function()
	-- If Diff mode is selected don't load any LSP Configs
	if (vim.opt.diff:get()) then
   		return
	end

	require("mason-lspconfig").setup()
	require("mason-lspconfig").setup_handlers {
        function (server_name)
            	require("lspconfig")[server_name].setup {}
        end,
   end,
}