pocco81 / true-zen.nvim

🦝 Clean and elegant distraction-free writing for NeoVim
GNU General Public License v3.0
984 stars 30 forks source link

Error when going into Ataraxis mode with empty file #37

Closed curiousyogurt closed 3 years ago

curiousyogurt commented 3 years ago

When I have a new file without a filename, and go into Atarxis mode, I get the following error:

E5108: Error executing lua ...im/lua/true-zen/services/modes/mode-ataraxis/service.lua:244: Vim(tabedit):E499: Empty file name for '%' or '#', only works with ":p:h": tabe %

When I enter into Atarxis mode with a file that is not empty, I do not encounter this error.

pocco81 commented 3 years ago

Hey! This is not an error, that's expected behaviour. What you are refering to as "empty file", is, in fact, a file that doesn't exist. You see, TrueZen interacts with the buffers rather than the windows. This means that when you try to run Ataraxis mode or Focus mode on a viewport of an in-memory text of a file that doesn't exist it will throw an error because the file doesn't exist.

You can even try typing on a buffer that's not "attached" to any file and then running TrueZen. You'll notice that the same error will popup regardless of the buffer being empty or not.

TrueZen tries to grab the current file by its name, which at this point doesn't exist because it hasn't been created. I could implement a solution to skip this if the file doesn't exist, but then other problems would appear.

If the file is new just :saveas my_file.txt.

Hope it's a little bit more clear now :)