From 4a7cc30c8600d38ae0690d2203fb90555741210b Mon Sep 17 00:00:00 2001 From: jinzhongjia Date: Tue, 20 Feb 2024 18:35:14 +0800 Subject: [PATCH] [fix]: When the window was first created, filetype was empty. --- lua/outline/view.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lua/outline/view.lua b/lua/outline/view.lua index 6067e77..f7824d0 100644 --- a/lua/outline/view.lua +++ b/lua/outline/view.lua @@ -18,18 +18,22 @@ function View:setup_view(split_command) -- create a scratch unlisted buffer self.buf = vim.api.nvim_create_buf(false, true) + -- set filetype + vim.api.nvim_buf_set_option(self.buf, 'filetype', 'Outline') + -- delete buffer when window is closed / buffer is hidden vim.api.nvim_buf_set_option(self.buf, 'bufhidden', 'delete') + -- create a split vim.cmd(split_command) - -- resize to a % of the current window size - vim.cmd('vertical resize ' .. cfg.o.outline_window.width) - -- get current (outline) window and attach our buffer to it self.win = vim.api.nvim_get_current_win() vim.api.nvim_win_set_buf(self.win, self.buf) + -- resize to a % of the current window size + vim.cmd('vertical resize ' .. cfg.o.outline_window.width) + -- window stuff vim.api.nvim_win_set_option(self.win, 'spell', false) vim.api.nvim_win_set_option(self.win, 'signcolumn', 'no') @@ -50,7 +54,6 @@ function View:setup_view(split_command) -- buffer stuff local tab = vim.api.nvim_get_current_tabpage() vim.api.nvim_buf_set_name(self.buf, 'OUTLINE_' .. tostring(tab)) - vim.api.nvim_buf_set_option(self.buf, 'filetype', 'Outline') vim.api.nvim_buf_set_option(self.buf, 'modifiable', false) if cfg.o.outline_window.show_numbers or cfg.o.outline_window.show_relative_numbers then