rafaelsq/nvim-goc.lua

github github
programming-languages-support
star 24
stars
alert-circle 4
open issues
users 1
subscribers
git-branch 4
forks
CREATED

2021-08-30

UPDATED

21 days ago


nvim-goc.lua

easy go coverage

image

Setup


-- if set, when we switch between buffers, it will not split more than once. It will switch to the existing buffer instead
vim.opt.switchbuf = 'useopen'

local goc = require'nvim-goc'
goc.setup({ verticalSplit = false })


vim.keymap.set('n', '<Leader>gcr', goc.Coverage, {silent=true})
vim.keymap.set('n', '<Leader>gcc', goc.ClearCoverage, {silent=true})
vim.keymap.set('n', '<Leader>gct', goc.CoverageFunc, {silent=true})
vim.keymap.set('n', ']a', goc.Alternate, {silent=true})
vim.keymap.set('n', '[a', goc.AlternateSplit, {silent=true})

cf = function(testCurrentFunction)
  local cb = function(path)
    if path then
      vim.cmd(":silent exec \"!xdg-open " .. path .. "\"")
    end
  end

  if testCurrentFunction then
    goc.CoverageFunc(nil, cb, 0)
  else
    goc.Coverage(nil, cb)
  end
end

vim.keymap.set('n', '<leader>gca', cf, {silent=true})
vim.keymap.set('n', '<Leader>gcb', function() cf(true) end, {silent=true})

-- default colors
-- vim.api.nvim_set_hl(0, 'GocNormal', {link='Comment'})
-- vim.api.nvim_set_hl(0, 'GocCovered', {link='String'})
-- vim.api.nvim_set_hl(0, 'GocUncovered', {link='Error'})