-
Notifications
You must be signed in to change notification settings - Fork 620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terraform (HCL) (*.tf): new parser #2952
Changes from 5 commits
616c2d1
c78ccef
c4d902e
ca9d8fe
489c04c
7d58baf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Generated by ./misc/optlib2c from optlib/terraform.ctags, Don't edit this manually. | ||
*/ | ||
#include "general.h" | ||
#include "parse.h" | ||
#include "routines.h" | ||
#include "field.h" | ||
#include "xtag.h" | ||
|
||
|
||
static void initializeTfParser (const langType language CTAGS_ATTR_UNUSED) | ||
{ | ||
} | ||
|
||
extern parserDefinition* TfParser (void) | ||
{ | ||
static const char *const extensions [] = { | ||
"tf.tfvars", | ||
NULL | ||
}; | ||
|
||
static const char *const aliases [] = { | ||
NULL | ||
}; | ||
|
||
static const char *const patterns [] = { | ||
NULL | ||
}; | ||
|
||
static tagRegexTable TfTagRegexTable [] = { | ||
{"^[[:space:]]*resource[[:space:]]*\"([^\"]*)\"[[:space:]]*\"([^\"]*)\"", "\\2", | ||
"r,Resource", NULL, NULL, false}, | ||
{"^[[:space:]]*data[[:space:]]*\"([^\"]*)\"[[:space:]]*\"([^\"]*)\"", "\\2", | ||
"d,Data", NULL, NULL, false}, | ||
{"^[[:space:]]*variable[[:space:]]*\"([^\"]*)\"", "\\1", | ||
"v,Variable", NULL, NULL, false}, | ||
{"^[[:space:]]*provider[[:space:]]*\"([^\"]*)\"", "\\1", | ||
"p,Provider", NULL, NULL, false}, | ||
{"^[[:space:]]*module[[:space:]]*\"([^\"]*)\"", "\\1", | ||
"m,Module", NULL, NULL, false}, | ||
{"^[[:space:]]*output[[:space:]]*\"([^\"]*)\"", "\\1", | ||
"o,Output", NULL, NULL, false}, | ||
{"^([a-z0-9_]+)[[:space:]]*=", "\\1", | ||
"f,TFVar", NULL, NULL, false}, | ||
}; | ||
|
||
|
||
parserDefinition* const def = parserNew ("tf"); | ||
|
||
def->enabled = true; | ||
def->extensions = extensions; | ||
def->patterns = patterns; | ||
def->aliases = aliases; | ||
def->method = METHOD_NOT_CRAFTED|METHOD_REGEX; | ||
def->tagRegexTable = TfTagRegexTable; | ||
def->tagRegexCount = ARRAY_SIZE(TfTagRegexTable); | ||
def->initialize = initializeTfParser; | ||
|
||
return def; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# terraform.ctags: regex parse for Terraform (HCL). | ||
# | ||
# Author: Antony Southworth <https://github.com/antonysouthworth-halter> | ||
# | ||
# This source code is released for free distribution under the terms of the | ||
# GNU General Public License version 2 or (at your option) any later version. | ||
# | ||
# Derived from `vim-terraform-completion`: | ||
# - https://github.com/juliosueiras/vim-terraform-completion/blob/master/ctags/terraform.ctags | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you reuse the regex patterns of @juliosueiras's work, ask @juliosueiras to allow to use one's .ctags in GPLv2 or later. Copy & paste the evidence of alowing to use here as comments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what would I need to paste? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you fill and paste it at the head of your .ctags?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! |
||
# | ||
# Changed the name from `terraform` to `tf` so vim will recognise it properly based | ||
# on file extension (*.tf). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean the name of the parser must be "tf"? |
||
# | ||
# A notable abscence is `local`, because `locals` are defined inside a block and | ||
# it's way harder to write a good regex for that. | ||
# - https://www.terraform.io/docs/language/values/locals.html | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you put a URL for the language reference? |
||
--langdef=tf | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Terraform or TerraformHCL is better. I'm not sure which one is better. |
||
--map-tf=+tf:.tf.tfvars | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this should be
See https://docs.ctags.io/en/latest/man/ctags.1.html#options for more details. |
||
--regex-tf=/^[[:space:]]*resource[[:space:]]*"([^"]*)"[[:space:]]*"([^"]*)"/\2/r,Resource/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use --kinddef-=... option before using kinds. |
||
--regex-tf=/^[[:space:]]*data[[:space:]]*"([^"]*)"[[:space:]]*"([^"]*)"/\2/d,Data/ | ||
--regex-tf=/^[[:space:]]*variable[[:space:]]*"([^"]*)"/\1/v,Variable/ | ||
--regex-tf=/^[[:space:]]*provider[[:space:]]*"([^"]*)"/\1/p,Provider/ | ||
--regex-tf=/^[[:space:]]*module[[:space:]]*"([^"]*)"/\1/m,Module/ | ||
--regex-tf=/^[[:space:]]*output[[:space:]]*"([^"]*)"/\1/o,Output/ | ||
--regex-tf=/^([a-z0-9_]+)[[:space:]]*=/\1/f,TFVar/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -341,6 +341,7 @@ | |
<ClCompile Include="..\parsers\systemdunit.c" /> | ||
<ClCompile Include="..\parsers\tcl.c" /> | ||
<ClCompile Include="..\parsers\tcloo.c" /> | ||
<ClCompile Include="..\parsers\terraform.c" /> | ||
<ClCompile Include="..\parsers\tex.c" /> | ||
<ClCompile Include="..\parsers\tex-beamer.c" /> | ||
<ClCompile Include="..\parsers\ttcn.c" /> | ||
|
@@ -452,4 +453,4 @@ | |
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> | ||
</Project> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About this file, no newline at the of file |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -540,6 +540,9 @@ | |
<ClCompile Include="..\parsers\tcloo.c"> | ||
<Filter>Source Files\Parsers</Filter> | ||
</ClCompile> | ||
<ClCompile Include="..\parsers\terraform.c"> | ||
<Filter>Source Files\Parsers</Filter> | ||
</ClCompile> | ||
<ClCompile Include="..\parsers\tex.c"> | ||
<Filter>Source Files\Parsers</Filter> | ||
</ClCompile> | ||
|
@@ -848,4 +851,4 @@ | |
<Filter>Resource Files</Filter> | ||
</ResourceCompile> | ||
</ItemGroup> | ||
</Project> | ||
</Project> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About this file, no newline at the end of file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TerraformParser or TerraFormParser is better.