How Set Neovim startup directory to Desktop in windows?

Viewed 44

I'm using Astro vim distro with neovide. every time I launch neovide / neovim-qt it launches in the directory it's installed on!

OS: windows 10 [Astrovim starting location][1] [using windows shortcut properties to set start in location][2] [1]: https://i.stack.imgur.com/ZvXfp.png [2]: https://i.stack.imgur.com/IEl4N.png

is there a way to set startup location in options.lua ?

1 Answers

Try following code in your configuration file, it make use of vim\neovim autocommands feature:

local os = require("os")

local path_to_desktop = os.getenv("USERPROFILE") .. "\\Desktop"

local vim_enter_group = vim.api.nvim_create_augroup("vim_enter_group", { clear = true })

vim.api.nvim_create_autocmd(
    {"VimEnter"},
    { pattern = "*", command = "cd " .. path_to_desktop, group = vim_enter_group }
)

nvim_create_autocmd and nvim_create_group are described in neovim docs. Use :h nvim_create_autocmdto find out more.

Related