Add hcl support, closes #403

This commit is contained in:
Adam Stankiewicz 2019-06-08 13:32:04 +02:00
parent af763ef221
commit 8f2a71643a
8 changed files with 118 additions and 347 deletions

View File

@ -10,7 +10,7 @@ A collection of language packs for Vim.
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
- It **installs and updates 120+ times faster** than the <!--Package Count-->138<!--/Package Count--> packages it consists of.
- It **installs and updates 120+ times faster** than the <!--Package Count-->139<!--/Package Count--> packages it consists of.
- Solid syntax and indentation support (other features skipped). Only the best language packs.
- All unnecessary files are ignored (like enormous documentation from php support).
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
@ -92,6 +92,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [haproxy](https://github.com/CH-DanReif/haproxy.vim) (syntax)
- [haskell](https://github.com/neovimhaskell/haskell-vim) (syntax, indent, ftplugin)
- [haxe](https://github.com/yaymukund/vim-haxe) (syntax)
- [hcl](https://github.com/b4b4r07/vim-hcl) (syntax, indent, ftplugin)
- [hive](https://github.com/zebradil/hive.vim) (syntax, ftplugin)
- [html5](https://github.com/othree/html5.vim) (syntax, indent, autoload, ftplugin)
- [i3](https://github.com/mboughaba/i3config.vim) (syntax, ftplugin)
@ -166,7 +167,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [terraform](https://github.com/hashivim/vim-terraform) (syntax, indent, autoload, ftplugin)
- [textile](https://github.com/timcharper/textile.vim) (syntax, ftplugin)
- [thrift](https://github.com/solarnz/thrift.vim) (syntax)
- [tmux](https://github.com/keith/tmux.vim) (syntax, ftplugin)
- [tmux](https://github.com/ericpruitt/tmux.vim) ()
- [tomdoc](https://github.com/wellbredgrapefruit/tomdoc.vim) (syntax)
- [toml](https://github.com/cespare/vim-toml) (syntax, ftplugin)
- [tptp](https://github.com/c-cube/vim-tptp) (syntax)

1
build
View File

@ -200,6 +200,7 @@ PACKS="
haproxy:CH-DanReif/haproxy.vim
haskell:neovimhaskell/haskell-vim
haxe:yaymukund/vim-haxe
hcl:b4b4r07/vim-hcl
hive:zebradil/hive.vim
html5:othree/html5.vim
i3:mboughaba/i3config.vim

View File

@ -542,6 +542,16 @@ autocmd BufNewFile,BufRead *.hx setf haxe
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'hcl') == -1
augroup filetypedetect
" hcl, from hcl.vim in b4b4r07/vim-hcl
autocmd BufNewFile,BufRead *.hcl set filetype=hcl
autocmd BufNewFile,BufRead *.nomad set filetype=hcl
autocmd BufNewFile,BufRead *.tf set filetype=hcl
autocmd BufNewFile,BufRead Appfile set filetype=hcl
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'hive') == -1
augroup filetypedetect
" hive, from hive.vim in zebradil/hive.vim
@ -1331,13 +1341,6 @@ au BufNewFile,BufRead *.thrift setlocal filetype=thrift
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'tmux') == -1
augroup filetypedetect
" tmux, from tmux.vim in keith/tmux.vim
autocmd BufNewFile,BufRead {.,}tmux*.conf* setfiletype tmux
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'toml') == -1
augroup filetypedetect
" toml, from toml.vim in cespare/vim-toml

41
ftplugin/hcl.vim Normal file
View File

@ -0,0 +1,41 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'hcl') != -1
finish
endif
" File: ftplugin/hcl.vim
" Author: BABAROT <b4b4r07@gmail.com>
" Description: FileType Plugin for HCL
" Last Change: Nob 05, 2015
if exists('b:did_ftplugin')
finish
endif
let b:did_ftplugin = 1
let s:save_cpo = &cpo
set cpo&vim
setlocal commentstring=#\ %s
" Add NERDCommenter delimiters
let s:delims = { 'left': '#' }
if exists('g:NERDDelimiterMap')
if !has_key(g:NERDDelimiterMap, 'hcl')
let g:NERDDelimiterMap.hcl = s:delims
endif
elseif exists('g:NERDCustomDelimiters')
if !has_key(g:NERDCustomDelimiters, 'hcl')
let g:NERDCustomDelimiters.hcl = s:delims
endif
else
let g:NERDCustomDelimiters = { 'hcl': s:delims }
endif
unlet s:delims
let b:undo_ftplugin = ""
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sw=4 ts=4:

View File

@ -1,5 +0,0 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'tmux') != -1
finish
endif
setlocal commentstring=#\ %s

15
indent/hcl.vim Normal file
View File

@ -0,0 +1,15 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'hcl') != -1
finish
endif
if exists('b:did_indent')
finish
endif
let b:did_indent = 1
" cindent seems to work adequately with HCL's brace-y syntax
setlocal cindent
" don't de-indent comments (cindent treats them like preprocessor directives)
setlocal cinkeys-=0#

48
syntax/hcl.vim Normal file
View File

@ -0,0 +1,48 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'hcl') != -1
finish
endif
if exists("b:current_syntax")
finish
endif
syn match hclEqual '='
syn match hclSimpleString '"[^\"]*"'
syn region hclComment display oneline start='\%\(^\|\s\)#' end='$'
syn region hclComment display oneline start='\%\(^\|\s\)//' end='$'
syn region hclInterpolation display oneline start='(' end=')' contains=hclInterpolation,hclSimpleString
syn region hclSmartString display oneline start='"' end='"\s*$' contains=hclInterpolation
syn keyword hclRootKeywords variable provider resource nextgroup=hclString,hclString skipwhite
syn keyword hclRootKeywords default nextgroup=hclEquals skipwhite
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
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
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
syn keyword hclAwsResourcesKeywords description name subnet_ids nextgroup=hclEquals,hclString skipwhite
syn keyword hclAwsResourcesKeywords instance vpc nextgroup=hclEquals,hclString skipwhite
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
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
syn keyword hclAwsResourcesKeywords vpc_id nextgroup=hclEquals,hclString skipwhite
syn keyword hclAwsResourcesKeywords iam_instance_profile image_id instance_type key_name name name_prefix security_groups user_data nextgroup=hclEquals,hclString skipwhite
syn keyword hclAwsResourcesKeywords name records ttl type zone_id nextgroup=hclEquals,hclString skipwhite
syn keyword hclAwsResourcesKeywords name nextgroup=hclEquals,hclString skipwhite
syn keyword hclAwsResourcesKeywords route_table_id subnet_id nextgroup=hclEquals,hclString skipwhite
syn keyword hclAwsResourcesKeywords cidr_block gateway_id instance_id route vpc_id nextgroup=hclEquals,hclString skipwhite
syn keyword hclAwsResourcesKeywords acl bucket nextgroup=hclEquals,hclString skipwhite
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
syn keyword hclAwsResourcesKeywords availability_zone- cidr_block map_public_ip_on_launch vpc_id nextgroup=hclEquals,hclString skipwhite
syn keyword hclAwsResourcesKeywords cidr_block enable_dns_hostnames enable_dns_support tags nextgroup=hclEquals,hclString skipwhite
hi def link hclComment Comment
hi def link hclEqual Operator
hi def link hclRootKeywords Statement
hi def link hclAwsResourcesKeywords Type
hi def link hclSmartString String
hi def link hclInterpolation String
hi def link hclSimpleString PreProc
let b:current_syntax = "hcl"

View File

@ -1,333 +0,0 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'tmux') != -1
finish
endif
" Vim syntax file
" Language: tmux(1) configuration file
" Maintainer: Tiago Cunha <tcunha@users.sourceforge.net>
" License: This file is placed in the public domain.
"
" To install this file:
"
" - Drop the file in the syntax directory into runtimepath (such as
" ~/.vim/syntax/tmux.vim).
" - Make the filetype recognisable by adding the following to filetype.vim
" (~/.vim/filetype.vim):
"
" augroup filetypedetect
" au BufNewFile,BufRead .tmux.conf*,tmux.conf* setf tmux
" augroup END
"
" - Switch on syntax highlighting by adding "syntax enable" to .vimrc.
"
if v:version < 600
syntax clear
elseif exists('b:current_syntax')
finish
endif
setlocal iskeyword+=-
syntax case match
syn keyword tmuxAction any current default none
syn keyword tmuxBoolean off on
syn keyword tmuxCmds
\ attach
\ attach-session
\ bind
\ bind-key
\ break-pane
\ breakp
\ capture-pane
\ capturep
\ choose-buffer
\ choose-client
\ choose-session
\ choose-tree
\ choose-window
\ clear-history
\ clearhist
\ clock-mode
\ command-prompt
\ confirm
\ confirm-before
\ copy-mode
\ copy-mode-vi
\ delete-buffer
\ deleteb
\ detach
\ detach-client
\ display
\ display-message
\ display-panes
\ displayp
\ find-window
\ findw
\ has
\ has-session
\ if
\ if-shell
\ info
\ join-pane
\ joinp
\ kill-pane
\ kill-server
\ kill-session
\ kill-window
\ killp
\ killw
\ last
\ last-pane
\ last-window
\ lastp
\ link-window
\ linkw
\ list-buffers
\ list-clients
\ list-commands
\ list-keys
\ list-panes
\ list-sessions
\ list-windows
\ load-buffer
\ loadb
\ lock
\ lock-client
\ lock-server
\ lock-session
\ lockc
\ locks
\ ls
\ lsb
\ lsc
\ lscm
\ lsk
\ lsp
\ lsw
\ move-pane
\ move-window
\ movep
\ movew
\ new
\ new-session
\ new-window
\ neww
\ next
\ next-layout
\ next-window
\ nextl
\ paste-buffer
\ pasteb
\ path
\ pipe-pane
\ pipep
\ prev
\ previous-layout
\ previous-window
\ prevl
\ refresh
\ refresh-client
\ rename
\ rename-session
\ rename-window
\ renamew
\ resize-pane
\ resizep
\ respawn-pane
\ respawn-window
\ respawnp
\ respawnw
\ rotate-window
\ rotatew
\ run
\ run-shell
\ save-buffer
\ saveb
\ select-layout
\ select-pane
\ select-window
\ selectl
\ selectp
\ selectw
\ send
\ send-keys
\ send-prefix
\ server-info
\ set
\ set-buffer
\ set-environment
\ set-hook
\ set-option
\ set-window-option
\ setb
\ setenv
\ setw
\ show
\ show-buffer
\ show-environment
\ show-hooks
\ show-messages
\ show-options
\ show-window-options
\ showb
\ showenv
\ showmsgs
\ showw
\ source
\ source-file
\ split-window
\ splitw
\ start
\ start-server
\ suspend-client
\ suspendc
\ swap-pane
\ swap-window
\ swapp
\ swapw
\ switch-client
\ switchc
\ unbind
\ unbind-key
\ unlink-window
\ unlinkw
\ wait
\ wait-for
syn keyword tmuxOptsSet
\ assume-paste-time
\ base-index
\ bell-action
\ bell-on-alert
\ buffer-limit
\ default-command
\ default-shell
\ default-terminal
\ destroy-unattached
\ detach-on-destroy
\ display-panes-active-colour
\ display-panes-colour
\ display-panes-time
\ display-time
\ escape-time
\ exit-unattached
\ focus-events
\ history-file
\ history-limit
\ lock-after-time
\ lock-command
\ message-command-style
\ message-limit
\ message-style
\ mouse
\ prefix
\ prefix2
\ quiet
\ renumber-windows
\ repeat-time
\ set-clipboard
\ set-remain-on-exit
\ set-titles
\ set-titles-string
\ status
\ status-bg
\ status-fg
\ status-interval
\ status-justify
\ status-keys
\ status-left
\ status-left-length
\ status-left-style
\ status-position
\ status-right
\ status-right-length
\ status-right-style
\ status-style
\ terminal-overrides
\ update-environment
\ visual-activity
\ visual-bell
\ visual-silence
\ word-separators
syn keyword tmuxOptsSetw
\ aggressive-resize
\ allow-rename
\ alternate-screen
\ automatic-rename
\ automatic-rename-format
\ clock-mode-colour
\ clock-mode-style
\ force-height
\ force-width
\ main-pane-height
\ main-pane-width
\ message-attr
\ message-bg
\ message-fg
\ mode-keys
\ mode-style
\ monitor-activity
\ monitor-silence
\ other-pane-height
\ other-pane-width
\ pane-active-border-bg
\ pane-active-border-fg
\ pane-active-border-style
\ pane-base-index
\ pane-border-fg
\ pane-border-style
\ remain-on-exit
\ synchronize-panes
\ window-active-style
\ window-status-activity-attr
\ window-status-activity-bg
\ window-status-activity-fg
\ window-status-activity-style
\ window-status-bell-style
\ window-status-bg
\ window-status-current-attr
\ window-status-current-bg
\ window-status-current-fg
\ window-status-current-format
\ window-status-current-style
\ window-status-fg
\ window-status-format
\ window-status-last-style
\ window-status-separator
\ window-status-style
\ window-style
\ wrap-search
\ xterm-keys
syn keyword tmuxTodo FIXME NOTE TODO XXX contained
syn match tmuxKey /\(C-\|M-\|\^\)\+\S\+/ display
syn match tmuxNumber /\<\d\+\>/ display
syn match tmuxOptions /\s-\a\+/ display
syn match tmuxVariable /\w\+=/ display
syn match tmuxVariableExpansion /\${\=\w\+}\=/ display
" Comments can span multiple lines, when the newline is escaped
" (with a single) backslash at the end.
syn region tmuxComment start=/#/ skip=/\\\@<!\\$/ end=/$/ contains=tmuxTodo
syn region tmuxString start=/"/ end=/"/ display oneline
syn region tmuxString start=/'/ end=/'/ display oneline
hi def link tmuxAction Boolean
hi def link tmuxBoolean Boolean
hi def link tmuxCmds Keyword
hi def link tmuxComment Comment
hi def link tmuxKey Special
hi def link tmuxNumber Number
hi def link tmuxOptions Identifier
hi def link tmuxOptsSet Function
hi def link tmuxOptsSetw Function
hi def link tmuxString String
hi def link tmuxTodo Todo
hi def link tmuxVariable Constant
hi def link tmuxVariableExpansion Constant
let b:current_syntax = 'tmux'