From be3e1d08d04237f9bb6a5a3da6f78b66886a43e2 Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Mon, 16 Oct 2023 11:00:18 -0400 Subject: [PATCH] fix lunarvim first-run issue --- modules/vim/init.lua | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/modules/vim/init.lua b/modules/vim/init.lua index 9f85f65..712df7d 100644 --- a/modules/vim/init.lua +++ b/modules/vim/init.lua @@ -4,20 +4,22 @@ vim.opt.whichwrap = "" vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "pylyzer" }) -lvim.format_on_save = true - -local formatters = require "lvim.lsp.null-ls.formatters" -formatters.setup { - { exe = "nixpkgs-fmt", filetypes = { "nix" } }, - { exe = "black", filetypes = { "python" } }, - { - name = "prettier", - filetypes = { - "html", - "json", - "js", - "typescript", - "yaml" +-- null-ls is missing on first-run. only do this if null-ls exists +if pcall(require, "null-ls") then + lvim.format_on_save = true + local formatters = require "lvim.lsp.null-ls.formatters" + formatters.setup { + { exe = "nixpkgs-fmt", filetypes = { "nix" } }, + { exe = "black", filetypes = { "python" } }, + { + name = "prettier", + filetypes = { + "html", + "json", + "js", + "typescript", + "yaml" + }, }, - }, -} + } +end