Handling errors during tests.
This commit is contained in:
parent
3f4d2dcbb7
commit
b916371f82
11
after/plugin/snippy.lua
Normal file
11
after/plugin/snippy.lua
Normal file
@ -0,0 +1,11 @@
|
||||
require('snippy').setup({
|
||||
mappings = {
|
||||
is = {
|
||||
['<Tab>'] = 'expand_or_advance',
|
||||
['<S-Tab>'] = 'previous',
|
||||
},
|
||||
nx = {
|
||||
['<leader>x'] = 'cut_text',
|
||||
},
|
||||
},
|
||||
})
|
@ -1,27 +1,27 @@
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
-- A list of parser names, or "all" (the five listed parsers should always be installed)
|
||||
ensure_installed = { "go", "rust", "toml", "c", "lua", "vim", "vimdoc", "query" },
|
||||
require 'nvim-treesitter.configs'.setup {
|
||||
-- A list of parser names, or "all" (the five listed parsers should always be installed)
|
||||
ensure_installed = { "go", "rust", "toml", "c", "lua", "vim", "vimdoc", "query" },
|
||||
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
|
||||
-- Automatically install missing parsers when entering buffer
|
||||
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
||||
auto_install = true,
|
||||
-- Automatically install missing parsers when entering buffer
|
||||
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
||||
auto_install = true,
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
highlight = {
|
||||
enable = true,
|
||||
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- Instead of true it can also be a list of languages
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
ident = { enable = true },
|
||||
rainbow = {
|
||||
enable = true,
|
||||
extended_mode = true,
|
||||
max_file_lines = nil,
|
||||
}
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- Instead of true it can also be a list of languages
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
ident = { enable = true },
|
||||
rainbow = {
|
||||
enable = true,
|
||||
extended_mode = true,
|
||||
max_file_lines = nil,
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,12 @@ local test_function_query_string = [[
|
||||
)
|
||||
]]
|
||||
|
||||
local t_run_query_string = [[
|
||||
(
|
||||
|
||||
)
|
||||
]]
|
||||
|
||||
local find_test_line = function(go_bufnr, name)
|
||||
local formatted = string.format(test_function_query_string, name)
|
||||
local query = vim.treesitter.query.parse("go", formatted)
|
||||
@ -66,11 +72,17 @@ vim.api.nvim_create_user_command('GoClearTestMarks', function()
|
||||
vim.api.nvim_buf_clear_namespace(currbuf, ns, 0, -1)
|
||||
end, {})
|
||||
|
||||
local errored = false
|
||||
function M.goRunTests()
|
||||
-- TODO: replace jobstart/jobwait with system()
|
||||
local id = vim.fn.jobstart({ "go", "test", "./...", "-json" }, {
|
||||
stdout_buffered = true,
|
||||
on_stdout = function(_, data)
|
||||
if errored == true then
|
||||
errored = false
|
||||
return
|
||||
end
|
||||
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
@ -91,7 +103,13 @@ function M.goRunTests()
|
||||
::continue::
|
||||
end
|
||||
end,
|
||||
on_exit = function()
|
||||
on_stderr = function(_, data)
|
||||
for _, value in pairs(data) do
|
||||
if value and value ~= "" then
|
||||
errored = true
|
||||
print('Error while running tests: ', value)
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
vim.fn.jobwait({ id })
|
||||
|
@ -11,7 +11,11 @@ return require('packer').startup(function(use)
|
||||
|
||||
-- Packer can manage itself
|
||||
use 'wbthomason/packer.nvim'
|
||||
|
||||
-- undotree
|
||||
use 'mbbill/undotree'
|
||||
|
||||
-- treesitter
|
||||
use('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' })
|
||||
|
||||
-- Colors
|
||||
@ -39,7 +43,7 @@ return require('packer').startup(function(use)
|
||||
use 'hrsh7th/cmp-cmdline'
|
||||
use 'hrsh7th/nvim-cmp'
|
||||
|
||||
-- Snippets (not really sure what this is for)
|
||||
-- Snippets
|
||||
use 'dcampos/nvim-snippy'
|
||||
use 'dcampos/cmp-snippy'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user