nvim: lsp: Do not attach LSP if file is opened via git

We might use Git show to view git revision of the file
on another branch and we do not want to attach LSP to
this file. This file will be opened as a temporary with
path /tmp/nvim/<something>.

On similar lines to commit 1eec783a20.
This commit is contained in:
Sanchayan Maity 2024-11-27 11:48:31 +05:30
parent e3ff05fa11
commit 036b6652a9
Signed by: sanchayanmaity
GPG key ID: 6F6A0609C12038F3

View file

@ -264,6 +264,10 @@ vim.api.nvim_create_autocmd("LspAttach", {
return
end
if string.find(file_name, "/tmp/") then
return
end
for _, mappings in pairs(lsp_key_mappings) do
local capability, mode, lhs, rhs = unpack(mappings)
if client.supports_method(capability) then
@ -286,6 +290,10 @@ vim.api.nvim_create_autocmd("LspDetach", {
return
end
if string.find(file_name, "/tmp/") then
return
end
for _, mappings in pairs(lsp_key_mappings) do
local capability, mode, lhs, _ = unpack(mappings)
if client.supports_method(capability) then