ahmedkhalf / project.nvim

The superior project management solution for neovim.
Apache License 2.0
1.29k stars 119 forks source link

does `project.nvim` follow the `XDG_BASE_DIRECTORY` specifications? #113

Open amtoine opened 1 year ago

amtoine commented 1 year ago

hello there :wave: :yum:

i'm writing a little script to automatically load all my git projects into the project.nvim history file and i'm trying to make it cross-platform :open_mouth:

i see this file is at ~/.local/share/nvim/project_nvim/project_history on my system. i have XDG_DATA_HOME set to ~/.local/share/. i also see in the lua code of project.nvim that the file is read from vim.fn.stdpath which also gives me ~/.local/share/nvim/.

can i safely assume the project_history file will be in $XDG_DATA_HOME/nvim/project_nvim/?

cheers :yum:

dgmora commented 1 year ago

Not related to your question, but having a feature like this directly in project.nvim would be great. I was looking for something similar.

andrewcrook commented 3 months ago

@dgmora

Neovim supports XDG so its get path functions should be using them with ‘/nvim’ concatenated to the strings , unless overriden.

The project.nvim example config uses vim.fn.stdpath('data’) which is $XDG_DATA_HOME../nvim/ and appends to make the following ~/.local/share/nvim/project_nvim. I looked at the defaults in the plugins code and this is also the default so the answer is yes it does use XDG

You can set it in you nvim config anyway ...

require('project_nvim').setup({
...
...
    datapath = vim.fn.stdpath('data'),
}

and, of course, the location can be changed, however, it looks like it will always append ‘/project_nvim’ to that path (see below for more info)

andrewcrook commented 3 months ago

@amtoine As I mentioned above the builtin default for ‘datapath' is vim.fn.stdpath('data’) looking at the code ...

 M.datapath = require("project_nvim.config").options.datapath
  M.projectpath = M.datapath .. "/project_nvim" -- directory
  M.historyfile = M.projectpath .. "/project_history" -- file

We can see projects are always stored in the path datapath .. /project_nvim the ‘project_history’ is always stored at datapath .. /project_nvim/project_history

I just looked at your GitHub page, Sorry if I sounded like giving you eggs to suck.

an i safely assume the project_history file will be in $XDG_DATA_HOME/nvim/project_nvim/?

I would say yes .. but you know what OSS is like.