A simple remember open files function for neovim + neo-tree.

I always liked that vscode remembered open files, however for some reason in (neo)vim that seems too complicated.

Session managers do a lot more than just remembering opened files and often broke my neo-tree setup.

So I ended up writing a little lua function in init.lua that only works if you open neovim by passing a directory to it.

ex: nvim ~/code/somethingCool

Basically it first sets the cwd to the passed directory, then adds an autocommand to save the list of open files on exit.

The generated file is saved in {dir}/.git/lastsession.lua which has commands to reopen the files using neo-tree.

Website

Tags: neo neovim