From 5b59cfe44ecb95c745742bb38f8251e026599dcc Mon Sep 17 00:00:00 2001 From: Fernando Ayats Date: Wed, 14 Aug 2024 21:13:35 +0200 Subject: [PATCH] tweak direnv detection --- .../neovim/viper-init-plugin/lua/viper/health.lua | 13 +++++++++++++ .../neovim/viper-init-plugin/lua/viper/lsp.lua | 12 +++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/health.lua diff --git a/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/health.lua b/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/health.lua new file mode 100644 index 00000000..a00f36df --- /dev/null +++ b/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/health.lua @@ -0,0 +1,13 @@ +local M = {} + +M.check = function() + vim.health.start("External programs") + + if vim.fn.executable("direnv") == 1 then + vim.health.ok("direnv found") + else + vim.health.error("direnv not found") + end +end + +return M diff --git a/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/lsp.lua b/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/lsp.lua index aa65cbd6..4f0df0f8 100644 --- a/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/lsp.lua +++ b/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/lsp.lua @@ -54,7 +54,7 @@ setup_all() -- end -- }) local function direnv() - vim.notify("Loading direnv... ") + vim.notify("Loading direnv") vim.api.nvim_clear_autocmds { group = "lspconfig" } pcall(function() @@ -65,13 +65,15 @@ local function direnv() vim.schedule(function() vim.fn.execute(obj.stdout) setup_all() - vim.notify("Direnv loaded!") + vim.notify("Finished loading direnv") end) end) end vim.api.nvim_create_user_command("Direnv", direnv, {}) -vim.api.nvim_create_autocmd({ "SessionLoadPost" }, { - callback = direnv, -}) +if vim.fn.executable("direnv") == 1 then + vim.api.nvim_create_autocmd({ "SessionLoadPost" }, { + callback = direnv, + }) +end