From ccb619bb55c7240a8a3dcb18553f76dcaee84ba0 Mon Sep 17 00:00:00 2001 From: Baitinq Date: Sun, 27 Oct 2024 10:57:22 +0100 Subject: dotfiles: nvim: dont enable nvim-test go runner unless go treesitter parser installed --- dotfiles/nvim/init.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'dotfiles') diff --git a/dotfiles/nvim/init.lua b/dotfiles/nvim/init.lua index 03304fa..bbc76a2 100644 --- a/dotfiles/nvim/init.lua +++ b/dotfiles/nvim/init.lua @@ -251,9 +251,13 @@ require('lazy').setup({ { 'klen/nvim-test', config = function() - require('nvim-test.runners.go-test'):setup { - args = { "test", "-tags", "dynamic" } - } + + -- If go parser is installed, then we can activate the go nvim-test runner + if require("nvim-treesitter.parsers").has_parser('go') then + require('nvim-test.runners.go-test'):setup { + args = { "test", "-tags", "dynamic" } + } + end require('nvim-test').setup { vim.keymap.set('n', 'tf', function() require('nvim-test').run('file') end, { desc = '[T]est [F]ile' }), vim.keymap.set('n', 'tn', function() require('nvim-test').run('nearest') end, { desc = '[T]est [N]earest' }), -- cgit 1.4.1