goolord / alpha-nvim

a lua powered greeter like vim-startify / dashboard-nvim
MIT License
1.84k stars 109 forks source link

cd into bookmark #24

Closed juanCortelezzi closed 3 years ago

juanCortelezzi commented 3 years ago

cd into bookmarks

This question is similar to this issue.

First of all, thank you very much for this awesome plugin!

I have been looking for something like mhinz/startify but written in lua for some time now. This is great, the only thing that is preventing me to switch to it is that the bookmarks do not cd into the directory of the file itself.

local startify = require("alpha.themes.startify")

-- disable MRU
startify.section.mru.val = { { type = "padding", val = 0 } }
-- disable MRU cwd
startify.section.mru_cwd.val = { { type = "padding", val = 0 } }

startify.section.top_buttons.val = {
  -- I would like to cd into the directory first
  startify.button("vi", "vim config", ":cd ~/Dotfiles/nvim/.config/nvim/<CR>:e init.lua<CR>"),

  -- while also maintaining the format of the normal bookmark file button like this one:
  startify.file_button("~/Dotfiles/nvim/.config/nvim/init.lua", "vit"),
}

startify.section.bottom_buttons.val = {
  startify.button("q", "Quit Nvim", ":qa<CR>"),
  startify.button("e", "New file", ":ene <BAR> startinsert <CR>"),
}

require("alpha").setup(startify.opts)

Why do I think this is needed ?

This is because I usually jump to the bookmark and then open Telescope to reach files in the same directory. For example, when jumping to init.lua generally I also want to see my plugins file or other nvim config files. With the current behavior of the plugin, when opening Telescope or other file searching tree/finder, the directory is the one I opened nvim from and not the one where the file is located.

Is this possible with the available functionality ?

goolord commented 3 years ago

yes, for example startify.button("c", "~/.config/nvim", ":cd ~/.config/nvim<CR>"),