Code Monkey home page Code Monkey logo

vim-terraform's Introduction

Call For Maintainers

This plugin, along with others like it, is now maintained by the HashiVim organization, which is looking for additional maintainers and contributors. See the HashiVim home page for further information.


Overview: vim-terraform

This plugin adds a :Terraform command that runs terraform, with tab completion of subcommands. It also provides syntax highlighting, indentation and more for HCL and Terraform-related files.


Installation

With Vim packages:

git clone https://github.com/hashivim/vim-terraform.git ~/.vim/pack/plugins/start/vim-terraform

If you prefer to use a plugin manager, go ahead.


Usage

Settings are documented in the help.


Updating vim-terraform

Note, this is only for maintainers of the vim-terraform project.

When a new version of Terraform drops, you can run the following where x.x.x is a version such as 0.11.11

./update_automagic.sh x.x.x

At this point, add the modified files to a git branch and open a pull request.

git checkout -b "feature/update-to-terraform-$VERSION"
git add $FILE
git commit -m "Message about update"
git push

Add another maintainer to the pull request and await confirmation.


Running tests

To run the test suite and verify functionality

make

Credits

Syntax highlighting and indentation by Kevin Le (@bkad) based on prior work by Larry Gilbert (@L2G). The rest originally written by Mark Cornick https://www.markcornick.com/ and contributors listed below. Licensed under the ISC license.

Thanks to the following contributors:

  • michael j talarczyk (@mijit)
  • Koji Nakayama (@knakayama)
  • Kris (@kostecky)
  • Okumura Takahiro (@hfm)
  • Paul Forman (@pforman)
  • Lowe Schmidt (@lsc)
  • Mario Kozjak (@mkozjak)

The :TerraformFmt command is adapted from vim-hclfmt.

This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

vim-terraform's People

Contributors

alexandregv avatar ashb avatar dimbleby avatar esc avatar hoelzro avatar imkira avatar kesoji avatar knakayama avatar kostecky avatar loicgombeaud avatar lsc avatar mandos avatar mbevc1 avatar mcornick avatar mcrmonkey avatar michaelpotter avatar minamijoyo avatar mkozjak avatar moofish32 avatar natw avatar ojford avatar orlando avatar padde avatar pgporada avatar ponkio-o avatar rkennedy avatar stephenpaulger avatar talarczykco avatar tgyurci avatar tmichel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-terraform's Issues

Heredoc syntax nor properly highlited

Just after installing module, found out that heredoc syntax is not supported well. I have code:

command = <<EOT
  echo "test"
  git add dir/*.tf
EOT 

Syntax after /* is treated as comment and collored properly, despite this characters were used in string, not as comment.

Commenting multiple lines with tcomment uses multiple /* */

If I select multiple lines and hit cc, I will end up with each line wrapped in a /* */.

It should either use a single /* */ for the whole block or use // for every line.

I'm not sure if the fault lies with tcomment or vim-terraform. I suspect the latter.

feature request: identify markdown embedded in comments (for syntax highlighting)

When using https://github.com/segmentio/terraform-docs, you have the option of embedding docs for your modules in a comment block. See https://github.com/segmentio/terraform-docs/blob/master/_example/main.tf for an example. If you write those embedded docs in markdown, they're still in a block comment, so you don't get any markdown syntax highlighting (as comments, they're all-blue).

I have zero experience with syntax highlighting in vim plugins, so I'm not sure how difficult this would be, but I think the feature would be really useful, and I would be happy to help make this happen in any way that I can.

One other note: it might be possible to simplify this by relying on the /** that terraform-docs uses to identify the block comment as an embedded doc (/* will be ignored, so /** could be used to identify this type of block, with the * starting each line highlighted in blue and with the rest of the line getting markdown syntax highlighting).

Automate terraform update

Hi,
Terraform v0.12.16 says the old string interpolation syntax is deprecated:

Warning: Interpolation-only expressions are deprecated

  on ../modules/test-notifier/test_notifier.tf line 27, in resource "aws_sns_topic_policy" "default":
  27:   arn    = "${aws_sns_topic.default.arn}"

Terraform 0.11 and earlier required all non-constant expressions to be
provided via interpolation syntax, but this pattern is now deprecated. To
silence this warning, remove the "${ sequence from the start and the }"
sequence from the end of this expression, leaving just the inner expression.

Template interpolation syntax is still used to construct strings from
expressions when the template includes multiple interpolation sequences or a
mixture of literal strings and interpolations. This deprecation applies only
to templates that consist entirely of a single interpolation sequence.

Is there a way we can automate fixing these, in Vim? And/or update the syntax highlighting to match. This repo contains a tool that can be used to fix things: https://github.com/apparentlymart/terraform-clean-syntax

Ternary operators '=' aligned by g:terraform_align

When using the g:terraform_align feature of the plugin to align '=' signs it erroneously messes with the equality checks inside ternary operations for example:

"${var.envtype == "prod" ? "" : var.envtype}"

will become:

${var.envtype                                      =    = "prod" ? "" : var.envtype}

If another equals sign is placed anywhere in an adjacent line.

Saved .tf file is messed up with regards to tabs and space

Hi,

When using the plugin, doing a <tab> seems to translate to a <space>. However, looking at the file without the plugin, we see that it was not written like that; <tab> are <tab>, and it is nasty.

It seems then the plugin is only doing a visual thing.

Is that by design?

Thank you.

Disable folding?

Is it possible to disable the code folding that vim-terraform introduces?

Missing outdent if closing brace is at end of a non-empty line

See the following code, indented using vim's = command:

resource "google_compute_instance" "foo" {
  name = "foo"
  scheduling {
    preemptible = "true"
    automatic_restart = "false" }
    boot_disk { initialize_params { image = "bar" } }
  }

The last two lines – boot_disk and the final } – have one extra indent level.

Terraform command not found

Greetings,

Thanks for the creating the project, continuing #79

I have

Plugin 'hashivim/vim-terraform'
let g:terraform_fmt_on_save=1
let g:terraform_align=1

In my ~/.vimrc, installing the plugin shows up as successful when I do a :PluginInstall.

When I am trying to use the command :Terraform in any of the open .tf files, I get a response of E492: Not an editor command: Terraform

Terraform is already present on my machine.

$ which terraform
/usr/local/bin/terraform

Not sure where am I going wrong.

Running `terraform fmt` on save

First of all thank you for writer this awesome plugin it helps me.
I would like to know if this is possible, so I wanted to automate the terraform fmt whenever I press :w or save in vim.

I have followed the installation guidelines but it seems there is no terraform fmt on save there.

I hope this is going to be new feature if it is not implemented yet.

Extract HCL into a separate plugin

HCL will be used in Nomad as well as Terraform, so it's probably worthwhile to extract into a vim-hcl plugin, or to see if someone else has already done this.

No :Terraform command

I've installed the plugin with Vundle. I've added terraform binary to the $PATH variable. I can run :call terraform#fmt() and it formats my code correctly but I don't have :Terraform command. I've tried to put Plugin 'hashivim/vim-terraform' directly after Plug 'gmarik/vundle' but didn't succeed. I can't see anything about terraform in :scriptnames log. I've run make inside the ~/.vimrc/bundle/vim-terraform path and that also worked well.

I was trying to create minimal working configuration but also didn't succeed. Are there some dependencies for the plugin I don't know about. Is there some basic configuration I can rely that this plugin works well with?

\ should be followed by /, ? or & line 1242

After installation of hashivim/vim-terraform, Vim throws list of errors at startup:

E10: \ should be followed by /, ? or &
line 1243:
E10: \ should be followed by /, ? or &
line 1244:
E10: \ should be followed by /, ? or &
line 1245:
E10: \ should be followed by /, ? or &
line 1246:
E10: \ should be followed by /, ? or &
line 1247:
E10: \ should be followed by /, ? or &
line 1248:
E10: \ should be followed by /, ? or &
line 1249:
E10: \ should be followed by /, ? or &

It repeats up to number 1270, next occurences are 1281, 1283, 1287 and 1289.

hashivim/vim-terraform is at 7679927
vim 8.0.1542

Any ideas what's wrong?

filetype not getting evaluated

I use vundle. The plugin was not working and it turned out the reason was my filetype was set to tf.

Adding this to my ~/.vimrc fixed the issue for me:

augroup terraform_filetype
    au!
    autocmd BufNewFile,BufRead *tf   set filetype=terraform
augroup END

I'm surprised I needed this though. I looked at vim-terraform/ftplugin/terraform.vim and it contains this:

" By default, Vim associates .tf files with TinyFugue - tell it not to.
autocmd! filetypedetect BufRead,BufNewFile *.tf
autocmd BufRead,BufNewFile *.tf set filetype=terraform
autocmd BufRead,BufNewFile *.tfvars set filetype=terraform
autocmd BufRead,BufNewFile *.tfstate set filetype=json
autocmd BufRead,BufNewFile *.tfstate.backup set filetype=json

If I add echo "Did we get here?" to vim-terraform/ftplugin/terraform.vim to confirm if that code ran or not, I do not see the echo that would confirm the file is getting evaluated.

Any idea why vim-terraform/ftplugin/terraform.vim is not getting evaluated?

Remove various options, maybe?

I'm not sure that we'll want to do anything with this - it is, after all, possible that there are people using the features that I'm talking about. But: I reckon that this plugin would be improved by removing various features that are either unneeded complication or out-of-scope.

  • g:terraform_commentstring seems like an unnecessary piece of configuration

    • we should always just set it to the correct value, which is the default of #%s
    • if people really want to override for some reason, they can always do so in ~/.vim/after/ftplugin/terraform.vim
  • the function provided by g:terraform_remap_spacebar is in my opinion out of scope for this plugin - it's nothing to do with terraform at all, it's just setting up some mappings for folding

    • people who want to set up such mappings can do so themselves without our help
    • (I'm not even sure that it's a good mapping: I, and many others, use space as the leader key)
  • g:terraform_align is interesting, but

    • it's broken, per #57, which I have no idea how to fix
    • given the existence of terraform fmt (and this plugin's wrapping of that), it's not tremendously useful - there's a very sane workflow that goes: type without g:terraform_align, and format when done (optionally on save).
  • I'd be content to lose g:terraform_fold_sections and the foldexpr in favour of the simpler syntax-based folding per #91

You might reasonably think that I could just not turn those things on, which is true, and which is what I do.

Still, they're all backed by code which is some sort of maintenance burden.

So I thought I'd raise an issue to canvas opinion, at least.

Obviously this isn't all-or-nothing; it could be sensible to decide to drop some of those but not others.

Allow definiting path to terraform executable

I am working on different projects that have different Terraform versions.
Each project's bootstrap has the terraform version it supports.

It would be awesome if I could define the terraform binary location per project.

Set `TF_CLI_ARGS_fmt` to avoid errors when it is already in the environment

I use TF_CLI_ARGS_fmt=<path>, which points terraform fmt at the correct path without me having to specify it.

Unfortunately, it means it doesn't work with vim-terraform, since the executed command becomes terraform fmt <path> <path> and I get an error about only one arg being accepted.

To fix this issue, vim-terraform could either:

  • run with TF_CLI_ARGS_fmt= blanked
  • set TF_CLI_ARGS_FMT=<path> itself, and run with vanilla terraform fmt

`terraform fmt` fails with Terraform v0.12-beta1

I'm testing the Terraform v0.12-beta1.
https://www.hashicorp.com/blog/announcing-terraform-0-1-2-beta1

When terraform_fmt_on_save is enabled and the buffer is saved, the following error occurs:

^[[31m
^[[1m^[[31mError: ^[[0m^[[0m^[[1mOnly .tf and .tfvars files can be processed with terraform fmt^[[0m

^[[0m^[[0m^[[0m
$ terraform --version
Terraform v0.12.0-beta1
+ provider.aws v1.60.0-dev20190216h00-dev
$ LANG=C nvim --version
NVIM v0.3.2
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20181231-68781-192nq64/neovim-0.3.2/build/config -I/tmp/neovim-20181231-68781-192nq64/neovim-0.3.2/src -I/usr/local/include -I/usr/local/opt/gettext/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/tmp/neovim-20181231-68781-192nq64/neovim-0.3.2/build/src/nvim/auto -I/tmp/neovim-20181231-68781-192nq64/neovim-0.3.2/build/include
Compiled by [email protected]

Features: +acl +iconv +jemalloc +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.3.2/share/nvim"

Run :checkhealth for more info

heredoc multiline syntax highlighting doesn't work correctly when indented

It seems that the heredoc multiline syntax highlighting doesn't parse correctly when indenting the closing phrase:

broken syntax highlighting

working syntax highlighting

The former is how we format our terraform scripts, frequently breaking the vim syntax highlighting :/

I guess changing end=/^\z1/ to something like end=/^\s*\z1/ here might fix this, but I don't have experience with VIM syntax highlighting, so this might break something.

locals {
  test = <<EOF
    something something
  EOF
}

locals {
  test = "123"
}

Format on save not running when file is first created

If I start writing a non existent file with vim, and then close with :wq, auto formatting is not being run on save. However, if I then open that file again and save it (either with or without changes), auto-format runs correctly

Steps to reproduce


  1. Create a new file example.tf
  2. Write a valid terraform resource. Example:
variable "some_var" {
  type = string
  description = "this should be a real description"
}
  1. Save and exit with :wq
  2. cat the file. Formatting has not been run for it.
  3. Re-open it with vim, and save with :w. The file automatically formats itself

question about `g:terraform_align=1`

I'm hoping to get some guidance on vim-terraform's g:terraform_align=1. I've set this in my vimrc:

" terraform
let g:terraform_align = 1

However, the plugin's indentation settings aren't overriding my existing tab settings (4 space tabs...) in .tf files. Where should I start debugging this? I haven't the slightest clue..

First class syntax support

It seems this plugin has been updated for up to v0.12.x but I don't seem to see any support for syntax highlighting for first class expressions.

vim-terraform-syntax

I'm using nvim 0.3.8 with the latest version of the plugin. As you can see in the screenshot, it highlights some sections but when you look at data.template_file.test.rendered, it's only changing the syntax for data and template_file and not the full expression.

The recent changelog for terraform 0.12.14 indicates that first class expressions will eventually be enforced and I've held back on writing "${var.test}" as a first class expression simply for readability.

Add automated testing

Hello!

As the title says, I think some kind of automated unit tests would be cool.

So I spent a little while and wrote some using vader.vim. The tests look like this:

Given terraform (user maps):
  resource "aws_subnet" "dmz" {
    cidr_block = "${var.dmz_subnet["${count.index}"]}" # Comment
  }

Execute (syntax is good):
  AssertEqual 'terraStringInterp', SyntaxOf('count.index')

  " Check it closed the string and wnet back to normal mode properly.
  AssertEqual 'terraComment', SyntaxOf('Comment')

Given terraform (nested strings):
  Name = "${var.environment == "staging" ? "sgn-stg-${var.application}" : "sgn-prd-${var.application}"}" # Comment
  Other = "foo"

Execute (syntax is good):
  AssertEqual 'terraStringInterp', SyntaxOf('var.environment')
  AssertEqual 'terraComment', SyntaxOf('Comment')
  AssertEqual '', SyntaxAt(2, 1)


Given terraform (heredoc syntax);
provisioner "local-exec" {
  command = <<CMD
echo ${aws_instance.web.private_ip} >> private_ips.txt && \
my_command
CMD # Comment

  tags = {}
  }
}
;

Execute (syntax is good):
  AssertEqual 'terraStringInterp', SyntaxOf('aws_instance')
  AssertEqual 'terraHereDocText', SyntaxOf('my_command')

  " Closing CMD is still here doc
  AssertEqual 'terraHereDocText', SyntaxOf('CMD', 2)

  " block should be closed
  AssertEqual 'terraComment', SyntaxOf('Comment')

  " tags should reset syntax
  AssertEqual '', SyntaxOf("tags") 

And when run like this:

$ TERM=xterm-color \
HOME=/dev/null \
VIMINIT= \
vim -Nu \
  <(echo "filetype off | set noswapfile viminfo= rtp+=$HOME/etc/vim/plugged/vader.vim,$PWD,$PWD/after | filetype plugin indent on | syntax enable") \
  -c 'Vader! test/*'

(this command is partly more complex because of my local way I configure my vim. Go figure.)

The output looks like this:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 29 2016 13:08:33)
MacOS X (unix) version
Included patches: 1-13
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             +byte_offset     +cmdline_hist    +cursorbind      -ebcdic          +file_in_path    -gettext         +keymap          +listcmds        +mouse           +mouse_sgr       -mzscheme        +persistent_undo +quickfix        +smartindent     +tag_old_static  +textobjects     +virtualedit     +wildmenu        -xpm
+arabic          +channel         +cmdline_info    +cursorshape     +emacs_tags      +find_in_path    -hangul_input    +lambda          +localmap        -mouseshape      -mouse_sysmouse  +netbeans_intg   +postscript      +reltime         +startuptime     -tag_any_white   +timers          +visual          +windows         -xsmp
+autocmd         +cindent         +comments        +dialog_con      +eval            +float           +iconv           +langmap         -lua             +mouse_dec       +mouse_urxvt     +num64           +printer         +rightleft       +statusline      -tcl             +title           +visualextra     +writebackup     -xterm_clipboard
-balloon_eval    -clientserver    +conceal         +diff            +ex_extra        +folding         +insert_expand   +libcall         +menu            -mouse_gpm       +mouse_xterm     +packages        +profile         +ruby            -sun_workshop    +termguicolors   -toolbar         +viminfo         -X11             -xterm_save
-browse          +clipboard       +cryptv          +digraphs        +extra_search    -footer          +job             +linebreak       +mksession       -mouse_jsbterm   +multi_byte      +path_extra      +python          +scrollbind      +syntax          +terminfo        +user_commands   +vreplace        -xfontset
++builtin_terms  +cmdline_compl   +cscope          -dnd             +farsi           +fork()          +jumplist        +lispindent      +modify_fname    +mouse_netterm   +multi_lang      +perl            -python3         +signs           +tag_binary      +termresponse    +vertsplit       +wildignore      -xim
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/Users/ash/.homebrew/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -L/usr/local/lib  -o vim        -lm  -lncurses -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -F/Users/ash/.homebrew/Cellar/python/2.7.10_2/Frameworks -framework Python   -lruby.2.0.0 -lobjc

Starting Vader: 1 suite(s), 3 case(s)
  Starting Vader: /Users/ash/code/tmp/vim-terraform/test/syntax.vader
    (1/3) [  GIVEN] user maps
    (1/3) [EXECUTE] syntax is good
    (2/3) [  GIVEN] nested strings
    (2/3) [EXECUTE] syntax is good
    (3/3) [  GIVEN] heredoc syntax
    (3/3) [EXECUTE] syntax is good
  Success/Total: 3/3
Success/Total: 3/3 (assertions: 10/10)
Elapsed time: 0.045476 sec.

So my question. Does this seem useful? If so which automated testing service would you like to use? I would normally use Travis or CircleCI. Do you have any preferences?

Terraform 0.10.0 ./update_syntax.rb breaks

Terraform no longer keeps all of its providers in the main terraform repository. They have split off to https://github.com/terraform-providers. As a result of this, the syntax/terraform.vim file will get trashed.

A potential solution is to scan the terraform-providers github user via the github api, list all their projects, download the default branch and make sure it's at the latest revision, and update the syntax file accordingly. This will require a rewrite of the update_syntax.rb file.

Error with TerraformFmt and terraform 0.12

Hi,

Since my upgrade to tf 0.12, the TerraformFmt command doesn't work anymore :

[[31m
^[[1m^[[31mError: ^[[0m^[[0m^[[1mNo file or directory at ../../../../../var/folders/cc/y5w0cx2510xb7lwvlvqg0gkw0000gn/T/v7ive4X/11.tf^[[0m

^[[0m^[[0m^[[0m

I don't know anything about vim plugin so any help would be appreciated.

Thanks,

installation via vundle

thanks for the project :),

would it be possible to add the instructions for installing using vundle?

Regards

vim-terraform doesnt follow sym links instead it creates new file when edited

I have a sym link which when I decide to edit it doesn't edit the original file but instead it creates a new file. This happens with latest vim-terraform.

=== reproducing ===
cat > variables.tf
variable "var1" {
default = "example"
}
mkdir test && cd test
ln -s ../variables.tf variables.tf

And then if cd to test and I edit variables.tf it destroys the sym link and create a file variables.tf

Escaped slashes at end of string ignores closing quote

The escaped slash at the end of the string "\"\\" causes the closing double quote to be ignored.

The following declaration of the skip in terraValueString fixes that, and some related cases:

syn region terraValueString   start=/"/ skip=/\([^\\]\(\\\\\)*\)\@<=\\"/ end=/"/ contains=terraStringInterp`

added as maintainer

hello,

i would like to be added as a maintainer.

vim and terraform are probably my 2 favorite technologies. i've been using Vim for 12 years and Terraform for 2 years extensively.

nerdcommenter & vim-gitgutter are awesome vim plugins i like to use. oh, yeah, and vim-terraform!

i made a small vim plugin here: https://github.com/tkjef/vim_github_urls

thanks,
tkjef

different name for augroup?

I defined the following settings in my nvim/init.vim file and was a little confused they weren't being applied.

    augroup terraform
        autocmd BufEnter *.tf set softtabstop=2
        autocmd BufEnter *.tf set tabstop=2
        autocmd BufEnter *.tf set shiftwidth=2

        autocmd FileType hcl,terraform autocmd BufWritePre <buffer> :call TerraformFormat()<CR>
        autocmd BufRead,BufNewFile *.tf setfiletype hcl
    augroup END

It took me a lot of time to figure out that there was already a terraform augroup defined.

Is there a way to warn about this conflict instead of silently ignoring my changes?

Is it possible to fold all sections at start time?

Vim starts with all sections unfolded for some reason.
I put

let g:terraform_remap_spacebar=1

and

let g:terraform_fold_sections=1

in .vimrc and folding works as expected by space key.
If it is by design, is there a way to make vim fold all sections at the start? Or maybe fold/unfold them all with some command.

No :Terraform command

Hello. Continuation of #82 because that issue is stale. I'm also running through the solution there, it looks like the commit placed as a solution to that issue isn't working for me. I already have the line autocmd! filetypedetect BufRead,BufNewFile *.tf in my ftdetect/terraform.vim file. Extra information, I'm using VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 14 2018 05:28:49) and an old version of terraform Terraform v0.11.13. No terraform files show up in :scriptnames. Any thoughts?

#-commented lines are indented

#-commented lines are indented.

resource "google_compute_instance" "foo" {
  name = "foo"
  #scheduling {
    #preemptible = "true"
    #automatic_restart = "false"
    #}
    boot_disk { initialize_params { image = "bar" } }
  }

Terraform fmt doesn't work correctly

My .vimrc:

call plug#begin('~/.vim/plugged')
Plug 'hashivim/vim-terraform'
call plug#end()

" terraform stuff
let g:terraform_align=1
let g:terraform_fmt_on_save=1

Then
vim vpc/main.tf

And I get:

 NORMAL  vpc/main.tf                                                                                                                                                                      terraform  utf-8[unix]   11% ☰    1/9 ㏑ :  1 
^[[31m
^[[1m^[[31mError: ^[[0m^[[0m^[[1mOnly .tf and .tfvars files can be processed with terraform fmt^[[0m

^[[0m^[[0m^[[0m
"vpc/main.tf" 9L, 141C written

This is driving me insane.

terraform fmt works on the file externally.

terraform 0.12.5

syntax highligting breaks when using ternary operator with strings

With this expression:

  tags {
    Name              = "${var.environment == "staging" ? "sgn-stg-${var.application}" : "sgn-prd-${var.application}"}"
    "sgn:application" = "${var.application}"
    "sgn:environment" = "${var.environment}"
    "sgn:deployment"  = "${var.application}:${var.environment}"
  }

syntax highlighting seems to break for the rest of the document, and the highlighting itself looks weird:

screen shot 2017-07-08 at 16 18 43

sed: 1: "s/Terraform//gI

./update_automagic.sh 0.12.3

result:

sed: 1: "s/Terraform//gI
": bad flag in substitute command: 'I'
-) You are trying to update this script for terraform 0.12.3 while you have
   terraform  installed at /usr/local/bin/terraform.
   Please update your local terraform before using this script.

env:

OS: macOS Mojave(10.14.4)

bug?

Syntax highlighting for Terraform 0.7

The changes to string interpolation in TF 0.7 have made it possible to nest and evaluate interpolations, but this plugin's syntax highlighting doesn't recognize this change.

hashicorp/terraform#6792, at the bottom of that timeline it is stated:

...when there is a string literal inside an interpolation (${ ... }) that string can itself contain interpolations. These nested interpolations can then contain their own strings, with their own interpolations again.

Here's a concrete example of what doesn't highlight well:

resource "aws_subnet" "svc" {
    count = "${length(var.aws_zones)}"
    vpc_id = "${aws_vpc.main.id}"
    cidr_block = "${var.svc_subnets["zone${count.index}"]}"
    availability_zone = "${var.aws_zones["zone${count.index}"]}"

    tags {
        Name = "${var.region}-${var.env}-svc-${count.index}"
        Stack = "${var.stack}"
    }
}

Issue with symlink

Issue

Hello, it seems there is an issue regarding symlink handling.

When I edit a file opened through a symlink and call :TerrafromFmt, the symlink is replaced by a new file and the original file is not updated.

How to reproduce

echo """
terraform {
                         backend "s3" {}
}
""" > test.tf
ln -s test.tf link.tf
file link.tf
# link.tf: symbolic link to test.tf

vim link.tf
# call :TerraformFmt
file link.tf
# link.tf: ASCII text
# it should be symbolic link to test.tf

I am using an up to date version of the plugin, vim version 8.0 and Linux 4.11.

Let me know if you may need any information. Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.