From 036b6652a94956136a7d8f521743e63832224eb6 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Wed, 27 Nov 2024 11:48:31 +0530 Subject: [PATCH] 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/. On similar lines to commit 1eec783a20. --- nvim/.config/nvim/lua/lsp.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nvim/.config/nvim/lua/lsp.lua b/nvim/.config/nvim/lua/lsp.lua index 40ddfd2..ed824b0 100644 --- a/nvim/.config/nvim/lua/lsp.lua +++ b/nvim/.config/nvim/lua/lsp.lua @@ -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