-
-
Notifications
You must be signed in to change notification settings - Fork 618
[Feature request] Allow floating window dimensions be customizable on demand #1512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It would be neat if I could call a command to optionally open the floating window centered with the filetree, like how the window is centered in Telescope... I like to traverse the file tree in a full-screen buffer, but using a floating window would obviously be cooler. (Also props for a great plugin guys, really neat stuff) |
I'm not quite sure what you mean. Can you not do this with a |
@alex-courtis, Not that I know of? Do you know how to call it properly? I have two keymappings: One for toggling the sidebar, the other I'm trying to use for floating window or full screen buffer. It'd be nice to start an FAQ to get different customizations, since I'm still not too familiar with lua/nvim api. I know with telescope I can pass a table with the config for each call. If I set My config: local status, n_tree = pcall(require, "nvim-tree")
if (not status) then return end
local nt_api = require "nvim-tree.api"
n_tree.setup {
view = {
-- float = {
-- enable = true,
-- },
adaptive_size = false,
mappings = {
list = {
{ key = "<BS>", action = "dir_up" },
{ key = "L", action = "cd" },
{ key = "n", action = "create" },
{ key = "x", action = "remove" },
{ key = "h", action = "close_node" },
{ key = "l", action = "dir_down" },
{ key = "v", action = "vsplit" },
{ key = "R", action = "refresh" },
},
},
},
filters = {
dotfiles = false,
},
git = {
ignore = false,
enable = true,
timeout = 400 -- (in ms)
},
update_focused_file = {
enable = true,
update_cwd = true,
},
}
vim.keymap.set('n', '<C-n>',
function()
nt_api.tree.toggle(false, true)
end,
{ desc = 'Toggle Nvim tree lua with no focus' }
)
--TODO: Not sure how to get this guy to work, open filtree in full window or floating window
vim.keymap.set('n', '<C-r>',
function()
vim.api.nvim_open_win(0, false, n_tree.view.float.open_win_config())
end,
{ desc = 'Open Nvim tree centered in a floating window' }
) |
This functionality is not yet merged: #1538 You can test the branch or wait for merge. You can then see |
I suspect you are overthinking things. view.float.enable true and an open_win_config function will be sufficient. |
An overhaul of mappings, with some accompanying API documentation is a work in progress. |
Testing it out now..Okay, I think I understand. I don't think there's an API driven way to call the nvim-tree with dynamic configs? Once I set nvim-tree.view.float.enable = true in my initial setup() every call to nvim-tree uses that config, correct? Map something here:
A showcase for such a nice plugin would be awesome! Let me know how I can help/provide screenshots etc. The PR is still pretty exciting. |
That is interesting! Please raise a feature request. |
That would be greatly appreciated: screenshots with a link to a specific commit to your configuration would be fantastic. |
has this been implemented? I came here looking for this exact feature |
Yes! See Take a look at this recipe: Center a floating nvim-tree window |
I want to be able to dynamically tell nvim-tree to open in floating view vs a sidebar view. I don't understand how I'll be able to do that from the link you shared. |
Sorry; you have to pick one of floating or "sidebar" and stick with it. What exactly is your use case? This sounds very niche so it is something we would do via API. |
I want to bind f to open floating nvim-tree and e for sidebar nvim-tree. currently I am re running setup with floating enabled and not, respectively. |
We could do that. Api.tree.open/toggle could take an argument to override Please raise a feature request so that we can track this. |
Is your feature request related to a problem? Please describe.
My use-case would be to open the float window in the center
Describe the solution you'd like
@alex-courtis proposes
view.float.open_win_config
to be a function that returns a table with the floating window configurationsDescribe alternatives you've considered
Tried to calculate the values on entering neovim but with no luck:
Additional context
#1462 (comment)
Thanks
The text was updated successfully, but these errors were encountered: