diff --git a/Units/simple-gomod.d/README b/Units/simple-gomod.d/README new file mode 100644 index 0000000000..99889a38e0 --- /dev/null +++ b/Units/simple-gomod.d/README @@ -0,0 +1 @@ +The input.gomod is taken from https://github.com/netmute/ctags-lsp.git . diff --git a/Units/simple-gomod.d/args.ctags b/Units/simple-gomod.d/args.ctags new file mode 100644 index 0000000000..1f6c59d7cd --- /dev/null +++ b/Units/simple-gomod.d/args.ctags @@ -0,0 +1,2 @@ +--sort=no +--map-GoMod=+.gomod diff --git a/Units/simple-gomod.d/expected.tags b/Units/simple-gomod.d/expected.tags new file mode 100644 index 0000000000..c21e4a035d --- /dev/null +++ b/Units/simple-gomod.d/expected.tags @@ -0,0 +1 @@ +github.com/netmute/ctags-lsp input.gomod /^module github.com\/netmute\/ctags-lsp$/;" m diff --git a/Units/simple-gomod.d/input.gomod b/Units/simple-gomod.d/input.gomod new file mode 100644 index 0000000000..d6c8b936ab --- /dev/null +++ b/Units/simple-gomod.d/input.gomod @@ -0,0 +1,3 @@ +module github.com/netmute/ctags-lsp + +go 1.23.2 diff --git a/docs/news/HEAD.rst b/docs/news/HEAD.rst index 70d8f35549..df657ac341 100644 --- a/docs/news/HEAD.rst +++ b/docs/news/HEAD.rst @@ -55,6 +55,7 @@ The following parsers have been added: * Netfilter: to handle the output of "nft list ..." command * Prolog * DBusService +* GoMod Changes about parser specific kinds, roles, fields, and extras ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/main/parsers_p.h b/main/parsers_p.h index f097931644..2f913e3f3f 100644 --- a/main/parsers_p.h +++ b/main/parsers_p.h @@ -108,6 +108,7 @@ GDScriptParser, \ GemSpecParser, \ GoParser, \ + GoModParser, \ GPerfParser, \ HaskellParser, \ HaxeParser, \ diff --git a/optlib/gomod.c b/optlib/gomod.c new file mode 100644 index 0000000000..904895d9af --- /dev/null +++ b/optlib/gomod.c @@ -0,0 +1,62 @@ +/* + * Generated by ./misc/optlib2c from optlib/gomod.ctags, Don't edit this manually. + */ +#include "general.h" +#include "parse.h" +#include "routines.h" +#include "field.h" +#include "xtag.h" + + +static void initializeGoModParser (const langType language) +{ + + addLanguageRegexTable (language, "main"); + + addLanguageTagMultiTableRegex (language, "main", + "^module[ \t]+([^ \t\n]+)([\n]|)", + "\\1", "m", "", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^[^\n]*[\n]", + "", "", "", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^.", + "", "", "", NULL); +} + +extern parserDefinition* GoModParser (void) +{ + static const char *const extensions [] = { + NULL + }; + + static const char *const aliases [] = { + NULL + }; + + static const char *const patterns [] = { + "go.mod", + NULL + }; + + static kindDefinition GoModKindTable [] = { + { + true, 'm', "module", "modules", + }, + }; + + parserDefinition* const def = parserNew ("GoMod"); + + def->versionCurrent= 0; + def->versionAge = 0; + def->enabled = true; + def->extensions = extensions; + def->patterns = patterns; + def->aliases = aliases; + def->method = METHOD_NOT_CRAFTED|METHOD_REGEX; + def->kindTable = GoModKindTable; + def->kindCount = ARRAY_SIZE(GoModKindTable); + def->initialize = initializeGoModParser; + + return def; +} diff --git a/optlib/gomod.ctags b/optlib/gomod.ctags new file mode 100644 index 0000000000..beb4d07375 --- /dev/null +++ b/optlib/gomod.ctags @@ -0,0 +1,32 @@ +# +# Copyright (c) 2025, Red Hat, Inc. +# Copyright (c) 2025, Masatake YAMATO +# +# Author: Masatake YAMATO +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. +# +# Reference: +# https://go.dev/doc/modules/gomod-ref +# +--langdef=GoMod +--map-GoMod=+(go.mod) +--kinddef-GoMod=m,module,modules + +--_tabledef-GoMod=main +--_mtable-regex-GoMod=main/module[ \t]+([^ \t\n]+)([\n]|)/\1/m/ +--_mtable-regex-GoMod=main/[^\n]*[\n]// +--_mtable-regex-GoMod=main/.// diff --git a/source.mak b/source.mak index 90c5119e36..f7394ee499 100644 --- a/source.mak +++ b/source.mak @@ -232,6 +232,7 @@ OPTLIB2C_INPUT = \ optlib/elixir.ctags \ optlib/forth.ctags \ optlib/gdbinit.ctags \ + optlib/gomod.ctags \ optlib/gperf.ctags \ optlib/inko.ctags \ optlib/iPythonCell.ctags \ diff --git a/win32/ctags_vs2013.vcxproj b/win32/ctags_vs2013.vcxproj index 3dfe444edb..21b561e8ac 100644 --- a/win32/ctags_vs2013.vcxproj +++ b/win32/ctags_vs2013.vcxproj @@ -240,6 +240,7 @@ + diff --git a/win32/ctags_vs2013.vcxproj.filters b/win32/ctags_vs2013.vcxproj.filters index 93b798992f..bb5b730601 100644 --- a/win32/ctags_vs2013.vcxproj.filters +++ b/win32/ctags_vs2013.vcxproj.filters @@ -243,6 +243,9 @@ Source Files\optlib + + Source Files\optlib + Source Files\optlib