From a2f1cb4072bb29fcc067605fb712bbd83917513e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3n=C3=A1n=20Carrigan?= Date: Wed, 20 Dec 2023 18:34:20 +0000 Subject: [PATCH] feat(types): enums See #334 --- doc/neotest.txt | 25 ++++++++++++++++++------- lua/neotest/types/init.lua | 23 +++++++++++++++++++---- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/doc/neotest.txt b/doc/neotest.txt index 0d05dcce..485735e8 100644 --- a/doc/neotest.txt +++ b/doc/neotest.txt @@ -56,7 +56,7 @@ See the table of contents for the consumers Neotest strategies and consumers -See also~ +See also ~ |neotest.Config| Parameters~ @@ -189,6 +189,7 @@ Default values: enabled = true, symbol_queries = { elixir = , + go = " ;query\n ;Captures imported types\n (qualified_type name: (type_identifier) @symbol)\n ;Captures package-local and built-in types\n (type_identifier)@symbol\n ;Captures imported function calls and variables/constants\n (selector_expression field: (field_identifier) @symbol)\n ;Captures package-local functions calls\n (call_expression function: (identifier) @symbol)\n ", lua = ' ;query\n ;Captures module names in require calls\n (function_call\n name: ((identifier) @function (#eq? @function "require"))\n arguments: (arguments (string) @symbol))\n ', python = " ;query\n ;Captures imports and modules they're imported from\n (import_from_statement (_ (identifier) @symbol))\n (import_statement (_ (identifier) @symbol))\n " } @@ -626,7 +627,7 @@ A consumer that displays error messages using the vim.diagnostic API. This consumer is completely passive and so has no interface. You can configure the diagnostic API for neotest using the "neotest" namespace -See also~ +See also ~ |vim.diagnostic.config()| @@ -636,7 +637,7 @@ neotest.summary *neotest.summary* A consumer that displays the structure of the test suite, along with results and allows running tests. -See also~ +See also ~ |neotest.Config.summary.mappings| for all mappings in the summary window *neotest.summary.open()* @@ -817,7 +818,7 @@ partial: boolean))` {test_focused} `(fun(adapter_id: string, position_id: string)>)` {starting} `(fun())` {started} `(fun())` -Type~ +Type ~ neotest.Client *neotest.client.RunTreeArgs* @@ -1073,7 +1074,7 @@ Return~ neotest.lib.files.sep *neotest.lib.files.sep* Path separator for the current OS -Type~ +Type ~ `(string)` *neotest.lib.files.detect_filetype()* @@ -1548,17 +1549,27 @@ Parameters~ ============================================================================== + *M.PositionType* +`PositionType` + +neotest.PositionType + *neotest.Position* Fields~ {id} `(string)` -{type} `("dir"|"file"|"namespace"|"test")` +{type} `(neotest.PositionType)` {name} `(string)` {path} `(string)` {range} `(integer[])` + *M.ResultStatus* +`ResultStatus` + +neotest.ResultStatus + *neotest.Result* Fields~ -{status} `("passed"|"failed"|"skipped")` +{status} `(neotest.ResultStatus)` {output?} `(string)` Path to file containing full output data {short?} `(string)` Shortened output string {errors?} `(neotest.Error[])` diff --git a/lua/neotest/types/init.lua b/lua/neotest/types/init.lua index ea8a0463..9ffb1148 100644 --- a/lua/neotest/types/init.lua +++ b/lua/neotest/types/init.lua @@ -1,12 +1,29 @@ +local M = {} + +---@enum neotest.PositionType +M.PositionType = { + dir = "dir", + file = "file", + namespace = "namespace", + test = "test", +} + ---@class neotest.Position ---@field id string ----@field type "dir"|"file"|"namespace"|"test" +---@field type neotest.PositionType ---@field name string ---@field path string ---@field range integer[] +---@enum neotest.ResultStatus +M.ResultStatus = { + passed = "passed", + failed = "failed", + skipped = "skipped", +} + ---@class neotest.Result ----@field status "passed"|"failed"|"skipped" +---@field status neotest.ResultStatus ---@field output? string Path to file containing full output data ---@field short? string Shortened output string ---@field errors? neotest.Error[] @@ -45,8 +62,6 @@ ---@field strategy? table|neotest.Strategy Arguments for strategy or override for chosen strategy ---@field stream fun(output_stream: fun(): string[]): fun(): table -local M = {} - M.Tree = require("neotest.types.tree") M.FanoutAccum = require("neotest.types.fanout_accum")