├── README.md ├── ftdetect └── hcl.vim ├── ftplugin └── hcl.vim ├── indent └── hcl.vim └── syntax └── hcl.vim /README.md: -------------------------------------------------------------------------------- 1 | # vim-hcl 2 | 3 | Vim syntax for [HCL](https://github.com/hashicorp/hcl). 4 | 5 | ## Installation 6 | 7 | ### Pathogen 8 | 9 | Set up [Pathogen](https://github.com/tpope/vim-pathogen) then clone/submodule this repo into `~/.vim/bundle/vim-hcl`, or wherever you've pointed your Pathogen. 10 | 11 | ### NeoBundle 12 | 13 | Set up [NeoBundle](https://github.com/Shougo/neobundle.vim) then add `NeoBundle 'b4b4r07/vim-hcl'` to your vimrc and run `:NeoBundleInstall` from a fresh vim. 14 | 15 | ## Contributing 16 | 17 | Contributions are very welcome! Just open a PR. 18 | -------------------------------------------------------------------------------- /ftdetect/hcl.vim: -------------------------------------------------------------------------------- 1 | autocmd BufNewFile,BufRead *.hcl set filetype=hcl 2 | autocmd BufNewFile,BufRead *.nomad set filetype=hcl 3 | autocmd BufNewFile,BufRead *.tf set filetype=hcl 4 | autocmd BufNewFile,BufRead Appfile set filetype=hcl 5 | -------------------------------------------------------------------------------- /ftplugin/hcl.vim: -------------------------------------------------------------------------------- 1 | " File: ftplugin/hcl.vim 2 | " Author: BABAROT 3 | " Description: FileType Plugin for HCL 4 | " Last Change: Nob 05, 2015 5 | 6 | if exists('b:did_ftplugin') 7 | finish 8 | endif 9 | let b:did_ftplugin = 1 10 | 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | setlocal commentstring=#\ %s 15 | 16 | " Add NERDCommenter delimiters 17 | 18 | let s:delims = { 'left': '#' } 19 | if exists('g:NERDDelimiterMap') 20 | if !has_key(g:NERDDelimiterMap, 'hcl') 21 | let g:NERDDelimiterMap.hcl = s:delims 22 | endif 23 | elseif exists('g:NERDCustomDelimiters') 24 | if !has_key(g:NERDCustomDelimiters, 'hcl') 25 | let g:NERDCustomDelimiters.hcl = s:delims 26 | endif 27 | else 28 | let g:NERDCustomDelimiters = { 'hcl': s:delims } 29 | endif 30 | unlet s:delims 31 | 32 | let b:undo_ftplugin = "" 33 | 34 | let &cpo = s:save_cpo 35 | unlet s:save_cpo 36 | 37 | " vim: set et sw=4 ts=4: 38 | -------------------------------------------------------------------------------- /indent/hcl.vim: -------------------------------------------------------------------------------- 1 | if exists('b:did_indent') 2 | finish 3 | endif 4 | 5 | let b:did_indent = 1 6 | 7 | " cindent seems to work adequately with HCL's brace-y syntax 8 | setlocal cindent 9 | 10 | " don't de-indent comments (cindent treats them like preprocessor directives) 11 | setlocal cinkeys-=0# 12 | -------------------------------------------------------------------------------- /syntax/hcl.vim: -------------------------------------------------------------------------------- 1 | 2 | if exists("b:current_syntax") 3 | finish 4 | endif 5 | 6 | syn match hclEqual '=' 7 | syn match hclSimpleString '"[^\"]*"' 8 | syn region hclComment display oneline start='\%\(^\|\s\)#' end='$' 9 | syn region hclComment display oneline start='\%\(^\|\s\)//' end='$' 10 | syn region hclInterpolation display oneline start='(' end=')' contains=hclInterpolation,hclSimpleString 11 | syn region hclSmartString display oneline start='"' end='"\s*$' contains=hclInterpolation 12 | 13 | syn keyword hclRootKeywords variable provider resource nextgroup=hclString,hclString skipwhite 14 | syn keyword hclRootKeywords default nextgroup=hclEquals skipwhite 15 | 16 | 17 | syn keyword hclAwsResourcesKeywords availability_zones desired_capacity force_delete health_check_grace_period health_check_type launch_configuration load_balancers max_size min_size name vpc_zone_identifier nextgroup=hclEquals,hclString skipwhite 18 | syn keyword hclAwsResourcesKeywords allocated_storage availability_zone backup_retention_period backup_window db_subnet_group_name engine engine_version final_snapshot_identifier identifier instance_class iops maintenance_window multi_az name password port publicly_accessible security_group_names skip_final_snapshot username vpc_security_group_ids nextgroup=hclEquals,hclString skipwhite 19 | syn keyword hclAwsResourcesKeywords cidr description ingress name security_group_id security_group_name security_group_owner_id source_security_group_id nextgroup=hclEquals,hclString skipwhite 20 | syn keyword hclAwsResourcesKeywords description name subnet_ids nextgroup=hclEquals,hclString skipwhite 21 | syn keyword hclAwsResourcesKeywords instance vpc nextgroup=hclEquals,hclString skipwhite 22 | syn keyword hclAwsResourcesKeywords availability_zones health_check healthy_threshold instance_port instance_protocol instances internal interval lb_port lb_protocol listener name security_groups ssl_certificate_id subnets target timeout unhealthy_threshold nextgroup=hclEquals,hclString skipwhite 23 | syn keyword hclAwsResourcesKeywords ami associate_public_ip_address availability_zone ebs_optimized iam_instance_profile instance_type key_name private_ip security_groups source_dest_check subnet_id tags user_data nextgroup=hclEquals,hclString skipwhite 24 | syn keyword hclAwsResourcesKeywords vpc_id nextgroup=hclEquals,hclString skipwhite 25 | syn keyword hclAwsResourcesKeywords iam_instance_profile image_id instance_type key_name name name_prefix security_groups user_data nextgroup=hclEquals,hclString skipwhite 26 | syn keyword hclAwsResourcesKeywords name records ttl type zone_id nextgroup=hclEquals,hclString skipwhite 27 | syn keyword hclAwsResourcesKeywords name nextgroup=hclEquals,hclString skipwhite 28 | syn keyword hclAwsResourcesKeywords route_table_id subnet_id nextgroup=hclEquals,hclString skipwhite 29 | syn keyword hclAwsResourcesKeywords cidr_block gateway_id instance_id route vpc_id nextgroup=hclEquals,hclString skipwhite 30 | syn keyword hclAwsResourcesKeywords acl bucket nextgroup=hclEquals,hclString skipwhite 31 | syn keyword hclAwsResourcesKeywords cidr_blocks description from_port ingress name owner_id protocol security_groups self tags to_port vpc_id nextgroup=hclEquals,hclString skipwhite 32 | syn keyword hclAwsResourcesKeywords availability_zone- cidr_block map_public_ip_on_launch vpc_id nextgroup=hclEquals,hclString skipwhite 33 | syn keyword hclAwsResourcesKeywords cidr_block enable_dns_hostnames enable_dns_support tags nextgroup=hclEquals,hclString skipwhite 34 | 35 | 36 | hi def link hclComment Comment 37 | hi def link hclEqual Operator 38 | hi def link hclRootKeywords Statement 39 | hi def link hclAwsResourcesKeywords Type 40 | hi def link hclSmartString String 41 | hi def link hclInterpolation String 42 | hi def link hclSimpleString PreProc 43 | 44 | let b:current_syntax = "hcl" 45 | --------------------------------------------------------------------------------