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; trouble.enable = true;
base = { base = {
completion.enable = true; completion.enable = true;
diagnostics.enable = true; diagnostics.enable = true;
find.enable = true; find.enable = true;
formatting = { formatting = {

View File

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

View File

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