fix(nvim): enable yaml syntax highlighting for sops files
Add BufReadPre autocmd to set filetype=yaml before buffer is loaded, ensuring syntax highlighting works immediately when opening encrypted sops files. Also updated BufReadPost to unconditionally set yaml filetype after decryption. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,16 @@ local function is_secrets_file(filepath)
|
||||
return false
|
||||
end
|
||||
|
||||
-- Set filetype before reading to enable syntax highlighting
|
||||
vim.api.nvim_create_autocmd("BufReadPre", {
|
||||
group = sops_group,
|
||||
pattern = secrets_patterns,
|
||||
callback = function(args)
|
||||
-- Set filetype to yaml before the file is read so syntax highlighting works
|
||||
vim.bo.filetype = "yaml"
|
||||
end,
|
||||
})
|
||||
|
||||
-- Decrypt file after reading
|
||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
group = sops_group,
|
||||
@@ -50,10 +60,8 @@ vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
vim.bo.writebackup = false
|
||||
vim.bo.undofile = false
|
||||
|
||||
-- Set filetype to yaml if not already set
|
||||
if vim.bo.filetype == "" then
|
||||
-- Ensure filetype is set to yaml for syntax highlighting
|
||||
vim.bo.filetype = "yaml"
|
||||
end
|
||||
|
||||
vim.notify("SOPS: File decrypted successfully", vim.log.levels.INFO)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user