fix: nvim tree auto save

This commit is contained in:
2024-06-10 18:09:01 +02:00
parent 93e5f439f4
commit b24359b712
3 changed files with 30 additions and 18 deletions

View File

@@ -39,7 +39,6 @@
trouble.enable = true;
base = {
completion.enable = true;
diagnostics.enable = true;
find.enable = true;
formatting = {

View File

@@ -23,20 +23,24 @@ in
};
config = lib.mkIf cfg.enable {
autoCmd = [
{
event = cfg.event;
pattern = [ "*" ];
callback = {
__raw = ''
function()
extraConfigLua = ''
function AutoSave()
if not vim.b.${cfg.varName} and not vim.g.${cfg.varName} then
local bufnr = vim.api.nvim_get_current_buf()
local modified = vim.api.nvim_buf_get_option(bufnr, 'modified')
if modified then
vim.cmd('silent! w')
print("Auto save at " .. os.date("%H:%M:%S"))
end
end
end
'';
};
autoCmd = [
{
event = cfg.event;
pattern = [ "*" ];
command = "lua AutoSave()";
}
];
@@ -79,6 +83,12 @@ in
};
};
neo-tree.eventHandlers.window_before_open = ''
function()
AutoSave()
end
'';
lualine.sections.lualine_x = lib.mkOrder 700 [
"(vim.g.${cfg.varName} or vim.b.${cfg.varName}) and '󱙃' or nil"
];

View File

@@ -17,15 +17,18 @@ in
plugins = {
neo-tree = {
enable = true;
filesystem.filteredItems.visible = true;
eventHandlers = {
file_opened = ''
filesystem = {
useLibuvFileWatcher = true;
followCurrentFile.enabled = true;
filteredItems.visible = true;
};
popupBorderStyle = "rounded";
eventHandlers.file_opened = ''
function()
require('neo-tree').close_all()
end
'';
};
};
which-key.registrations."<leader>f".t = "Tree";
};
};