Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neovim, how to keep ft=ansible instead of ft=yaml.ansible (mising jinjaVarBlock) #135

Open
nbari opened this issue Sep 24, 2023 · 0 comments

Comments

@nbari
Copy link

nbari commented Sep 24, 2023

I just upgraded to neovim, and using these options:

vim.api.nvim_create_autocmd({
    "BufRead",
    "BufNewFile"
}, {
    pattern = {
        "*/ansible/*.yml",
        "*/tasks/*.yml",
    },
    callback = function()
        vim.bo.filetype = "ansible"
    end
})

-- ansible hosts
vim.api.nvim_create_autocmd({
    "BufRead",
    "BufNewFile"
}, {
    pattern = {
        "*/ansible/inventory/*",
        "*/ansible/hosts-*"
    },
    callback = function()
        local filepath = vim.fn.expand("%:p")
        if filepath:match("%.yml$") then
            vim.bo.filetype = "yaml.ansible_hosts"
        else
            vim.bo.filetype = "ansible_hosts"
        end
    end
})

For the LSP using ansiblels I use this:

    ["ansiblels"] = function()
                lspconfig.ansiblels.setup({
                    filetypes = {
                        "ansible",
                        "yaml.ansible",
                        "yaml.ansible_hosts"
                    },
                    settings = {
                        ansible = {
                            validation = {
                                lint = {
                                    arguments = "-c ~/.config/ansible-lint.yml"
                                }
                            }
                        }
                    }
                })

But the plugin is always overwriting the setting filetype to yaml.ansible, I would like to use only filetype ansible for "*/tasks/*.yml", any idea how to do this?

How could this maybe be overwriting using the after dir?

If I add this to every file: # vim: set ft=ansible: works but I would like to prevent don't it.

The main problem that I have is that if I use yaml.ansible for an unknown reason I don't see the jinjaVarBlock

This is how I see it with ft=yaml.ansible
Screenshot from 2023-09-24 17-26-24

And I I use ft=ansible:
Screenshot from 2023-09-24 17-26-57

I notice that when using ft=yaml.ansible the :syn list is empty but when using only ft=ansible I get all the syntax groups

@nbari nbari changed the title neovim, how to keep ft=ansible instead of ft=yaml.ansible neovim, how to keep ft=ansible instead of ft=yaml.ansible (mising jinjaVarBlock) Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant