diff --git a/after/ftplugin/yaml_ansible.lua b/after/ftplugin/yaml_ansible.lua index 23527cd..c279bc1 100644 --- a/after/ftplugin/yaml_ansible.lua +++ b/after/ftplugin/yaml_ansible.lua @@ -23,3 +23,43 @@ if fname:find('tasks/') then end vim.bo.path = table.concat(ansible_paths, ',') +-- TODO: ansible role navigation +-- When gd is pressed on a role name (e.g., "caddy", "geerlingguy.docker"), +-- open that role's directory in oil. +-- +-- Implementation approach: +-- 1. Find ansible root by searching upward for ansible.cfg (bounded by getcwd) +-- - If not found, fallback to searching for .git directory +-- - If neither found, show warning and do nothing +-- 2. Parse roles_path from ansible.cfg +-- - Split by ':' to get multiple directories +-- - Resolve relative paths against ansible root +-- 3. Check if word under cursor matches any role directory +-- - Search each role directory for matching subdirectory +-- 4. If match found: :Oil +-- - Else: fallback to vim.lsp.buf.definition() +-- +-- Key functions to implement: +-- - find_file_ascending(start_dir, filename, boundary_dir) +-- Search upward for a file (e.g., ansible.cfg), stopping at boundary_dir +-- +-- - find_directory_ascending(start_dir, dirname, boundary_dir) +-- Search upward for a directory (e.g., .git), stopping at boundary_dir +-- +-- - get_ansible_root(buf_path) +-- Return the ansible project root directory by searching for ansible.cfg +-- or .git directory +-- +-- - parse_roles_path(ansible_root) +-- Parse ansible.cfg to extract roles_path configuration +-- Return list of absolute role directories +-- Fallback to ansible_root .. "/roles" if roles_path not in config +-- +-- - find_role_path(role_name, role_dirs) +-- Search each role directory for a matching subdirectory +-- Return full path if found, nil otherwise +-- +-- - ansible_gd() +-- Main function bound to gd keymap +-- Get word under cursor, find role path, open in oil or fallback to LSP +