Closed haroonb closed 2 years ago
It looks like your .vimrc
is keymap to ctrl+space
instead of crtl+,
. Try ctrl+space
.
Hello, thanks for the quick reply. I tried using crtl+space
. I also wrote that in the initial post, but I wrote it like crtl+<space>
and the space part dissapeared, my bad.
As I understand the plugin I should be getting module suggestions as I write module names and such.
The part, that still confuses me is, if i need a coc-settings.json
, if I installed the plugin using :CocInstall @yaegassy/coc-ansible
coc-settings.json
is not required. Is it only "auto-completion" that is not working? Are the "diagnostics" working?
There may be a problem with your ansible project or your python environment. Try it once in a virtual environment such as venv
.
Prepare:
mkdir -p $HOME/coc-ansible-check
cd $HOME/coc-ansible-check python3 -m venv venv
source venv/bin/activate
pip install ansible ansible-lint
Edit:
vim site.yml
or
mkdir -p roles/tasks/dummy/
vim roles/dummy/tasks/main.yml
Hello, the issue still persists in the virtual env.
butt@ansible-controller:~/branch1/ansible_playbooks$ mkdir -p $HOME/coc-ansible-check
butt@ansible-controller:~/branch1/ansible_playbooks$ cd $HOME/coc-ansible-check
butt@ansible-controller:~/coc-ansible-check$ python3 -m venv venv
butt@ansible-controller:~/coc-ansible-check$ source venv/bin/activate
(venv) butt@ansible-controller:~/coc-ansible-check$ sudo pip install ansible ansible-lint
Requirement already satisfied: ansible in /usr/lib/python3/dist-packages (5.3.0)
Requirement already satisfied: ansible-lint in /usr/local/lib/python3.8/dist-packages (5.4.0)
Requirement already satisfied: ansible-core~=2.12.2 in /usr/lib/python3/dist-packages (from ansible) (2.12.2)
Requirement already satisfied: tenacity in /usr/local/lib/python3.8/dist-packages (from ansible-lint) (8.0.1)
Requirement already satisfied: rich>=9.5.1 in /usr/local/lib/python3.8/dist-packages (from ansible-lint) (11.2.0)
Requirement already satisfied: packaging in /usr/lib/python3/dist-packages (from ansible-lint) (20.3)
Requirement already satisfied: ruamel.yaml<1,>=0.15.37; python_version >= "3.7" in /usr/local/lib/python3.8/dist-packages (from ansible-lint) (0.17.21)
Requirement already satisfied: enrich>=1.2.6 in /usr/local/lib/python3.8/dist-packages (from ansible-lint) (1.2.7)
Requirement already satisfied: pyyaml in /usr/local/lib/python3.8/dist-packages (from ansible-lint) (6.0)
Requirement already satisfied: wcmatch>=7.0 in /usr/local/lib/python3.8/dist-packages (from ansible-lint) (8.3)
Requirement already satisfied: resolvelib<0.6.0,>=0.5.3 in /usr/lib/python3/dist-packages (from ansible-core~=2.12.2->ansible) (0.5.4)
Requirement already satisfied: commonmark<0.10.0,>=0.9.0 in /usr/local/lib/python3.8/dist-packages (from rich>=9.5.1->ansible-lint) (0.9.1)
Requirement already satisfied: colorama<0.5.0,>=0.4.0 in /usr/lib/python3/dist-packages (from rich>=9.5.1->ansible-lint) (0.4.3)
Requirement already satisfied: pygments<3.0.0,>=2.6.0 in /usr/local/lib/python3.8/dist-packages (from rich>=9.5.1->ansible-lint) (2.11.2)
Requirement already satisfied: ruamel.yaml.clib>=0.2.6; platform_python_implementation == "CPython" and python_version < "3.11" in /usr/local/lib/python3.8/dist-packages (from ruamel.yaml<1,>=0.15.37; python_version >= "3.7"->ansible-lint) (0.2.6)
Requirement already satisfied: bracex>=2.1.1 in /usr/local/lib/python3.8/dist-packages (from wcmatch>=7.0->ansible-lint) (2.2.1)
(venv) butt@ansible-controller:~/coc-ansible-check$ vim site.yml
The ansible-lint seems to work.
When I enter ctrl+space
I get this, don't know if this helps
ctrl+space
forcefully invokes completion, but I think just typing it in the first place will complete it to some extent....
I tried it in my environment. I usually use Neovim, but I tried it with Vim8 (v8.2.4478).
DEMO (mp4):
https://user-images.githubusercontent.com/188642/156018579-e8a31f10-8400-4c7c-ae8d-59155820510c.mp4
If you can, please update Vim to the latest version and try it.
Can you maybe share your .vimrc with me?
I installed the latest vim and still didn't help
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 28 2021 11:18:09)
Included patches: 1-3458
Modified by jonathon.fernyhough@york.ac.uk
Compiled by jonathon.fernyhough@york.ac.uk
Huge version without GUI. Features included (+) or not (-):
+acl +file_in_path +mouse_urxvt -tag_any_white
+arabic +find_in_path +mouse_xterm -tcl
+autocmd +float +multi_byte +termguicolors
+autochdir +folding +multi_lang +terminal
-autoservername -footer -mzscheme +terminfo
-balloon_eval +fork() +netbeans_intg +termresponse
+balloon_eval_term +gettext +num64 +textobjects
-browse -hangul_input +packages +textprop
++builtin_terms +iconv +path_extra +timers
+byte_offset +insert_expand -perl +title
+channel +ipv6 +persistent_undo -toolbar
+cindent +job +popupwin +user_commands
-clientserver +jumplist +postscript +vartabs
-clipboard +keymap +printer +vertsplit
+cmdline_compl +lambda +profile +virtualedit
+cmdline_hist +langmap -python +visual
+cmdline_info +libcall +python3 +visualextra
+comments +linebreak +quickfix +viminfo
+conceal +lispindent +reltime +vreplace
+cryptv +listcmds +rightleft +wildignore
+cscope +localmap -ruby +wildmenu
+cursorbind -lua +scrollbind +windows
+cursorshape +menu +signs +writebackup
+dialog_con +mksession +smartindent -X11
+diff +modify_fname -sodium -xfontset
+digraphs +mouse +sound -xim
-dnd -mouseshape +spell -xpm
-ebcdic +mouse_dec +startuptime -xsmp
+emacs_tags +mouse_gpm +statusline -xterm_clipboard
+eval -mouse_jsbterm -sun_workshop -xterm_save
+ex_extra +mouse_netterm +syntax
+extra_search +mouse_sgr +tag_binary
-farsi -mouse_sysmouse -tag_old_static
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -Wdate-time -g -O2 -fdebug-prefix-map=/build/vim-sZb2J1/vim-8.2.3458=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lm -ltinfo -lselinux -lcanberra -lacl -lattr -lgpm -ldl -L/usr/lib/python3.8/config-3.8-x86_64-linux-gnu -lpython3.8 -lcrypt -lpthread -ldl -lutil -lm -lm
I've prepared a small .vimrc
.
mini.vim:
call plug#begin('/tmp/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'sheerun/vim-polyglot'
Plug 'yaegassy/coc-ansible', {'do': 'yarn install --frozen-lockfile'}
call plug#end()
syntax on
filetype plugin indent on
set hidden
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
let g:coc_filetype_map = {
\ 'yaml.ansible': 'ansible',
\ }
It worked fine in my environment. (vim -Nu mini.vim
)
@haroonb I noticed in your png file that you are getting the error E29: No inserted text yet
. Perhaps this is because ctrl+space
is not mapped correctly.
This may be a problem with Vim8 or the terminal emulator you are using. Google search for "vim8 c-space" may help you find the solution.
If you change the mapping in this way, does it change the behavior?
"if has('nvim')
" inoremap <silent><expr> <c-space> coc#refresh()
"else
" inoremap <silent><expr> <c-@> coc#refresh()
"endif
inoremap <silent><expr> <c-space> coc#refresh()
Thanks for the support.
I tried it in a virtual env, with your suggested .vimrc
on another server, but that didn't help. crtl+space
didn't do anything with the normal mapping or inoremap <silent><expr> <c-space> coc#refresh()
. not even a error.
I also tried the same on my original configuration, with the same result.
I switched my terminal emulator for mobaXterm to the windows integrated ssh
over the cmd
and that didn't help either.
If you don't have any more ideas I would close this issue, because it seems to work for you, so the error must be on my side.
I have no ideas. 🙇
I found out what the issue was. The autocompletion doesn't work with set paste
. If I take that out of the .vimrc
everthing works. Is this a bug or working as intended?
Hello I'm trying to get the autocompletion to work with vim. However I can't seem to get anything to autocomplete. As I understand it, I should be able to use the autocomplete feature with crtl+, but nothing happens, nor do I get any suggestions for modules or arguments inside modules.