zk-org / zk-nvim

Neovim extension for zk
https://github.com/zk-org/zk
GNU General Public License v3.0
503 stars 41 forks source link

Floaterm + ask for title #58

Closed zeljkomarinkovic closed 2 years ago

zeljkomarinkovic commented 2 years ago

Is it possible to chain commands in some manner so i get asked for title and open new note in floaterm?

What i tried is:

vim.api.nvim_set_keymap("n", "<leader>zt", "<Cmd>Floaterm ZkNew { title = vim.fn.input('Title: ') }<CR>", opts)

but this gets me this error

Screenshot 2022-06-23 at 00 24 15
eric-hansen commented 2 years ago

Not sure what the intention is with using Floatterm here. But try doing it as :ZkNew { title = vim.fn.input('Title: ')}<cr>

zeljkomarinkovic commented 2 years ago

i know that that works, but i would like to have floating window where i can write down a thought, note, todo, whatever and hide it or close it and continue to work on project

eric-hansen commented 2 years ago

Not really sure this is going to work the way you want, but I could be wrong.

You're passing what is essentially a shell command to Floatterm, but ZkNew is not a shell command it's a Neovim command.

You could look at doing what I suggested and then opening up the file in a split buffer. But you're trying to fit a round peg in a square hole atm.

mickael-menu commented 2 years ago

There's no out-of-the-box solution for this.

I think it would be possible to do basically this:

https://github.com/mickael-menu/zk-nvim/blob/614ec31800174e0f6dc1aeaa528eafb9de1193a5/lua/zk.lua#L65-L75

but replacing vim.cmd("edit " .. res.path) with the creation of an nvim floating window buffer.

Overall, it would be interesting to have more customization on how a note is opened (current window, split window, floating window, etc.).

zeljkomarinkovic commented 2 years ago

@eric-hansen I have also figured that out little bit too late

@mickael-menu I will give it a go, if i come with some solution will make PR, thanks