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

feat(pack): Adding ansible pack #346

Merged
merged 1 commit into from
Jul 2, 2023
Merged

feat(pack): Adding ansible pack #346

merged 1 commit into from
Jul 2, 2023

Conversation

Sacro
Copy link
Contributor

@Sacro Sacro commented Jul 1, 2023

No description provided.

@github-actions
Copy link

github-actions bot commented Jul 1, 2023

Review Checklist

Does this PR follow the [Contribution Guidelines](development guidelines)? Following is a partial checklist:

Proper conventional commit scoping:

  • If you are adding a new plugin, the scope would be the name of the category it is being added into. ex. feat(utility): added noice.nvim plugin

  • If you are modifying a pre-existing plugin or pack, the scope would be the name of the plugin folder. ex. fix(noice-nvim): fix LSP handler error

  • Pull request title has the appropriate conventional commit type and scope where the scope is the name of the pre-existing directory in the project as described above

  • README is properly formatted and uses fenced in links with <url> unless they are inside a [title](url)

  • Proper usage of opts table rather than setting things up with the config function.

@Sacro
Copy link
Contributor Author

Sacro commented Jul 2, 2023

Should be better now!

@mehalter
Copy link
Member

mehalter commented Jul 2, 2023

We should probably also add the filetype.add to this pack:

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,
    },
  }

@Sacro
Copy link
Contributor Author

Sacro commented Jul 2, 2023 via email

@mehalter
Copy link
Member

mehalter commented Jul 2, 2023

Oh wait, does ansible-vim already add this? This might not be necessary

@Sacro
Copy link
Contributor Author

Sacro commented Jul 2, 2023

It does, but it's not lazy loaded unless you manually set the filetype first. if we can trigger that automagically that would be nice.

@mehalter
Copy link
Member

mehalter commented Jul 2, 2023

@Sacro if we set the filetype and are using language servers and treesitter, does ansible-vim even provide anything else? I think it just provides syntax highlighting and filetype detector which are all handled elsewhere

@Sacro
Copy link
Contributor Author

Sacro commented Jul 2, 2023 via email

lua/astrocommunity/pack/ansible/init.lua Outdated Show resolved Hide resolved
Copy link
Member

@mehalter mehalter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome thanks!

@mehalter mehalter merged commit fb549e4 into AstroNvim:main Jul 2, 2023
Uzaaft pushed a commit that referenced this pull request Jul 3, 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

Successfully merging this pull request may close these issues.

3 participants