Add ansible filetype so that LSP works correctly

This commit is contained in:
Ducky SSH User
2025-12-07 22:59:28 +00:00
parent 73bb97ed1d
commit 736a2699b9
3 changed files with 34 additions and 7 deletions

View File

@@ -0,0 +1,21 @@
-- Ansible configuration for detecting .yml files in roles and playbooks directories
return {
{
'neovim/nvim-lspconfig',
optional = true,
-- This table sets up file type detection for Ansible files
init = function()
-- Set up autocommand to detect Ansible files and set their filetype
local ansible_augroup = vim.api.nvim_create_augroup('ansible-detection', { clear = true })
vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
group = ansible_augroup,
pattern = { '*/roles/**/*.yml', '*/roles/**/*.yaml', '*/playbooks/**/*.yml', '*/playbooks/**/*.yaml', '*/hosts/**/*.yml', '*/hosts/**/*.yaml' },
callback = function()
vim.bo.filetype = 'yaml.ansible'
end,
desc = 'Set filetype to yaml.ansible for Ansible files',
})
end,
},
}

View File

@@ -2,4 +2,6 @@
-- I promise not to create any merge conflicts in this directory :)
--
-- See the kickstart.nvim README for more information
return {}
return {
require 'custom.plugins.ansible',
}