From 82697ea146e4b873460a5a87eb9fd4da57c9c17d Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sun, 7 Aug 2022 23:36:34 -0300 Subject: [PATCH] feat: Migrate autocmd in on_attach to pure Lua call Migrated, following TeeJ_Dv's advice, the auto-command creation to a Lua function. As this auto-command only cares for the on_attach Lua scope, it seems correct to have this one defined as a Lua function instead of the legacy Vimscript. --- nvim/lsp_client_settings.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nvim/lsp_client_settings.vim b/nvim/lsp_client_settings.vim index 82fcf9e..5aeebe0 100644 --- a/nvim/lsp_client_settings.vim +++ b/nvim/lsp_client_settings.vim @@ -46,7 +46,13 @@ lua << EOF local nvim_lsp = require("lspconfig") local on_attach = function(client, bufnr) - vim.api.nvim_command("autocmd CursorHoldI lua vim.diagnostic.open_float({focusable = false, header = ''})") + vim.api.nvim_create_autocmd("CursorHoldI", { + buffer = bufnr, + callback = function() + vim.diagnostic.open_float({ focusable = false, header = "" }) + end + }) + vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( vim.lsp.diagnostic.on_publish_diagnostics, { update_in_insert = true,