yaegassy / coc-ansible

ansible-language-server extension for coc.nvim
https://www.npmjs.com/package/@yaegassy/coc-ansible
MIT License
71 stars 3 forks source link

New issue after reinstall. #32

Closed sojjan1337 closed 1 year ago

sojjan1337 commented 1 year ago

Hi!

Having trouble to make the auto-completion to work for ansible. I can see that the ansibleServer is started but when i'm coding the tab "auto-completion" won't appear.

When i open a .yaml file the filetype is "yaml.ansible"

I have noticed though that i have two dirs: /plugged/coc.nvim /plugged/coc-ansible

added into init.vim:

Plug⋅'yaegassy/coc-ansible',⋅{'do':⋅'yarn⋅install⋅--frozen-lockfile'}
i have also added the neoclide/coc.nvim - works fine with terraform

let g:coc_filetype_map = {
  \ 'yaml.ansible': 'ansible',
  \ }

au BufNewFile,BufRead *.yaml :setl ft=yaml.ansible
au BufNewFile,BufRead *.yml :setl ft=yaml.ansible

CocInfo:

vim version: NVIM v0.9.0
node version: v18.16.0
coc.nvim version: 0.0.82-e51a7cd 2023-05-24 18:08:04 +0900
coc.nvim directory: /home/mr/.config/nvim/plugged/coc.nvim
term: xterm-256color
platform: linux

## Log of coc.nvim

2023-05-30T00:52:21.167 INFO (pid:700933) [extension:coc-git] - Looking for git in: git
2023-05-30T00:52:21.227 WARN (pid:700933) [workspace] - Extension "coc-lists" registered synchronized autocmd "VimLeavePre", which could be slow.
2023-05-30T00:52:21.497 INFO (pid:700933) [plugin] - coc.nvim initialized with node: v18.16.0 after 460
2023-05-30T00:52:21.497 INFO (pid:700933) [services] - LanguageClient YAML Support state change: stopped => starting
2023-05-30T00:52:21.499 INFO (pid:700933) [attach] - receive notification: highlight []
2023-05-30T00:52:21.517 INFO (pid:700933) [language-client-index] - Language server "yaml" started with 700953
2023-05-30T00:52:21.694 INFO (pid:700933) [services] - LanguageClient YAML Support state change: starting => running
2023-05-30T00:52:21.698 INFO (pid:700933) [services] - service yaml started
2023-05-30T00:52:22.136 INFO (pid:700933) [language-client-index] - **Language server "ansibleServer" started with 700970**
2023-05-30T00:52:23.092 INFO (pid:700933) [attach] - Request action: runCommand [ 'ufo.foldingRange', 1 ]
2023-05-30T00:52:23.598 ERROR (pid:700933) [attach] - Request error: runCommand [ 'ufo.foldingRange', 1 ] UfoFallbackException
2023-05-30T00:52:24.457 INFO (pid:700933) [attach] - Request action: doKeymap [ 'i-PGJzPg==' ]
2023-05-30T00:52:24.745 INFO (pid:700933) [attach] - Request action: runCommand [ 'ufo.foldingRange', 1 ]
2023-05-30T00:52:24.848 INFO (pid:700933) [attach] - receive notification: highlight []
2023-05-30T00:52:25.246 ERROR (pid:700933) [attach] - Request error: runCommand [ 'ufo.foldingRange', 1 ] UfoFallbackException
2023-05-30T00:52:28.909 INFO (pid:700933) [attach] - receive notification: showInfo []
yaegassy commented 1 year ago

Hi, I haven't performed any update tasks on coc-ansible that could potentially be the cause of your issue. I believe the issue lies within your environment, but I'm not sure of the cause.

Could you please follow the steps below and check if there are any logs indicating a possible cause?

  1. Execute :CocCommand workspace.showOutput.
  2. Select ansibleServer and press Enter. Or Select ansible-client and press Enter
sojjan1337 commented 1 year ago

Hi! There are no selection for either ansibleServer or ansible-client in the list. I can see git/Prettier/vimlsp/snippets/watchman

Thanks for your support!

yaegassy commented 1 year ago

If ansible-client is not included in the selection options, I believe coc-ansible is not working at all. The ansibleServer also won't start. It seems to be an issue with your PC or Vim environment, so I recommend trying it out in a minimal configuration using virtual machines or docker, for example.

sojjan1337 commented 1 year ago

I managed to see it now. This is the output:

########## ansible-client

==== environment ====

pythonCommandPaths(env): /usr/bin/python3 pythonCommandPaths(real): /usr/bin/python3.11 pythonInterpreterPath(custom): None existsAnsibleCmd: true existsAnsibleLintCmd: true existsAnsibleDocCmd: true forceBuiltinTools:

yaegassy commented 1 year ago

Thanks for the adjustments. As I believe the issue has been resolved and is now working, I will close this issue.

sojjan1337 commented 1 year ago

Hi i don't get it to work. Not sure what i'm doing wrong

yaegassy commented 1 year ago

It could be related to the version of Ansible you are using. Could you try creating a Python virtual environment and testing it there?

e.g.:

mkdir -p $HOME/ansible-check
cd $HOME/ansible-check
python3 -m venv venv
source venv/bin/activate
pip install ansible ansible-lint

touch site.yml
nvim site.yml
sojjan1337 commented 1 year ago

Thanks for your effort. Still it won't work.

But i get this line at the top: --- /-> Ansible Schemas Bundle 22.4 (ansible.json)

pip list | grep ansible ansible 7.1.0 ansible-compat 2.2.7 ansible-core 2.14.1 ansible-lint 6.16.2

ansible --version ansible [core 2.14.1] config file = None

yaegassy commented 1 year ago

I tried the following steps with docker's fedora:latest. It worked fine in my environment. Unfortunately, I couldn't reproduce your issue.

Prepare:

docker run -it --rm fedora:latest bash


dnf upgrade -y && dnf install vim-enhanced git -y
dnf install nodejs -y
npm i -g yarn

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

cat <<EOF > ~/.vimrc
syntax on
filetype plugin indent on
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}
Plug 'yaegassy/coc-ansible', {'do': 'yarn install --frozen-lockfile'}
Plug 'pearofducks/ansible-vim'
call plug#end()

let g:coc_filetype_map = {
  \ 'yaml.ansible': 'ansible',
  \ }
EOF

mkdir -p $HOME/check
cd $HOME/check
python3 -m venv venv
source venv/bin/activate
pip install ansible ansible-lint

Plugin Install and Check:

  1. Open vim by navigating to $HOME/check and execute the command :PlugInstall.
  2. Once the plugin installation is complete, close any unnecessary windows and execute :e playbook.yml.

Screen shot:

coc-ansible-issue-32-1
sojjan1337 commented 1 year ago

np. but thanks anyway :)