Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat request] when open nvim-tree, set the window to the right of nvim-tree #91

Closed
shellRaining opened this issue Jul 15, 2023 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@shellRaining
Copy link

image

as the img shown, the result window is under nvim-tree, and when I close the result window, it will auto focus on the nvim-tree, I wish it can re-focus on my code window

thanks a lot if you can impl this~馃槉

@CRAG666
Copy link
Owner

CRAG666 commented Jul 20, 2023

It is not difficult to do, however this is delegated to neovim, neovim decides which window to focus on, in any case I am open to any pr

@CRAG666 CRAG666 added the help wanted Extra attention is needed label Jul 20, 2023
@reactVishnu
Copy link

I got the same problem, so i made this for getting back to the code window..

`function Switch()
local tree_win = vim.fn.win_findbuf(vim.api.nvim_get_current_buf())

if #tree_win == 0 then
-- NvimTree is not open, press w once
vim.cmd('wincmd w')
else
-- NvimTree is open, press w twice
vim.cmd('wincmd w')
vim.cmd('wincmd w')
end

end

vim.api.nvim_set_keymap('n', '', ':w:RunFile:lua Switch()', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '.', ':RunClose', { noremap = true, silent = false })
vim.api.nvim_set_keymap('i', '', ':w:RunFile:lua Switch()', { noremap = true, silent = false })

`
I use nvchad , so i add this in my init.lua file.. you can make the changes add this code to the equivalent of your vim or nvim config..

Thanks.

@CRAG666 CRAG666 closed this as completed May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants