feat: Add highlight config for trailing white spaces in yaml files
This commit is contained in:
@@ -35,6 +35,45 @@ return {
|
||||
[".*/etc/foo/.*"] = "fooscript",
|
||||
},
|
||||
},
|
||||
-- Commands
|
||||
commands = {
|
||||
CleanYamlSpaces = {
|
||||
function()
|
||||
if vim.bo.filetype == 'yaml' or vim.bo.filetype == 'yml' then
|
||||
local cursor_pos = vim.api.nvim_win_get_cursor(0)
|
||||
vim.cmd([[%s/\s\+$//e]])
|
||||
vim.api.nvim_win_set_cursor(0, cursor_pos)
|
||||
print("Espaces en fin de ligne supprimés")
|
||||
else
|
||||
print("Cette commande ne fonctionne que sur les fichiers YAML")
|
||||
end
|
||||
end,
|
||||
desc = "Nettoie les espaces en fin de ligne dans les fichiers YAML",
|
||||
},
|
||||
},
|
||||
-- Autocmd
|
||||
autocmds = {
|
||||
yaml_trailing_spaces = {
|
||||
{
|
||||
event = { "BufRead", "BufNewFile" },
|
||||
pattern = { "*.yaml", "*.yml" },
|
||||
callback = function()
|
||||
vim.fn.matchadd("TrailingWhiteSpace", "\\s\\+$")
|
||||
end,
|
||||
desc = "Surligne les espaces en fin de ligne dans les fichiers YAML",
|
||||
},
|
||||
{
|
||||
event = "BufWritePre",
|
||||
pattern = { "*.yaml", "*.yml" },
|
||||
callback = function()
|
||||
local cursor_pos = vim.api.nvim_win_get_cursor(0)
|
||||
vim.cmd([[%s/\s\+$//e]])
|
||||
vim.api.nvim_win_set_cursor(0, cursor_pos)
|
||||
end,
|
||||
desc = "Nettoie les espaces en fin de ligne avant sauvegarde",
|
||||
},
|
||||
},
|
||||
},
|
||||
-- vim options can be configured here
|
||||
options = {
|
||||
opt = { -- vim.opt.<key>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
|
||||
-- if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
|
||||
|
||||
-- AstroUI provides the basis for configuring the AstroNvim User Interface
|
||||
-- Configuration documentation can be found with `:h astroui`
|
||||
@@ -16,6 +16,7 @@ return {
|
||||
highlights = {
|
||||
init = { -- this table overrides highlights in all themes
|
||||
-- Normal = { bg = "#000000" },
|
||||
TrailingWhiteSpace = { bg = "red" },
|
||||
},
|
||||
astrodark = { -- a table of overrides/changes when applying the astrotheme theme
|
||||
-- Normal = { bg = "#000000" },
|
||||
|
||||
Reference in New Issue
Block a user