goolord / alpha-nvim

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

50 show cmd output in floating window #63

Closed ben-hansske closed 2 years ago

ben-hansske commented 2 years ago

The code does what it should. You can run a execute a shell command and it will output to a terminal buffer inside a floating window. It can also run any other lua function that outputs a string via vim.api.nvim_chan_send. The file dashboard-term.lua gives a short example on how to configure it and how to write a function that outputs to the terminal buffer. However there have been a couple of issues that I have not been able to solve or would like to hear your feedback:

I am using this for almost a week now and did not encounter further problems. Please let me know what you think about this.

goolord commented 2 years ago

thank you so much for writing all of this ! i'm gonna go ahead and split the terminal code into its own module, also i renamed the element type to "term"

i'll try testing this and pushing whatever fixes i can later, too

goolord commented 2 years ago

printing out is also awfully slow on my machine for some reason, this is something else to investigate

goolord commented 2 years ago

another todo: hide the cursor in the terminal buffer

ben-hansske commented 2 years ago

There is one more issue I forgot to mention up there: lolcat for example sees that it does not output to a terminal and does not print colors unless it is forced with -f. I already checked the $TERM variable, but it looked fine. I think the best way to get around this might be to use vim.fn.termopen instead of vim.api.nvim_open_term. I'll give it a try.

danielnehrig commented 2 years ago

let me know if you need/want testing from my side

ben-hansske commented 2 years ago

Sorry for not responding in a while! Testing is of course much appreciated.

With the last commit I was able to sort out the following issues:

Remaining issues are still:

I am not sure how much you care about these two remaining issues. I would leave them as they are if you don't mind?

danielnehrig commented 2 years ago

any update here what is missing ?

goolord commented 2 years ago

i'll try messing with animating the window position, but if it's not fruitful i'll just merge it as is for now, i think

goolord commented 2 years ago

line does work, i don't really understand why line('.') always returns 0 (even in normal files) but line('w0', winid) is more like what we want i think

olimorris commented 2 years ago

Hey @ben-hansske just coming to this now. Hadn't realised we had this awesome pull request in the works and more than happy to test this out. Is there anything we can borrow from dashboard.nvim's recent refactor?

ben-hansske commented 2 years ago

Hi @olimorris, I am quite busy right now, but I will try to schedule some time the next week looking into the recent developement on dashboard.nvim.

olimorris commented 2 years ago

@ben-hansske could you share the config you use with this pull request? I'm going to try and play around with it tonight.

ben-hansske commented 2 years ago

There is an example theme: https://github.com/ben-hansske/alpha-nvim/blob/50-show-cmd-output-in-floating-window/lua/alpha/themes/dashboard-term.lua To use it

require'alpha'.setup(require'alpha.themes.dashboard-term'.opts)

should be enough.

Feel free to play around with it! The lines 37 - 56 are probably what you are looking for.

goolord commented 2 years ago

closed in favor of https://github.com/goolord/alpha-nvim/pull/124 for the moment