mirror of
https://github.com/mistricky/codesnap.nvim.git
synced 2024-12-27 03:46:29 +00:00
[Feat] Default to XDG_PICTURES_DIR
for save path (#124)
* [Feature] Use XDG_Picture_dir as fallback * [Doc]: Add in new default behaviour for save_path
This commit is contained in:
parent
06d8e345e7
commit
f49e3bde85
2 changed files with 13 additions and 0 deletions
|
@ -408,6 +408,7 @@ There is a default config:
|
||||||
min_width = 0,
|
min_width = 0,
|
||||||
bg_x_padding = 122,
|
bg_x_padding = 122,
|
||||||
bg_y_padding = 82,
|
bg_y_padding = 82,
|
||||||
|
save_path = os.getenv("XDG_PICTURES_DIR") or (os.getenv("HOME").. "/Pictures")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
local path_utils = require("codesnap.utils.path")
|
local path_utils = require("codesnap.utils.path")
|
||||||
|
-- Get user os
|
||||||
|
-- If linux, use XDG_PICTURE_DIR, if mac use ~/Pictures, if windows use FOLDERID_Pictures (If support is added back)
|
||||||
|
local default_save_path = nil
|
||||||
|
local os_name = vim.loop.os_uname().sysname
|
||||||
|
if os_name == "Linux" then
|
||||||
|
default_save_path = os.getenv("XDG_PICTURES_DIR") or (os.getenv("HOME") .. "/Pictures")
|
||||||
|
elseif os_name == "Darwin" then
|
||||||
|
default_save_path = os.getenv("HOME") .. "/Pictures"
|
||||||
|
else
|
||||||
|
error("codesnap.nvim only supports Linux and MacOS")
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
config = {
|
config = {
|
||||||
|
@ -15,6 +26,7 @@ return {
|
||||||
min_width = 0,
|
min_width = 0,
|
||||||
bg_x_padding = 122,
|
bg_x_padding = 122,
|
||||||
bg_y_padding = 82,
|
bg_y_padding = 82,
|
||||||
|
save_path = default_save_path,
|
||||||
},
|
},
|
||||||
cwd = path_utils.back(path_utils.back(debug.getinfo(1, "S").source:sub(2):match("(.*[/\\])"))),
|
cwd = path_utils.back(path_utils.back(debug.getinfo(1, "S").source:sub(2):match("(.*[/\\])"))),
|
||||||
preview_switch = true,
|
preview_switch = true,
|
||||||
|
|
Loading…
Reference in a new issue