Skip to content

Commit

Permalink
Merge pull request #53 from jinzhongjia/main
Browse files Browse the repository at this point in the history
[fix]: When the window was first created, filetype was empty.
  • Loading branch information
hedyhli committed May 19, 2024
2 parents dbd8368 + a533494 commit 139e363
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lua/outline/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@ 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)

-- 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 if split_command not specify width like "25vsplit"
if split_command:match("%d+") == nil then
-- resize to a % of the current window size
vim.cmd('vertical resize ' .. cfg.o.outline_window.width)
end

-- 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)

-- window stuff
vim.api.nvim_win_set_option(self.win, 'spell', false)
vim.api.nvim_win_set_option(self.win, 'signcolumn', 'no')
Expand All @@ -53,7 +57,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
Expand Down

0 comments on commit 139e363

Please sign in to comment.