(Neo)Vim Terraform Completion with Linter - Demos
IMPORTANT: This plugin now allow version based completion
Terraform Module is supported(though there might be bugs)
(R) for Require , (O) for Optional and (B) for Block
- vim-terraform (For FileType) (Optional not require for completion)
- vim-syntastic (Only for Linter)
- neomake (Only for Linter, Neovim)
- Deoplete (Neovim only, for completion)
- Ctags & tagbar (Optional for Tag Sidebar)
Require +ruby
or +ruby/dyn
for vim & json gem for ruby as well
Snippets completion is done through <C-X><C-K>
NeoBundle 'hashivim/vim-terraform'
NeoBundle 'vim-syntastic/syntastic'
NeoBundle 'juliosueiras/vim-terraform-completion'
Plug 'hashivim/vim-terraform'
Plug 'vim-syntastic/syntastic'
Plug 'juliosueiras/vim-terraform-completion'
" Minimal Configuration
set nocompatible
syntax on
filetype plugin indent on
call plug#begin('~/.vim/plugged')
" (Optinal) for Tag Sidebar
" Plug 'majutsushi/tagbar'
Plug 'hashivim/vim-terraform'
Plug 'vim-syntastic/syntastic'
Plug 'juliosueiras/vim-terraform-completion'
call plug#end()
" Syntastic Config
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" (Optional)Remove Info(Preview) window
set completeopt-=preview
" (Optional)Hide Info(Preview) window after completions
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" (Optional) Enable terraform plan to be include in filter
let g:syntastic_terraform_tffilter_plan = 1
" (Optional) Default: 0, enable(1)/disable(0) plugin's keymapping
let g:terraform_completion_keys = 1
" (Optional) Default: 1, enable(1)/disable(0) terraform module registry completion
let g:terraform_registry_module_completion = 0
put this in your init.vim
let g:deoplete#omni_patterns = {}
let g:deoplete#omni_patterns.terraform = '[^ *\t"{=$]\w*'
let g:deoplete#enable_at_startup = 1
call deoplete#initialize()
NOTE: For newer version of deoplete if the above doesn't work
let g:deoplete#omni_patterns = {}
call deoplete#custom#option('omni_patterns', {
\ 'complete_method': 'omnifunc',
\ 'terraform': '[^ *\t"{=$]\w*',
\})
call deoplete#initialize()
by default , all providers uses the latest version, but you can add a file call .tfcompleterc
under working directory, and content can be this:
vsphere=1.0.3
aws=0.1.0
using the syatax of <provider>=<version>
By default no community providers is enable, to use one, first refer to COMMUNITY_PROVIDER_VERSIONS.md , then add a .tfcompleterc
to your current working dir , for ex. to use Generic REST Api Provider, the .tfcompleterc would look like
restapi=master
To use completion for google beta provider, please use .tfcompleterc
and put google=beta_<version>
Todolist
- Adapt to Upcoming terraform 0.10
- Added a bot for auto pushing of new provider version
- (WIP) Refactoring Regex for linter and completion, and Trying out on api based(so it can integrade with other editor) solution
- (WIP) More test cases
- Support for Neomake(Require further testing)
- Run terraform plan and output to a new window(
<leader>rr
) - Async Run support(For Neovim/Vim 8)
- Move regex code to a json(for easier extension)
- Test from zero to useful setup using Docker
- Jump Reference (Ctrl-L first time to jump to resource definition, second time on the same line to jump back)
- Show Doc (Ctrl-K)
- Provide config and example
- Integrate Basic
terraform validate
andtflint
into Synstatic - Added a custom linter for providing a better error
- (WIP) Better linter
- (WIP) Full Snippets
NOTE: enabling deep check for tflint can be a bit slow
NOTE: To use tffilter
please add export PATH=$PATH:/path/to/this/plugin/bin
to your bashrc or zshrc
Todolist
- (Require more work) Lookup Attributes data using terraform.tfstate
- Evaluate Interpolation
- (WIP) Custom Provider completion, might do Rest API style due to unstable custom provider
- Provider
- Completion for functions(file,etc) and basic resource arguments(count,lifecyle, etc)
- Module (Make sure you run
terraform get
beforehand) - Data
- Resource(with Provider)
- Parameter
- Adding Info to Argument and Attribute(Type not including ,since Info already indicate it)
- Variable
- Cleaner code
- local/offline
- Add completion tags, ingress, and other subblock
- Further seperate data source from resource
- Add Completion for hcl
- Completion for Sublock(Indicate by
Type(B)
)
- Add Travis-CI for testing, and ensuring the completion is outputing the right completion
- Look into the new module registry (Now support module name completion)
- Add config for allowing multiple version for providers
- Provider Model Extraction script adapted from Intellij-hcl
- Completion data is from Terraform Official Documentation and Model data from Intellij-HCL
- Folding adapted from vim-terraform