nvim: lsp: Do not attach LSP if file is opened via git
We might use Gedit to view older git revision of the file to which we do not want to attach LSP.
This commit is contained in:
parent
ccd2f77454
commit
1eec783a20
1 changed files with 15 additions and 5 deletions
|
@ -254,8 +254,13 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
local file_name = vim.api.nvim_buf_get_name(bufnr)
|
||||
local opts = { noremap=true, silent=true }
|
||||
|
||||
if string.find(file_name, ".git/") then
|
||||
return
|
||||
end
|
||||
|
||||
for _, mappings in pairs(lsp_key_mappings) do
|
||||
local capability, mode, lhs, rhs = unpack(mappings)
|
||||
if client.supports_method(capability) then
|
||||
|
@ -272,6 +277,11 @@ vim.api.nvim_create_autocmd("LspDetach", {
|
|||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
local file_name = vim.api.nvim_buf_get_name(bufnr)
|
||||
|
||||
if string.find(file_name, ".git/") then
|
||||
return
|
||||
end
|
||||
|
||||
for _, mappings in pairs(lsp_key_mappings) do
|
||||
local capability, mode, lhs, _ = unpack(mappings)
|
||||
|
|
Loading…
Reference in a new issue