I’m trying to use LazyVim https://www.lazyvim.org/ to create and edit ansible playbooks and roles, but for the live of my I don’t understand how to enable ansible-language-server.

The installation of lazyvim went flawless and after starting nvim I used the command :Mason to install:

  • ansible-language-server
  • ansible-lint
  • yaml-language-server
  • yamllint

but still, when opening a task or playbook file in nvim, i don’t get any of that cool features like snippets and automatic syntax checking like I hoped.

Can anyone give me a hint how to enable those? Mason says the plugins are installed, is it only a problem of nvim not recognizing the filetype as ansible? Do I need to enable some plugins via .config/nvim/lua/plugins? I’m out of my element here, help would be much appreciated.

  • hisbaan
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Can you paste the output of :LspInfo when opening an ansible file? Wait a few seconds after opening the file to give the language server time to load

    • this_is_router@feddit.deOP
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      1 year ago

      LspInfo

       Language client log: /home/me/.local/state/nvim/lsp.log
       Detected filetype:   yaml
       
       1 client(s) attached to this buffer: 
       
       Client: yamlls (id: 1, bufnr: [1])
       	filetypes:       yaml, yaml.docker-compose
       	autostart:       true
       	root directory:  Running in single file mode.
       	cmd:             /home/me/.local/share/nvim/mason/bin/yaml-language-server --stdio
       
       Configured servers list: lua_ls, yamlls, bashls, ansiblels, tsserver, jsonls
      

      Looks like the file is recognized as yaml but not as ansible.

      • hisbaan
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        Try putting # vim:ft=yaml.ansible at the top of your file then re-opening it

        • this_is_router@feddit.deOP
          link
          fedilink
          arrow-up
          2
          ·
          1 year ago

          that work, but since I don’t want to touch all my yaml files, I looked into the ftdetect file I already created and saw an error in my path definition.

          its working now. last thing i haven’t found out is, how to tell nvim to check syntax periodically and not only when saving. other then that it works pretty well. thank you