Skip to content

Commit 5c1162f

Browse files
committed
Add custom highlighting for the common FQCN names
Thanks to @gardar via pearofducks#136 for kicking this feature off!
1 parent 93798e8 commit 5c1162f

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ Accepts any syntax group name from `:help E669` - e.g. _Comment_, _Constant_, _I
108108

109109
*Note:* Defaults to 'Structure' when not set.
110110

111+
##### g:ansible_normal_keywords_highlight
112+
`let g:ansible_fqcn_highlight = 'Constant'`
113+
114+
Accepts any syntax group name from `:help E669` - e.g. _Comment_, _Constant_, _Identifier_
115+
116+
*Note:* Defaults to 'Statement' when not set.
117+
118+
*Note:* The `.` in the FCQN can also be highlighted via a modification to a [Vim syntax internal](https://stackoverflow.com/questions/69781626/how-to-do-syntax-highlighting-for-a-keyword-containing-a-period). This plugin will not do this automatically.
119+
111120
##### g:ansible_normal_keywords_highlight
112121
`let g:ansible_normal_keywords_highlight = 'Constant'`
113122

syntax/ansible.vim

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Vim syntax file
22
" Language: Ansible YAML/Jinja templates
33
" Maintainer: Dave Honneffer <[email protected]>
4-
" Last Change: 2018.02.08
4+
" Last Change: 2023.10.29
55

66
if !exists("main_syntax")
77
let main_syntax = 'yaml'
@@ -99,6 +99,13 @@ if exists("g:ansible_extra_keywords_highlight")
9999
endif
100100
endif
101101

102+
execute 'syn keyword ansible_fqcn_keywords ansible builtin ansible.builtin. containedin='.s:yamlKey.' contained'
103+
if exists("g:ansible_fqcn_highlight")
104+
execute 'highlight link ansible_fqcn_keywords '.g:ansible_fqcn_highlight
105+
else
106+
highlight default link ansible_fqcn_keywords Statement
107+
endif
108+
102109
execute 'syn keyword ansible_normal_keywords
103110
\ include include_role include_tasks include_vars import_role import_playbook import_tasks
104111
\ when changed_when failed_when block rescue always notify listen register

0 commit comments

Comments
 (0)