-
-
Notifications
You must be signed in to change notification settings - Fork 250
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
Conversation
Review ChecklistDoes this PR follow the [Contribution Guidelines](development guidelines)? Following is a partial checklist: Proper conventional commit scoping:
|
Should be better now! |
We should probably also add the 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,
},
} |
Looks good, do you want me to add that?
…On Sun, 2 Jul 2023, 11:56 Micah Halter, ***@***.***> wrote:
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,
},
}
—
Reply to this email directly, view it on GitHub
<#346 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAUJMHPQ7GW4OLVMEF2EEGDXOFHVDANCNFSM6AAAAAAZ3BWLYI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Oh wait, does |
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. |
@Sacro if we set the filetype and are using language servers and treesitter, does |
I find I'm getting better code completion with it enabled.
…On Sun, 2 Jul 2023, 14:34 Micah Halter, ***@***.***> wrote:
@Sacro <https://github.com/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
—
Reply to this email directly, view it on GitHub
<#346 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAUJMHLJANTNQ7JMLEN5QH3XOF2GZANCNFSM6AAAAAAZ3BWLYI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
There was a problem hiding this 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!
No description provided.