Skip to content

Commit

Permalink
fix: revert gsub changes to lang and clean up logs
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgriffing committed Dec 26, 2022
1 parent d70eb64 commit e58b47d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lua/nvim-biscuits/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ local ts_utils = require('nvim-treesitter.ts_utils')
local nvim_biscuits = {should_render_biscuits = true}

local make_biscuit_hl_group_name =
function(lang) return 'BiscuitColor' .. lang end
function(lang)
return 'BiscuitColor' .. lang
end

nvim_biscuits.decorate_nodes = function(bufnr, lang)
if config.get_language_config(final_config, lang, "disabled") then return end

utils.console_log("decorating nodes for " .. lang)

local parser = ts_parsers.get_parser(bufnr, lang)

utils.console_log("parser " .. lang)

if parser == nil then
utils.console_log('no parser for ' .. lang)
return
Expand Down Expand Up @@ -51,7 +49,6 @@ nvim_biscuits.decorate_nodes = function(bufnr, lang)

local start_line, start_col, end_line, end_col =
ts_utils.get_node_range(node)
-- local text = ts_utils.get_node_text(node)[1]

local lines = vim.api.nvim_buf_get_lines(bufnr, start_line,
start_line + 1, false)
Expand Down Expand Up @@ -165,7 +162,7 @@ nvim_biscuits.BufferAttach = function(bufnr)

attached_buffers[bufnr] = true

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

local toggle_keybind = config.get_language_config(final_config, lang,
"toggle_keybind")
Expand All @@ -178,13 +175,14 @@ nvim_biscuits.BufferAttach = function(bufnr)

local on_lines = function() nvim_biscuits.decorate_nodes(bufnr, lang) end

if lang then
vim.cmd("highlight default link " .. make_biscuit_hl_group_name(lang) ..
" BiscuitColor")
end

-- 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
if bufnr then
utils.console_log('bufnr ' .. bufnr)
nvim_biscuits.decorate_nodes(bufnr, lang)
end
else
Expand Down Expand Up @@ -220,7 +218,7 @@ nvim_biscuits.toggle_biscuits = function()
nvim_biscuits.should_render_biscuits =
not nvim_biscuits.should_render_biscuits
local bufnr = vim.api.nvim_get_current_buf()
local lang = ts_parsers.get_buf_lang(bufnr)
local lang = ts_parsers.get_buf_lang(bufnr):gsub("-", "")
nvim_biscuits.decorate_nodes(bufnr, lang)
end

Expand Down

0 comments on commit e58b47d

Please sign in to comment.