goolord / alpha-nvim

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

dashboard button press doesn't work as expected #100

Closed Clumsy-Coder closed 2 years ago

Clumsy-Coder commented 2 years ago

I'm currently trying to figure out why selecting a button and pressing Enter key is not working

I get a E21: Cannot make changes, 'modifiable' is off instead

config

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

dashboard.section.buttons.val = {
  dashboard.button("SPC f f" , "  Find file", ":Telescope find_files hidden=true no_ignore=true<CR>"),
}

alpha.setup(dashboard.config)

The weird thing is that if used

dashboard.button("<leader>ff" , "  Find file", ":Telescope find_files hidden=true no_ignore=true<CR>")

instead, then pressing enter key works.


NOTE: I also have <leader>ff keymapped using leader is <space>

vim.api.nvim_set_keymap("n", "<leader>ff", ":Telescope find_files hidden=true no_ignore=true<cr>", { noremap = true, silent = true } )
Clumsy-Coder commented 2 years ago

Found the cause of problem

https://github.com/goolord/alpha-nvim/blob/534a86b348b741ada5bb0d4b83c2c3da6763352a/lua/alpha/themes/dashboard.lua#L53

sc should be changed to sc_

sc will contain raw string. Ex: SPC f f sc_ is the formatted string. Ex: <leader>ff

It's the same for startify https://github.com/goolord/alpha-nvim/blob/534a86b348b741ada5bb0d4b83c2c3da6763352a/lua/alpha/themes/startify.lua#L47

goolord commented 2 years ago

goood catch, i must have messed this up at some point when reverting some changes recently. thanks

goolord commented 2 years ago

https://github.com/goolord/alpha-nvim/commit/d54ce84559ee50500a1133d1c58daf9cd715525b

dinhmai74 commented 2 years ago

I have the same issue now @goolord any way to fix it? It happens when I update to nvim nightly NVIM v0.8.0-dev-971-g3e0c262a6

image
goolord commented 2 years ago

what does your config look like? works fine on my machine

dinhmai74 commented 2 years ago

nvm @goolord , I found the issue. I used this code button("h", " Hapoon File ", ":lua require('harpoon.ui').toggle_quick_menu()<cr>"), which cause the bug -> change to button("h", " Hapoon File ", "<cmd>lua require('harpoon.ui').toggle_quick_menu()<cr>") and it works fine