Code Monkey home page Code Monkey logo

Comments (24)

gennaro-tedesco avatar gennaro-tedesco commented on September 25, 2024 2

That is a good idea: I will try to clean it up a little and link the relevant bits! :)

from nvim-possession.

gennaro-tedesco avatar gennaro-tedesco commented on September 25, 2024 1

Sorry that we couldn't resolve this yet - I will keep the issue open and keep you updated as well!

from nvim-possession.

EmreDogann avatar EmreDogann commented on September 25, 2024

Update:

It seems that when I set the fzf-lua preset to "telescope" it works with no errors. Below is how I'm loading fzf-lua (my copy-paste to clipboard is broken right now so I apologise for the screenshots):

image

image

With that being said, it still looks very different from the gif in the README.

from nvim-possession.

gennaro-tedesco avatar gennaro-tedesco commented on September 25, 2024

Let us try and understand under what circumstances the error can be reproduced:

I created the sessions/ directory

does this mean the error occurs when setting a custom

sessions = {
  sessions_path = ...
  ...
}

rather than vim.fn.stdpath("data") .. "/sessions/" or do you still see the error with default configuration? Moreover I see that in your example you are explicitly setting a fzf-lua previewer: would it still occur if using the default configuration for both nvim-possession and fzf-lua, namely just using

{
  "gennaro-tedesco/nvim-possession",   
  dependencies = {
     "ibhagwan/fzf-lua",
  },
  config = true,
}

? I am running the default configuration with latest commits as of now and cannot reproduce it.

from nvim-possession.

EmreDogann avatar EmreDogann commented on September 25, 2024

So I've stripped everything down to the code snippet you provided and unfortunately, it's the same error.
I uninstalled all my other plugins in case of conflicts but that didn't help.
I also tried reinstalling fzf through apt but same result.
nvim checkhealth also says everything is ok.

does this mean the error occurs when setting a custom

Sorry, that was bad wording on my part, when I first installed the plugin it was giving me errors about how it couldn't find the /sessions/ folder in the default path. So I created that manually.

from nvim-possession.

gennaro-tedesco avatar gennaro-tedesco commented on September 25, 2024

So if I understand correctly:

  1. you created the session folder manually on your computer
  2. you indicated the path to said session folder in
sessions = {
  sessions_path = ...
  ...
}
  1. though the path is correct, you see an exception "No such file or directory"
  2. such exception in 3. occurs because of extra white spaces that aren't stripped correctly
  3. if you use the fzf-lua setup "Telescope" the error disappears

correct?

What is your fzf-lua setup? I cannot reproduce the error by using a default fzf-lua configuration, so I suspect there may be some previewers options that you may be setting that for some reasons artificially add the extra spaces (and they happen to disappear when using the "Telescope" setup). In particular the plugin uses the in-built previewer, so do not manually set bat as one.

P. S. Do you maybe have some particular fzf options, for separators, inline arguments or such? fzf-lua inherits the general fzf shell options and parses them into the preview, so that may cause some additional characters to appear.

from nvim-possession.

EmreDogann avatar EmreDogann commented on September 25, 2024

you created the session folder manually on your computer
you indicated the path to said session folder in

I created the folder manually in the default location (i.e. vim.fn.stdpath("data") .. "/sessions/"). I did not change the sessions_path field.
Apart from that all the other points are correct.

What is your fzf-lua setup?

My setup is the default, in this case it is loading fzf-lua as a dependency through nvim-possession.

P. S. Do you maybe have some particular fzf options, for separators, inline arguments or such? fzf-lua inherits the general fzf shell options and parses them into the preview, so that may cause some additional characters to appear.

I do have a .zshrc where I set some fzf arguments like separators and such, but I've commented those out and reloaded to make sure they weren't conflicting. Maybe there is some cache somewhere that fzf might be using?

from nvim-possession.

gennaro-tedesco avatar gennaro-tedesco commented on September 25, 2024

Could you show me (perhaps with a small recording) the following steps:

  1. create a new session with nvim-possession
  2. go to the location of said session on your computer, check if the name/path is correct
  3. load the session (which should allegedly result in an error)

What are the characters ~/.d/l/s/n/s/ that are displayed in your screenshot, at the fzf-lua prompt? Might it be they are references to other directories and perhaps something on your computer isn't resolving the ~/ correctly?

from nvim-possession.

EmreDogann avatar EmreDogann commented on September 25, 2024

What are the characters ~/.d/l/s/n/s/

This is the short path to my vim.fn.stdpath("data") folder which in my case is ~/.dotfiles/local/share/nvim/. To be honest I don't know why fzf is showing it as this short path I don't recall settings anything like that.
It follows what I set for my XDG paths:

# Inside .zshenv
export XDG_CONFIG_HOME = $HOME/.dotfiles
export XDG_DATA_HOME = $XDG_CONFIG_HOME/local/share
export XDG_CACHE_HOME = $XDG_CONFIG_HOME/cache

What I did was clear my vim.fn.stdpath("data") folder and tried it again. But when I now go to call require('nvim-possession').new() I get a different error saying sessions_path does not exist:

WindowsTerminal_WSL2_Ubuntu.mp4

If I mkdir create the sessions/ folder at ~/.dotfiles/local/share/nvim/ then this error goes away.

But then I run into the error from earlier:

WindowsTerminal_WSL_Ubuntu_2.mp4

EDIT:
Apologies I forgot step 2. Here is a screenshot of the session file from the path it saved to:
image

from nvim-possession.

gennaro-tedesco avatar gennaro-tedesco commented on September 25, 2024

Hmm, may I ask what operating system you are on? I have repeated all your steps above and I could not reproduce the exception, so I am led to believe that the extra spaces you see may be a representation of the fzf prompt that is specific to your machine. In particular you can see from your recording above that, when nvim-possession saves the session, the path is correctly indicated to be exactly the location where the session exists (with no extra spaces). The exception occurs when the entry string is fed via the fzf-prompt.

What happens when you just invoke fzf (either fzf-lua per sé in neovim or fzf in the terminal)? My guess is that you would see the additional extra spaces there as well.

from nvim-possession.

EmreDogann avatar EmreDogann commented on September 25, 2024

Hmm, may I ask what operating system you are on?

I'm on Windows 11 using WSL 2 Ubuntu via Windows Terminal.

Invoking fzf in the terminal seems to be working fine:
image

Invoking it in nvim using :lua require('fzf-lua').files({cwd = '~/.dotfiles', cmd = "fd --no-ignore --hidden"}) seems to be fine as well:
image

I'm not sure, maybe somewhere fzf settings are being overridden? I did migrate from regular vim where I was using fzf.vim so maybe some weird stuff is going on there? The fzf.vim files and the previous vim install+config are still on the system.

from nvim-possession.

gennaro-tedesco avatar gennaro-tedesco commented on September 25, 2024

Invoking it in nvim using

isn't there an additional white space between the icon and the first character of your first entry ( local)? Anyway: I didn't try on Windows (as I don't have a Windows computer at hand), only on MacOs and Linux.

I will continue investigating, but unless I come across a Windows computer I cannot guarantee to resolve this quickly, unfortunately; apologies for that, I am trying to reproduce it but it just doesn't manifest on my machines. As a workaround you could use the "Telescope" setup (what of it didn't convince you? But also, I don't understand why it works in that case...), in the meantime I will try to ask the maintainer of fzf-lua to see if he is aware of a specific Windows behaviour that prompts extra white spaces.

from nvim-possession.

EmreDogann avatar EmreDogann commented on September 25, 2024

There's nothing wrong with the telescope preset, I just prefer the layout of the fzf/default preset.
But thanks for the help, I will continue investigating and will provide updates here if I find anything.

from nvim-possession.

EmreDogann avatar EmreDogann commented on September 25, 2024

Update:

I think your hunch about the whitespace and icons might be correct. I just tested it out with some of the other presets:

WindowsTerminal_WSL2_Ubuntu_3.mp4

It seems that the telescope and max-perf presets work fine.

Looking at the fzf-lua README it seems that the icons might be the issue here:


Profiles

Conviniently, fzf-lua comes with a set of preconfigured profiles, notably:

Profile Details
default fzf-lua defaults, uses neovim "builtin" previewer and devicons (if available) for git/files/buffers
fzf-native utilizes fzf's native previewing ability in the terminal where possible using bat for previews
fzf-tmux similar to fzf-native and opens in a tmux popup (requires tmux > 3.2)
max-perf similar to fzf-native and disables icons globally for max performance
telescope closest match to telescope defaults in look and feel and keybinds
skim uses skim as an fzf alternative, (requires the sk binary)

from nvim-possession.

gennaro-tedesco avatar gennaro-tedesco commented on September 25, 2024

Ah, so probably both max-perf and telescope silently remove the space allocated to devicons, whereas the other defaults force a white space when icons are explicitly removed!

I would still expect it to work if you choose any other preset but manually set icons to false in your fzf-lua setup configuration. This said, great that we could make it work at the end!

from nvim-possession.

EmreDogann avatar EmreDogann commented on September 25, 2024

So it's not only file_icons in fzf-lua but also git_icons. Once i set those both to false in the fzf-lua config, it seems to work.
With that being said, is there no way to set file and git icons to false only in nvim-possesion windows? It would be nice to have an option to display these icons in other windows. If not, then maybe this deserves an issue thread over on the fzf-lua repo?

from nvim-possession.

gennaro-tedesco avatar gennaro-tedesco commented on September 25, 2024

With that being said, is there no way to set file and git icons to false only in nvim-possesion windows?

I do have such setup, have a look here: essentially you have to explicitly enable the git/file icons for the pickers you want instead of using presets; nvim-possession sets icons to false automatically, so you wouldn't have problems there. I presume that by using presets they somehow take over whatever other fzf-lua prompt there is, which is the reason why we saw those extra spaces in your example, and this shouldn't happen if you just configure the single pickers by themselves.

If you use (modifying at your will) my dotfiles as per link above you will exactly reproduce the setup as in the README :)

from nvim-possession.

EmreDogann avatar EmreDogann commented on September 25, 2024

Ok so modifying M.list() inside nvim-possession/init.lua to also disable git_icons like so:

---list all existing sessions and their files
	---return fzf picker
	M.list = function()
		local iter = vim.loop.fs_scandir(user_config.sessions.sessions_path)
		if iter == nil then
			print("session folder " .. user_config.sessions.sessions_path .. " does not exist")
			return
		end
		local next = vim.loop.fs_scandir_next(iter)
		if next == nil then
			print("no saved sessions")
			return
		end

		return fzf.files({
			user_config = user_config,
			prompt = user_config.sessions.sessions_icon .. "sessions:",
			file_icons = false,
			git_icons = false,		<-------- Adding this fixed the issue
			show_cwd_header = false,
			preview_opts = "nohidden",

			previewer = ui.session_previewer,
			winopts = user_config.fzf_winopts,
			cwd = user_config.sessions.sessions_path,
			actions = {
				["default"] = M.load,
				["ctrl-x"] = { M.delete_selected, fzf.actions.resume },
			},
		})
	end

Fixes the issue for me, without having to disable any icons in my fzf-lua config.

If you use (modifying at your will) my dotfiles as per link above you will exactly reproduce the setup as in the README :)

Yeah I will definitely steal some stuff from there haha. I really like the look of your setup

from nvim-possession.

gennaro-tedesco avatar gennaro-tedesco commented on September 25, 2024

...what if you open a PR with that fix, so that I can include it and we fix this once and for all? :)

from nvim-possession.

EmreDogann avatar EmreDogann commented on September 25, 2024

Sure thing!

Let me just finish up my nvim-possession setup to make sure nothing else comes up before the PR.

from nvim-possession.

gennaro-tedesco avatar gennaro-tedesco commented on September 25, 2024

I have released a new version after merging the PR: updating the plugin via your plugin manager of choice should do and you should be able to see the error solved!

Thank you for your contribution!

from nvim-possession.

EmreDogann avatar EmreDogann commented on September 25, 2024

Yep just tried it out and everything is working as expected, thanks a lot!

By the way, it would be nice if you put in the README a link to the config to get nvim-possession looking like the gif in the README. I was a bit confused at first because my one looked vastly different.

from nvim-possession.

gennaro-tedesco avatar gennaro-tedesco commented on September 25, 2024

By the way, it would be nice if you linked the config to get nvim-possession looking like the gif in the README. I was a bit confused at first because my one looked vastly different.

Do you mean the configuration to be found in my dotfiles?

from nvim-possession.

EmreDogann avatar EmreDogann commented on September 25, 2024

Yeah that could work

from nvim-possession.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.