Created
June 6, 2023 11:28
-
-
Save kremovtort/651b6e94ac8049977c77ee89962d52eb to your computer and use it in GitHub Desktop.
Make toggleterm don't affect neotree window
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return { | |
"akinsho/toggleterm.nvim", | |
version = "*", | |
opts = { | |
size = function(term) | |
if term.direction == "horizontal" then | |
return vim.o.lines * 0.45 | |
elseif term.direction == "vertical" then | |
return vim.o.columns * 0.4 | |
end | |
end, | |
shade_terminals = false, | |
-- we find neotree window and then replace it to start position | |
on_open = function(term) | |
local wins = vim.api.nvim_list_wins() | |
local neotree_win | |
for _, win in ipairs(wins) do | |
local buf = vim.api.nvim_win_get_buf(win) | |
local win_ft = vim.api.nvim_buf_get_option(buf, "filetype") | |
if win_ft == "neo-tree" then | |
neotree_win = win | |
break | |
end | |
end | |
if neotree_win ~= nil then | |
vim.api.nvim_win_call(neotree_win, function() | |
local width_before = vim.api.nvim_win_get_width(0) | |
vim.cmd("wincmd H") | |
vim.cmd("vertical resize " .. width_before) | |
end) | |
end | |
end, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment