Skip to content

Commit

Permalink
fix: Fixed various bugs related to the new defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
OXY2DEV committed Aug 10, 2024
1 parent 7c24a92 commit e88ce30
Show file tree
Hide file tree
Showing 10 changed files with 889 additions and 769 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "helpview.nvim.wiki"]
path = helpview.nvim.wiki
url = https://github.com/OXY2DEV/helpview.nvim.wiki.git
21 changes: 17 additions & 4 deletions ftplugin/help.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local helpview = require("helpview");
local cursor_pos = {};

local ts_available, treesitter_parsers = pcall(require, "nvim-treesitter.parsers");

Expand Down Expand Up @@ -59,19 +60,20 @@ vim.api.nvim_create_autocmd({ "BufWinEnter" }, {
local cursor = vim.api.nvim_win_get_cursor(0);
local lines = vim.api.nvim_buf_line_count(event.buf);

cursor_pos[vim.api.nvim_get_current_win()] = cursor;
helpview.renderer.clear(event.buf);

-- Don't render stuff others can't see
if lines > 1000 then
local before = math.max(0, cursor[1] - (helpview.configuration.parse_range or 100));
local after = math.min(vim.api.nvim_buf_line_count(event.buf), cursor[1] + (helpview.configuration.parse_range or 100));

local parse = helpview.parser.init(event.buf, before, after);

helpview.renderer.clear(event.buf);
helpview.renderer.render(event.buf, parse, helpview.configuration, helpview.get_buffer_info(event.buf));
else
local parse = helpview.parser.init(event.buf);

helpview.renderer.clear(event.buf);
helpview.renderer.render(event.buf, parse, helpview.configuration, helpview.get_buffer_info(event.buf));
end
end
Expand Down Expand Up @@ -144,6 +146,8 @@ vim.api.nvim_create_autocmd(events, {

callback = function (event)
timer:stop();

local cursor = vim.api.nvim_win_get_cursor(0);
local mode = vim.api.nvim_get_mode().mode;
local buffer = event.buf;

Expand All @@ -155,8 +159,17 @@ vim.api.nvim_create_autocmd(events, {
return;
end

timer:start(100, 0, vim.schedule_wrap(function ()
local cursor = vim.api.nvim_win_get_cursor(0);
local debounce_delay = helpview.configuration.dsbounce_delay or 100;

--- Immediately draw if the distance is too big
if cursor_pos[vim.api.nvim_get_current_win()] and math.abs(cursor_pos[vim.api.nvim_get_current_win()][1] - cursor[1]) > vim.o.lines then
debounce_delay = 0;
end

cursor_pos[vim.api.nvim_get_current_win()] = cursor;

timer:start(debounce_delay, 0, vim.schedule_wrap(function ()
cursor = vim.api.nvim_win_get_cursor(0);
local lines = vim.api.nvim_buf_line_count(buffer);

if lines > 1000 then
Expand Down
1 change: 1 addition & 0 deletions helpview.nvim.wiki
Submodule helpview.nvim.wiki added at 1b7249
Loading

0 comments on commit e88ce30

Please sign in to comment.