Skip to content

Commit

Permalink
perf(sources.path): stop treesitter before setting preview buf lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Bekaboo committed Jan 13, 2025
1 parent 80538f5 commit 9f6a19a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lua/dropbar/sources/path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ local function preview(sym)
return lines
end

vim.api.nvim_buf_set_name(sym.data.preview_buf, preview_bufnewname)
vim.api.nvim_buf_call(sym.data.preview_buf, function()
vim.treesitter.stop(sym.data.preview_buf)
vim.bo.syntax = ''
end)

local lines = not stat and nopreview('Not a file or directory')
or stat.type == 'directory' and vim.fn.systemlist(
'ls -lhA ' .. vim.fn.shellescape(sym.data.path)
Expand All @@ -88,15 +94,10 @@ local function preview(sym)
:totable()

vim.bo[sym.data.preview_buf].modifiable = true
vim.api.nvim_buf_set_lines(sym.data.preview_buf, 0, -1, false, {})
vim.api.nvim_buf_set_lines(sym.data.preview_buf, 0, -1, false, lines)
vim.bo[sym.data.preview_buf].modifiable = false

vim.api.nvim_buf_set_name(sym.data.preview_buf, preview_bufnewname)
vim.api.nvim_buf_call(sym.data.preview_buf, function()
vim.treesitter.stop(sym.data.preview_buf)
end)
vim.bo[sym.data.preview_buf].syntax = ''

if not add_syntax then
return
end
Expand Down

0 comments on commit 9f6a19a

Please sign in to comment.