pearofducks / ansible-vim Goto Github PK
View Code? Open in Web Editor NEWA vim plugin for syntax highlighting Ansible's common filetypes
License: MIT License
A vim plugin for syntax highlighting Ansible's common filetypes
License: MIT License
Hey,
I'm more or less new to ansible and im working on writing a playbook using the generic format as follows
.
├── roles
│ └── sshd
│ ├── defaults
│ │ └── main.yml
│ ├── files
│ │ └── laptop.pub
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── README.md
│ ├── tasks
│ │ └── main.yml
│ ├── templates
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ └── main.yml
└── sshd.yml
While editing the sshd.yml file which is the main playbook and starting it off with
---
- name: configure sshd
then i want to add the hosts: setting, it unindents it once i type ':' which is super annoying. According to what i've found this is the right format so im not sure whats going on.
What I'm looking for
---
- name: sshd configs
hosts: all
what im getting
---
- name: sshd configs
hosts: all
Thanks!
So I just started using this plugin, is really awesome, and thanks for it.
I noticed that the snippets where in multiline, so I went and check and saw that it is a parameter passed to generate.py
but as it is wrapped in generate.sh
it won't receive the parameter.
Also, this could be mentioned in the root readme so people is aware of this option
I got an error message when run into vim
"roles/mail/tasks/main.yml" 74L, 2592C
Error detected while processing /home/mini/.vim/bundle/vim-ansible-yaml/syntax/ansible.vim:
line 48:
E121: Undefined variable: main_syntax
E15: Invalid expression: main_syntax == 'ansible'
Press ENTER or type command to continue
vim --version
vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)
Included patches: 1-1689
Extra patches: 8.0.0056
Modified by [email protected]
Compiled by [email protected]
Huge version with GTK2 GUI. Features included (+) or not (-):
+acl +farsi +mouse_netterm +tag_binary
+arabic +file_in_path +mouse_sgr +tag_old_static
+autocmd +find_in_path -mouse_sysmouse -tag_any_white
+balloon_eval +float +mouse_urxvt +tcl
+browse +folding +mouse_xterm +terminfo
++builtin_terms -footer +multi_byte +termresponse
+byte_offset +fork() +multi_lang +textobjects
+channel +gettext -mzscheme +timers
+cindent -hangul_input +netbeans_intg +title
+clientserver +iconv +packages +toolbar
+clipboard +insert_expand +path_extra +user_commands
+cmdline_compl +job +perl +vertsplit
+cmdline_hist +jumplist +persistent_undo +virtualedit
+cmdline_info +keymap +postscript +visual
+comments +langmap +printer +visualextra
+conceal +libcall +profile +viminfo
+cryptv +linebreak -python +vreplace
+cscope +lispindent +python3 +wildignore
+cursorbind +listcmds +quickfix +wildmenu
+cursorshape +localmap +reltime +windows
+dialog_con_gui +lua +rightleft +writebackup
+diff +menu +ruby +X11
+digraphs +mksession +scrollbind -xfontset
+dnd +modify_fname +signs +xim
-ebcdic +mouse +smartindent +xsmp_interact
+emacs_tags +mouseshape +startuptime +xterm_clipboard
+eval +mouse_dec +statusline -xterm_save
+ex_extra +mouse_gpm -sun_workshop +xpm
+extra_search -mouse_jsbterm +syntax
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -Wdate-time -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib -llua5.2 -Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.22/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-2.3 -lpthread -lgmp -ldl -lcrypt -lm
2018-08-16 10:13:26 [minion@hqs009 ansible]$
ansible --version
ansible --version
ansible 2.5.0
config file = /home/mini/ansible/ansible.cfg
configured module search path = ['/home/mini/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.5/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]
2018-08-16 10:13:56 [mini@hq9 ansible]$
any suggestions ??
Highlighting gets strange after the <<
.
I presume it's trying to do HTML related stuff?
The file name is sqs_queues.tf.j2
(Final product is Terraform HCL)
{% for queue_type, queue in sqs.queues.items() %}
# ----- {{ queue_type|replace('_', ' ')|title }} Queue ----- #
resource "aws_sqs_queue" "{{ queue_type }}" {
name = "{{ queue.name }}-queue"
delay_seconds = "{{ queue.delay }}"
max_message_size = "{{ queue.max_msg_size }}"
message_retention_seconds = "{{ queue.msg_retention_secs }}"
receive_wait_time_seconds = "{{ queue.rcv_wait_secs }}"
visibility_timeout_seconds = "{{ queue.visibility_timeout_secs }}"
redrive_policy = <<EOF
{
"deadLetterTargetArn":"${aws_sqs_queue.{{ queue_type }}_deadletter.arn}",
"maxReceiveCount":{{ queue.redrive_max_rcv_count|int }}
}
EOF
}
resource "aws_sqs_queue" "{{ queue_type }}_deadletter" {
name = "{{ queue.name }}-queue-deadletter"
}
{% if queue.incoming_account is defined %}
resource "aws_sqs_queue_policy" "{{ queue_type }}_allow_sqs_write" {
queue_url = "${aws_sqs_queue.{{ queue_type }}.id}"
policy = "${data.aws_iam_policy_document.{{ queue_type }}_allow_sqs_write.json}"
}
data "aws_iam_policy_document" "{{ queue_type }}_allow_sqs_write" {
statement {
sid = "AllowSQSWrite"
actions = [
"SQS:SendMessage"
]
resources = [
"${aws_sqs_queue.{{ queue_type }}.arn}",
]
principals {
type = "AWS"
identifiers = ["arn:aws:iam::{{ queue.incoming_account }}:root"]
}
}
}
{% endif %}
The jinja2 syntax highlighting doesn't automatically pick up on the root filetype. I tried to use backrefs to help with this, but it doesn't seem to work.
let g:ansible_template_syntaxes = { '\(.*\)\.\(.*\)\.j2': '\2' }
I know with vim, you need to escape the parentheses for capturing groups, but I tried 'em unescaped, too. Here's the breakdown:
\(.*\)
- Capture Group 1, the filename
\.
- A literal dot
\(.*\)
- Capture Group 2, the root filetype
\.j2
- The j2 filetype
The value of the setting should be \2
, whatever was in Capture Group 2.
If I name my playbook playbook.yml. None of the plugin works.
I don't get indents or highlights
Infortunately the syntax highliting completely screwes up YAML-based Ansible syntax. This is how my files look now in terminal vim
on Linux with elflord
colorscheme:
This is the same code in GTK gvim
, using solarized
colorscheme:
And this is also in GTK gvim
using my preferred darkburn
colorscheme:
Any chance to fix that? Unless these are my vim
settings that are screwed up somehow...
Hi ,
Can u let me know where i could set the variables like g:ansible_unindent_after_newline = 1?
tks! in advance.
There's probably a better way to accomplish this:
" :Ansibledoc -- Replace the current buffer with the output of ansible-doc
" :Ansibledoc file
" :Ansibledoc -s file
" :Ansibledoc -l
" :Ansibledoc -F
function! Ansibledoc(...)
execute "%!COLUMNS='$(tput cols)' ansible-doc " . join(a:000)
set filetype=yaml
endfunction
command! -nargs=* Ansibledoc call Ansibledoc(<f-args>)
Is ansible-vim a syntax-only vim plugin?
Is there a variable to disable auto indentation ?
Thanks.
If I have your plugin installed and I type the following code into a .yml playbook file,
When I begin typing "copy" it gets indented in line with "name" above it as it should. But as soon as I type the closing ":", the line indents out so that copy is aligned with the dash in front of name instead of remaining indented in line with "name". Should it work that way? I believe the "name" and "copy" should be aligned. Do I perhaps have to have something else set in my .vimrc file in order for the indentation to work properly?
Thanks.
I'm trying to use Vim fold markers (defaults are {{{
and }}}
, inside comments). On a normal yaml
file, they are classified correctly as yamlComment
; on a yaml.ansible
file, they are classified as jinjaVarDelim
and are highlighted incorrectly.
All my tests have been done using the following Vim command:
:echo synIDattr(synID(line("."),col("."),1), "name")
https://gist.github.com/habitullence/bc10eff328345378448f671dc8cbaae2#file-main-yml-L35
After the single quotes on this line syntax highlighting breaks.
Try viewing this playbook in vim with ansible-vim plugin installed:
- name: |
"https://github.com/ansible/ansible/issues/24572"
hosts: all
tasks:
- debug: var=ansible_virtualization_role
and Syntax highlighting is confused following the multiline string play name. It looks like it doesn't ever detect the end of the string. It appears that the : colon is the problem, as when I remove it, the syntax looks perfect:
- name: |
"https//github.com/ansible/ansible/issues/24572"
hosts: all
tasks:
- debug: var=ansible_virtualization_role
Also, it highlights perfectly when I use the original string play name, but just not broken over multiple lines:
- name: "https://github.com/ansible/ansible/issues/24572"
hosts: all
tasks:
- debug: var=ansible_virtualization_role
I'm using VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan 16 2018 17:48:09)
and ansible-vim installed today from master branch.
When opening a yml file with this plugin enabled, I see only:
---2;2R^[[>1;5200;0c^[]10;rgb:2e2e/3434/3636^G^[]11;rgb:ffff/ffff/ffff^G
This stays for a second or two and then the rest of the file appears. A clear and redraw of the screen (^L) makes the line disappear.
This happens on any yml file I've encountered (for example, those generated by: ansible-galaxy init foo).
This one is really frustrating me.
Load the plugin how you like (I use pathogen still), then:
let g:ansible_unindent_after_newline = 1
let g:ansible_attribute_highlight = "ob"
let g:ansible_extra_keywords_highlight = 1
let g:ansible_normal_keywords_highlight = 'Constant'
let g:ansible_with_keywords_highlight = 'Constant'
let g:ansible_template_syntaxes = { '*.rb.j2': 'ruby' }
Create a new tasks/main.yml
and start making some magic, only to find it breaking in the most frustrating ways.
---
- name: This is just a demo
hosts: "{{ target|default('localhost') }}"
tasks:
- name: Show the brokenness.
## Prevent fail-into
when: (ansible_facts['distribution'] == "bananabread")
template:
src: some.j2
dest: /usr/local/etc/some.conf
- name: This line did not indent even close to correctly.
# vim:ft=yaml.ansible:
But we have let g:ansible_unindent_after_newline = 1
so this should fix it, right? Wrong.
---
- name: This is just a demo
hosts: "{{ target|default('localhost') }}"
tasks:
- name: Show the brokenness.
## Prevent fail-into
when: (ansible_facts['distribution'] == "bananabread")
template:
src: some.j2
dest: /usr/local/etc/some.conf
- name: Well this line has no business being all the way over here.
# vim:ft=yaml.ansible:
More obnoxiously, this is unfixable without killing the plugin. Fix the broken indent, assuming it will reset position, and it does not. Instead it re-indents the whole thing back to 0 and just keeps breaking it over and over.
When I comment a block of lines in visual block mode (ctrl-V, jjjj, I, then enter #) the identation jumps to right, after i hit escape - all selected lines are indented. For example take this code:
- name: test comment
copy:
content: blabla
dest: somewhere
mode: 0666
If u I select from first to last lines (the first column) and hit "I", enter the # and hit escape, it becomes:
#- name: test comment # copy: # content: blabla # dest: somewhere # mode: 0666
sometimes it breaks even more, the dash character is ending up between letters. I tried with a totally clean .vimrc file and the problem is still there.
I have a file called site.yml
as documented in Best Pratices of Ansible, but my file are not highlighted.
I try :set ft=ansible
but don't work. Is a bug or my mistake?
For more complex setup you tend do break down playbooks inventories and roles into sub-dirs. It would be nice if a check for the existence of ansible.cfg
file exists to the list of ft detection.
Dear frd how to install this. Already try but not working.. Help me for this
Is there any way to check syntax erros?
for example {{ variable }}
with "{{variable}}"
what config do you use to get this highlighting: https://camo.githubusercontent.com/6f304717cef61cba73b61ba73444d143e3b1ebc6/687474703a2f2f692e696d6775722e636f6d2f7768424f5a5a4b2e706e67?
I get almost no highlighting
Not sure if it is my environment or not, but when I use ansible-vim and put a comment # at the beginning of a line containing a variable, the variable is still highlighted. So in
#- debug: msg="password for {{item.name}}"
the {{item name}}
part of the line isn't the same colour as the rest of the line, which is in my case DarkBlue.
I get this when installing the snippets:
Traceback (most recent call last):
File "generate.py", line 99, in <module>
for document in get_documents():
File "generate.py", line 17, in get_documents
documentation = plugin_docs.get_docstring(os.path.join(root, f))[0]
TypeError: get_docstring() takes at least 2 arguments (1 given)
ansible
is v2.5.
I dont know if this is newer than your plugin, but, "with_file" is not highlighted.
If you included the following:
set wildignore+=*.retry
Adding it would cause the retry files to be ignored during tab completion.
Adding ignore is not an uncommon practice for vim modules. Vundle, c.vim, and others make use of this feature today.
Seems that most characters in front of a "
except for a space or another quote will break the syntax highlighting.
You can check this task in a tasks/main.yml and the text afterward will have the wrong colours.
- name: break ansible-vim syntax highlighting
shell: echo "{{ foo }}"."{{ bar }}"
- name: this task will have colours as it in quotes
shell: echo "Hello world"
I tried to fix it myself but there was too much of a learning curve
Environment
macOS 10.15.2
NeoVim
Python 3.7.6 (installed with Homebrew)
ansible 2.9.2 (installed with python pip)
config file = None
configured module search path = ['/Users/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /Users/user/.homebrew/lib/python3.7/site-packages/ansible
executable location = /Users/user/.homebrew/bin/ansible
python version = 3.7.6 (default, Jan 2 2020, 02:05:27) [Clang 11.0.0 (clang-1100.0.33.16)]
NVIM v0.4.3
Build type: Release
LuaJIT 2.0.5
Compilation: /Users/user/.homebrew/Library/Homebrew/shims/mac/super/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -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-20191127-79160-1ile155/neovim-0.4.3/build/config -I/tmp/neovim-20191127-79160-1ile155/neovim-0.4.3/src -I/Users/user/.homebrew/include -I/tmp/neovim-20191127-79160-1ile155/neovim-0.4.3/deps-build/include -I/Users/user/.homebrew/opt/gettext/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include -I/tmp/neovim-20191127-79160-1ile155/neovim-0.4.3/build/src/nvim/auto -I/tmp/neovim-20191127-79160-1ile155/neovim-0.4.3/build/include
Compiled by [email protected]
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/Users/user/.homebrew/Cellar/neovim/0.4.3/share/nvim"
Error with snippet generation
ansible-vim master ⦾ ./UltiSnips/generate.sh
[WARNING]: Failed to assign id for <_ast.Tuple object at 0x1023b2c10> on
/Users/user/.homebrew/lib/python3.7/site-
packages/ansible/modules/utilities/logic/async_wrapper.py, skipping
Error in NeoVim
An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://github.com/SirVer/ultisnips/issues/new
Please read and follow:
https://github.com/SirVer/ultisnips/blob/master/CONTRIBUTING.md#reproducing-bugs
Following is the full stack trace:
Traceback (most recent call last):
File "/Users/user/.config/nvim/plugged/ultisnips/pythonx/UltiSnips/err_to_scratch_buffer.py", line 18, in wrapper
return func(self, *args, **kwds)
File "/Users/user/.config/nvim/plugged/ultisnips/pythonx/UltiSnips/snippet_manager.py", line 198, in snippets_in_current_scope
snippets = self._snips(before, True)
File "/Users/user/.config/nvim/plugged/ultisnips/pythonx/UltiSnips/snippet_manager.py", line 668, in _snips
source.ensure(filetypes)
File "/Users/user/.config/nvim/plugged/ultisnips/pythonx/UltiSnips/snippet/source/file/base.py", line 31, in ensure
self._load_snippets_for(ft)
File "/Users/user/.config/nvim/plugged/ultisnips/pythonx/UltiSnips/snippet/source/file/base.py", line 53, in _load_snippets_for
self._parse_snippets(ft, fn)
File "/Users/user/.config/nvim/plugged/ultisnips/pythonx/UltiSnips/snippet/source/file/base.py", line 70, in _parse_snippets
raise SnippetSyntaxError(filename, line_index, msg)
UltiSnips.snippet.source.file.base.SnippetSyntaxError: Invalid multiword trigger: 'cp_mgmt_run_ips_update "Runs IPS database update. If "package-path' in ~/.config/nvim/plugged/ansible-vim/UltiSnips/ansible.snippets:27491
Example file:
---
- apt_repository:
repo
If you type ':' or '-' in the end, it will get indented to:
---
- apt_repository:
repo:
Minimal vimrc to reproduce:
set nocp
call plug#begin('~/.vim/plugged')
Plug 'pearofducks/ansible-vim'
call plug#end()
filetype plugin indent on
syntax on
set ai
set si
set ft?
says filetype=yaml.ansible
.
Having the following configs in ~/.vimrc
filetype plugin indent on
set ai
set si
Testing inside ansible task:
- name: deploy template
template:
src: foo.j2
dest: /etc/foo
after hitting ENTER after template:
it's not auto-indenting src:
(and whatever comes next) with 2 spaces.
Compare this behavior between :set filetype=yaml
and :set filetype=ansible
When editing a file and providing, as an example, a handler. The plugin returns the next line to the indent of the hyphen. It should return the position two spaces after the hyphen
Actual result:
handlers: - name: Restart Apache service: name=httpd state=restarted
ansible-playbook ....
ERROR: Syntax Error while loading YAML script, /home/ansible/sample.yaml
Note: The error may actually appear before this position: line 19, column 11
- name: Restart Apache
service: name=httpd state=restarted
Expected result:
handlers: - name: Restart Apache service: name=httpd state=restarted
ansible-playbook runs without error
Hi,
It would be nice and consistent to be able to configure g:ansible_extra_keywords_highlight
like g:ansible_normal_keywords_highlight
and g:ansible_with_keywords_highlight
. I'd like them all with the same style.
An easy way would be to define a sane default style for g:ansible_extra_keywords_highlight
(Identifier
I suppose), and allow the user to use a style instead of just "1" to enable a second pre-defined style.
I could be extended to g:ansible_name_highlight
and g:ansible_attribute_highlight
. For instance I would really like to set ansible_name_highlight
on Tag
instead of Underlined
.
I'm not sure how easy this is to implement, and it's possible that I will look closer to this myself during the holidays but working spell checking would be really nice for me to have as a dyslexic non-English speaker :)
example.yml
with filetype=yaml
example.yml
with filetype=ansible
I'm using the latest code from master, commit 8540ad7. Vim 7.4 (packaged by Ubuntu). I'm happy to help to fix this but not sure where to start, I'm mostly a vim user, not a hacker :)
folded scalar, or any form of key=value
in yaml in many cases fails to maintain type.
e.g.
---
- hosts: localhost
connection: local
gather_facts: False
tasks:
- set_fact: >
myvar=123
- debug: >
msg={{ myvar is number }}
PLAY [localhost] **********************************************************************************************************************
TASK [set_fact] ***********************************************************************************************************************
ok: [localhost]
TASK [debug] **************************************************************************************************************************
ok: [localhost] => {
"msg": false
}
PLAY RECAP ****************************************************************************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
It is better to use a structured map format
---
- hosts: localhost
connection: local
gather_facts: False
tasks:
- set_fact:
myvar: 123
- debug:
msg: "{{ myvar is number }}"
See a really good write up about it here - https://www.jeffgeerling.com/blog/yaml-best-practices-ansible-playbooks-tasks
Hi,
This is a continuation to #74. Trying to debug the issue, I added the following to my .vimrc:
map :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"
When editing this file https://github.com/miguellavalle/OpenStack-tools/blob/master/ansible/nova-net-migration/prep-compute-nodes-migration.yml, if I place the cursor on top of "name" in line 8, the echo I get is:
hi<> trans<> lo<>
So it's not recognizing the syntax. The only thinks that seem to be recognized are attributes like "path" in line 9 (hi<ansible_attributes> trans<ansible_attributes> lo and jinja variables and delimiters, like in line 13 (hi trans lo and hi trans lo). Would this be attributable toi the plugin?
Scrolling of big ansible YAML configs (>100Kb) is slow and CPU intensive, slower then vim stock yaml highlighter and even slower than https://github.com/chase/vim-ansible-yaml.
It would be incredibly handy if this plugin allowed you to open a role that's defined in the playbook you are working in in another tab so that you don't lose your train of thought, for ease it could be that the plugin assumes the ansible directory is laid out according to the example layout listed in the ansible documentation
This generated snippet is incorrect and breaks UltiSnips
snippet cp_mgmt_run_ips_update "Runs IPS database update. If "package-path" is not provided server will try to get the latest package from the User Center." b
The error (from a fake snippet to return the error):
An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://github.com/SirVer/ultisnips/issues/new
Please read and follow:
https://github.com/SirVer/ultisnips/blob/master/CONTRIBUTING.md#reproducing-bugs
Following is the full stack trace:
Traceback (most recent call last):
File "/home/adrian/.config/nvim/bundle/ultisnips/pythonx/UltiSnips/err_to_scratch_buffer.py", line 18, in wrapper
return func(self, *args, **kwds)
File "/home/adrian/.config/nvim/bundle/ultisnips/pythonx/UltiSnips/snippet_manager.py", line 896, in _track_change
self._try_expand(autotrigger_only=True)
File "/home/adrian/.config/nvim/bundle/ultisnips/pythonx/UltiSnips/snippet_manager.py", line 788, in _try_expand
snippets = self._snips(before, False, autotrigger_only)
File "/home/adrian/.config/nvim/bundle/ultisnips/pythonx/UltiSnips/snippet_manager.py", line 668, in _snips
source.ensure(filetypes)
File "/home/adrian/.config/nvim/bundle/ultisnips/pythonx/UltiSnips/snippet/source/file/base.py", line 31, in ensure
self._load_snippets_for(ft)
File "/home/adrian/.config/nvim/bundle/ultisnips/pythonx/UltiSnips/snippet/source/file/base.py", line 53, in _load_snippets_for
self._parse_snippets(ft, fn)
File "/home/adrian/.config/nvim/bundle/ultisnips/pythonx/UltiSnips/snippet/source/file/base.py", line 70, in _parse_snippets
raise SnippetSyntaxError(filename, line_index, msg)
UltiSnips.snippet.source.file.base.SnippetSyntaxError: Invalid multiword trigger: 'prueba "pr "ue' in ~/.config/nvim/UltiSnips/yaml.snippets:1
Looks like having quotes inside the quotes break UltiSnips
If I have the following long line in a file with set ft=yaml.ansible
:
# Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
and if I want to break the comment line into multiple lines I just move the cursor to that line and press gqq
which does this:
# Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.
As you can see it doesn't break the comment line correctly, because it doesn't add #
before each line. If I set ft=yaml
it works correctly:
# Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
# tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
# quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
# consequat.
so I guess it's a bug in yaml.ansible
file type.
Bit of a weird issue here.
When opening a file initially you see the following:
then when you run :ownsyntax
you get:
Using the following snippet to inspect which rules are running
:set statusline=%{synIDattr(synIDtrans(synID(line('.'),col('.'),1)),'name')}
on the initial opening the highlighted key is a Identifier
and the unhighlighted subkey is a yamlPlainScalar
. After running :ownsyntax
they are both Identifier
.
Not a huge deal but when a task is written as
tasks:
- name: Auth Module Example
na_eseries_auth:
ssid: 2·
admin_pass: 'hello2'
password: 'hello3'
set_admin: no
api_url: "{{ netapp_api_url }}"
api_username: "{{ netapp_api_username }}"
api_password: "{{ netapp_api_password }}"
when: auth
The color of the params like ssid
, admin_pass
, etc are of the same color as the module name, in this example, na_eseries_auth
According to this, there are three types of keywords, play-, block- and task-level keywords. It would be nice to have different highlighting for those three groups.
There are also some keywords (like run_once
) that are currently missing in general.
I'm not sure how to describe this problem, so i made a GIF of the event. I find this extremely annoying because it happens seemingly randomly, and not always in this exact case. It's also dependent on filetype plugin indent on
being set in ~/.vimrc
The problem also happens sometimes after entering a newline, which has the added annoyance of having to go up a line, then fix. The GIF example shows that you have to move back a word in order to remove the additional indent.
I know in the GIF it looks like I have a very custom setup, but I did verify with a blank .vimrc
+ the bare minimum necessary to use this plugin through pathogen.
Edit: it also happens only when this is present and loaded, not when using the default YAML definitions.
Is it possible to always highlight the value of a when:
key as jinja?
... the when clause, which contains a raw Jinja2 expression without double curly braces
— http://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html
I was hoping to override some of the highlight links that you have in syntax/ansible_hosts.vim
. It would be a simple change to.
diff --git a/syntax/ansible_hosts.vim b/syntax/ansible_hosts.vim
index 5ecc4da..0fca099 100644
--- a/syntax/ansible_hosts.vim
+++ b/syntax/ansible_hosts.vim
@@ -14,17 +14,18 @@ syn region hostsHeader start="\v^\s*\[" end="\v\]"
syn keyword hostsHeaderSpecials children vars containedin=hostsHeader contained
syn match hostsComment "\v^[#;].*$"
-highlight link hostsFirstWord Label
-highlight link hostsHeader Define
-highlight link hostsComment Comment
-highlight link hostsHeaderSpecials Identifier
-highlight link hostsAttributes Structure
+highlight default link hostsFirstWord Label
+highlight default link hostsHeader Define
+highlight default link hostsComment Comment
+highlight default link hostsHeaderSpecials Identifier
if exists("g:ansible_attribute_highlight")
if g:ansible_attribute_highlight =~ 'n'
- highlight link hostsAttributes NONE
+ highlight default link hostsAttributes NONE
elseif g:ansible_attribute_highlight =~ 'd'
- highlight link hostsAttributes Comment
+ highlight default link hostsAttributes Comment
+ else
+ highlight default link hostsAttributes Structure
endif
endif
Will submit PR for the ansible_hosts.vim
file, let me know if you would like the same change made to the ansible.vim
syntax file.
Hi
I am using this in my default vimrc to do tab = 2 spaces
" for yaml files (ansible playbooks) <tab> = 2 spaces
autocmd FileType yaml set tabstop=2|set shiftwidth=2
After installing this plugin when I use tab in a playbook I get a tab (^I
) instead of two spaces (checked with set list
) and then I get syntax errors when trying to run the playbook.
What am I doing wrong? Any suggestion to fix this? I have installed the plugin using pathogen
When I'm trying to start a new module after I've finished one, this plugin always indents to the level of the previous module's keys. i.e.:
- name: "ensure staged init file is populated"
become: yes
template:
src: "_etc_init.d_staged_service.j2"
dest: "/etc/init.d/{{ staged_service }}"
owner: "root"
group: "root"
mode: "0755"
- name: "this shouldn't be indented"
This is super frustrating.
Thanks for the great plugin! I really generally love it!
Hi, this is more of a question than an issue. I like the example screenshot color scheme but so far I was unable to find out what scheme it is. It would be nice if you could update the README file with this information.
thanks,
-cM.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.