Skip to content

Commit

Permalink
[fix]: When the window was first created, filetype was empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhongjia committed Feb 20, 2024
1 parent a8d40ae commit 4a7cc30
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lua/outline/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand Down

0 comments on commit 4a7cc30

Please sign in to comment.