Closed axieax closed 1 year ago
I just experience a similar issue too, with neo-tree.nvim: https://github.com/nvim-neo-tree/neo-tree.nvim/issues/325. This is the DEMO from the link to save you a click for browsing:
Same issue here with mundotree.
reporting the same issue for dap-repl filetype from github.com/rcarriga/nvim-dap-ui
I have simillar problem with Telescope prompt: useless line number on the left and strange rectangle at the right:
Even though it seems excluded by default (discussed in #61) and I tried to disable plugin in Telescope prompt by excluding it both in filetype and buftype it still appears. Related config part:
excluded_filetypes = {
'TelescopePrompt',
'toggleterm',
},
excluded_buftypes = {
'help',
'prompt',
'popup',
}
Full focus config:
focus.setup({
-- The focused window will no longer automatically resize. Other focus
-- features are still available.
autoresize = true,
-- Prevents focus automatically resizing windows based on configured excluded
-- filetypes or buftypes Query filetypes using :lua print(vim.bo.ft) or
-- buftypes using :lua print(vim.bo.buftype).
excluded_filetypes = {
'', -- Hover popups such as Treesitter syntax investigation popup, lsp popups...
'TelescopePrompt',
'toggleterm',
},
excluded_buftypes = {
'help',
'prompt',
'popup',
},
-- Enable resizing for excluded filetypes using forced_filetypes.
--forced_filetypes = { 'dan_repl' },
-- Force width for the focused window.
-- Default: Calculated based on golden ratio.
--width = 120,
-- Force minimum width for the unfocused window.
-- Default: Calculated based on golden ratio.
--min_width = 80,
-- Force height for the focused window.
-- Default: Calculated based on golden ratio.
--height = 40,
-- Sets the width of directory tree buffers such as NerdTree, NvimTree and
-- CHADTree.
-- Default: vim.g.nvim_tree_width or 30
--treewidth = 20,
-- True: When a :Focus.. command creates a new split window, initialise it as
-- a new blank buffer.
-- False: When a :Focus.. command creates a new split, retain a copy of the
-- current window in the new window.
--bufnew = false,
-- Prevents focus automatically resizing windows based on configured file
-- trees. Query filetypes using `:lua print(vim.bo.ft)`.
-- Default: { 'nvimtree', 'nerdtree', 'chadtree', 'fern' }.
--compatible_filetrees = { 'filetree' },
-- Displays a cursorline in the focused window only.
-- Not displayed in unfocused windows.
cursorline = false,
-- Displays a sign column in the focused window only
-- Gets the vim variable setcolumn when focus.setup() is run
-- See :h signcolumn for more options e.g :set signcolum=yes
-- Default: true, signcolumn=auto
signcolumn = true,
-- Displays a cursor column in the focused window only.
-- See :h cursorcolumn for more options.
-- Default: false.
--cursorcolumn = true,
-- Displays a color column in the focussed window only.
-- See `:h colorcolumn` for more options.
-- Default: enable = false, width = 80.
colorcolumn = { enable = true, width = 80 },
-- Displays line numbers in the focused window only.
-- Not displayed in unfocused windows.
-- Default: true.
number = true,
-- Displays relative line numbers in the focused window only.
-- Not displayed in unfocused windows.
-- Default: true.
--relativenumber = true,
-- Displays hybrid line numbers in the focused window only.
-- Not displayed in unfocused windows.
-- Combination of :h relativenumber, but also displays the line number of the
-- current line only.
-- Default: false.
hybridnumber = true,
-- Preserve absolute numbers in the unfocused windows.
-- Works in combination with relativenumber or hybridnumber.
-- Default: false.
--absolutenumber_unfocussed = true,
-- Enable auto highlighting for focused/unfocused windows
-- Default: false
--winhighlight = true,
-- By default, the highlight groups are setup as such:
-- hi default link FocusedWindow VertSplit
-- hi default link UnfocusedWindow Normal
-- To change them, you can link them to a different highlight group, see `:h hi-default` for more info.
--vim.cmd('hi link UnfocusedWindow CursorLine')
--vim.cmd('hi link FocusedWindow VisualNOS')
});
Only completely disabling plugin helps. Hope this issue gets fixed as this plugin is cool!
FWIW, I think I may have found out why this isn't working as intended.
It seems that the plugin is checking only the focused window's filetype and not applying the focus, but it does not take into account the splits and their filetypes.
Example: I tell focus.nvim to exclude help files, and then open a help file and another random file in a vertical split
focus.nvim is going to work as it should when I focus the helpfile, but when I go to the other buffer (which contains a non-excluded filetype), focus.nvim will try to manipulate the windows and thus the helpfile buffer will get resized -- not what we want!
This is just something I noticed while trying to figure out why this plugin isn't doing what intended.
FWIW, I think I may have found out why this isn't working as intended.
It seems that the plugin is checking only the focused window's filetype and not applying the focus, but it does not take into account the splits and their filetypes.
Example: I tell focus.nvim to exclude help files, and then open a help file and another random file in a vertical split
focus.nvim is going to work as it should when I focus the helpfile, but when I go to the other buffer (which contains a non-excluded filetype), focus.nvim will try to manipulate the windows and thus the helpfile buffer will get resized -- not what we want!
This is just something I noticed while trying to figure out why this plugin isn't doing what intended.
As far as resize is concerned - yes. Unfortunately, signcolumn and numbers are always trigger when focusing window leading to bugs such as this:
FWIW, I think I may have found out why this isn't working as intended.
It seems that the plugin is checking only the focused window's filetype and not applying the focus, but it does not take into account the splits and their filetypes.
Example: I tell focus.nvim to exclude help files, and then open a help file and another random file in a vertical split
focus.nvim is going to work as it should when I focus the helpfile, but when I go to the other buffer (which contains a non-excluded filetype), focus.nvim will try to manipulate the windows and thus the helpfile buffer will get resized -- not what we want!
This is just something I noticed while trying to figure out why this plugin isn't doing what intended.
This is exactly the issue. I have tried a number of patches but one approach ends up causing issues for some plugins etc, some approaches the other.
I think in the end of the day the naive approach to resizing this plugin does will need some improvement to support a wide variety of plugins and user preferences.
I have been looking into tracking each split, and then resizing them all accordingly. Rather than using an autocmd and resizing just the current split, it will loop around all splits at once and determine their sizes as per filetype/buftype and then size them accordingly.
This will solve the issue you described where it is not that the resize() function is resizing the ignored split, but rather the current split you are in is resized and then that might "crush" other splits as vim fights for screen real estate.
FWIW, I think I may have found out why this isn't working as intended. It seems that the plugin is checking only the focused window's filetype and not applying the focus, but it does not take into account the splits and their filetypes. Example: I tell focus.nvim to exclude help files, and then open a help file and another random file in a vertical split focus.nvim is going to work as it should when I focus the helpfile, but when I go to the other buffer (which contains a non-excluded filetype), focus.nvim will try to manipulate the windows and thus the helpfile buffer will get resized -- not what we want! This is just something I noticed while trying to figure out why this plugin isn't doing what intended.
As far as resize is concerned - yes. Unfortunately, signcolumn and numbers are always trigger when focusing window leading to bugs such as this:
I've only just noticed this now 😅 Thanks for pointing that out. I'll look into it.
The other issue is not related to focus itself but other plugins. There is a reason I opted to use vim.schedule to schedule resize to run in the event loop so that hopefully other plugins that are still initialising can finish. Sometimes focus will do its thing and then the plugin will do something later like setting the filetype. I have found some plugins don't set the filetype initially also, leading it to be empty initially and then set later after focus has read the buffers filetype and resized accordingly.
FWIW, I think I may have found out why this isn't working as intended. It seems that the plugin is checking only the focused window's filetype and not applying the focus, but it does not take into account the splits and their filetypes. Example: I tell focus.nvim to exclude help files, and then open a help file and another random file in a vertical split focus.nvim is going to work as it should when I focus the helpfile, but when I go to the other buffer (which contains a non-excluded filetype), focus.nvim will try to manipulate the windows and thus the helpfile buffer will get resized -- not what we want! This is just something I noticed while trying to figure out why this plugin isn't doing what intended.
As far as resize is concerned - yes. Unfortunately, signcolumn and numbers are always trigger when focusing window leading to bugs such as this:
I've only just noticed this now 😅 Thanks for pointing that out. I'll look into it.
The other issue is not related to focus itself but other plugins. There is a reason I opted to use vim.schedule to schedule resize to run in the event loop so that hopefully other plugins that are still initialising can finish. Sometimes focus will do its thing and then the plugin will do something later like setting the filetype. I have found some plugins don't set the filetype initially also, leading it to be empty initially and then set later after focus has read the buffers filetype and resized accordingly.
Yeah, I understand that this issue is not as easy as it may seem. I hope it gets resolved as this plugin is big improvement in my workflow from a visual point! Thanks for your hard work!
Just pushed an update of which I hope to address a few issues. https://github.com/beauwilliams/focus.nvim/commit/6ff7636a6ab7603ec39abe921ad62d406fd7dfa2
Simplified the logic in the hopes to prevent firing the resize() fn as often. I wanted also to try rid of vim.defer_fn in the resize autocommand. This was a solution that fixed as many bugs as it created but was necessary for get the right balance with various plugins that focus wishes to support.
So have it working without defer now again, testing a simplified autocmd logic and the ability to easily turn focus on and off per window. At least this will allow users to quickly disable on a per window basis without having to completely disable focus.
One could also potentially use the list of disabled window ID's as a method to disable for plugins etc (i.e set a mapping to create a window with focus disabled then open a plugin in that window)
Tracking window/buffer ID's is the direction in which I think will help to resolve many problems. What do you guys think?
Please try https://github.com/nvim-focus/focus.nvim/tree/refactor
Take a look at the Disabling Focus section: https://github.com/nvim-focus/focus.nvim/tree/refactor#disabling-focus
Fixed in current master/main.
Hi! This seems like a common issue, but I'm having trouble with excluding filetypes for "toggleterm", "qf" as well as "help" (I've tried buftype_exclude for "help" as well).
Demo:
https://user-images.githubusercontent.com/62098008/159968916-27ffbb99-e77c-4f55-a35b-d6ebe7a1c2b3.mp4
Expected behaviour:
My focus.nvim config:
My full config can be found here.