From 90465952ea2d2b81fb1ce84c6cfc2fb54aae9276 Mon Sep 17 00:00:00 2001 From: Chris Griffing Date: Mon, 26 Dec 2022 13:43:53 -0800 Subject: [PATCH] fix: add default for show_on_start as true and check for existing bufnr before decorating nodes --- lua/nvim-biscuits/config.lua | 3 ++- lua/nvim-biscuits/init.lua | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lua/nvim-biscuits/config.lua b/lua/nvim-biscuits/config.lua index 41351af..9bf8edb 100644 --- a/lua/nvim-biscuits/config.lua +++ b/lua/nvim-biscuits/config.lua @@ -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 diff --git a/lua/nvim-biscuits/init.lua b/lua/nvim-biscuits/init.lua index bdcdccd..c522dd7 100644 --- a/lua/nvim-biscuits/init.lua +++ b/lua/nvim-biscuits/init.lua @@ -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 @@ -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") @@ -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