mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-03-11 17:03:39 +00:00
feat(nvim): ansible document support
This commit is contained in:
@@ -79,6 +79,29 @@ return {
|
|||||||
-- augroups/autocommands and custom filetypes also this just pure lua so
|
-- augroups/autocommands and custom filetypes also this just pure lua so
|
||||||
-- anything that doesn't fit in the normal config locations above can go here
|
-- anything that doesn't fit in the normal config locations above can go here
|
||||||
polish = function()
|
polish = function()
|
||||||
|
local function yaml_ft(path, bufnr)
|
||||||
|
-- get content of buffer as string
|
||||||
|
local content = vim.filetype.getlines(bufnr)
|
||||||
|
if type(content) == "table" then content = table.concat(content, "\n") end
|
||||||
|
|
||||||
|
-- check if file is in roles, tasks, or handlers folder
|
||||||
|
local path_regex = vim.regex "(tasks\\|roles\\|handlers)/"
|
||||||
|
if path_regex and path_regex:match_str(path) then return "yaml.ansible" end
|
||||||
|
-- check for known ansible playbook text and if found, return yaml.ansible
|
||||||
|
local regex = vim.regex "hosts:\\|tasks:"
|
||||||
|
if regex and regex:match_str(content) then return "yaml.ansible" end
|
||||||
|
|
||||||
|
-- return yaml if nothing else
|
||||||
|
return "yaml"
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.filetype.add {
|
||||||
|
extension = {
|
||||||
|
yml = yaml_ft,
|
||||||
|
yaml = yaml_ft,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
require("notify").setup({
|
require("notify").setup({
|
||||||
background_colour = "#000000",
|
background_colour = "#000000",
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user