Skip to content

Commit

Permalink
fix: add default for show_on_start as true and check for existing buf…
Browse files Browse the repository at this point in the history
…nr before decorating nodes
  • Loading branch information
cmgriffing committed Dec 26, 2022
1 parent d93872b commit 9046595
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lua/nvim-biscuits/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ config.default_config = function()
prefix_string = " // ",
-- on_events example: { "InsertLeave", "CursorHoldI" }
on_events = {},
trim_by_words = false
trim_by_words = false,
show_on_start = true
}
end

Expand Down
11 changes: 8 additions & 3 deletions lua/nvim-biscuits/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ nvim_biscuits.decorate_nodes = function(bufnr, lang)

local parser = ts_parsers.get_parser(bufnr, lang)

utils.console_log("parser " .. lang)

if parser == nil then
utils.console_log('no parser for for ' .. lang)
utils.console_log('no parser for ' .. lang)
return
end

Expand Down Expand Up @@ -163,7 +165,7 @@ nvim_biscuits.BufferAttach = function(bufnr)

attached_buffers[bufnr] = true

local lang = ts_parsers.get_buf_lang(bufnr):gsub("-", "")
local lang = ts_parsers.get_buf_lang(bufnr)

local toggle_keybind = config.get_language_config(final_config, lang,
"toggle_keybind")
Expand All @@ -181,7 +183,10 @@ nvim_biscuits.BufferAttach = function(bufnr)

-- we need to fire once at the very start if config allows
if (not toggle_keybind) or config.get_language_config(final_config, lang, "show_on_start") then
nvim_biscuits.decorate_nodes(bufnr, lang)
if bufnr then
utils.console_log('bufnr ' .. bufnr)
nvim_biscuits.decorate_nodes(bufnr, lang)
end
else
nvim_biscuits.should_render_biscuits = false
end
Expand Down

0 comments on commit 9046595

Please sign in to comment.