Skip to content

Commit

Permalink
fix: Fixed a bug causing visual artifacts with tables in split view
Browse files Browse the repository at this point in the history
fix: Added a checkhealth module

fix: Fixed definitions for callbacks

chore: Added some logic for version detection
  • Loading branch information
OXY2DEV committed Oct 5, 2024
1 parent b0df405 commit b2d46d9
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 1 deletion.
1 change: 1 addition & 0 deletions lua/definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
---@field on_enable fun(buf: integer, win: integer): nil
---@field on_disable fun(buf: integer, win: integer): nil
---@field on_mode_change fun(buf: integer, win: integer, mode: string): nil
---@field split_enter? fun(buf: integer, win: integer): nil

--- Block quotes
---------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions lua/markview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,7 @@ markview.splitView = {
local cursor = vim.api.nvim_win_get_cursor(windows[1]);
pcall(vim.api.nvim_win_set_cursor, self.window, cursor);

vim.api.nvim_buf_clear_namespace(self.buffer, markview.renderer.namespace, 0, -1);
local parsed_content;

if #content < markview.configuration.max_file_length then
Expand Down
53 changes: 53 additions & 0 deletions lua/markview/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
local health = {};

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

local devicons_loaded = pcall(require, "nvim-web-devicons");
local mini_loaded = pcall(require, "mini.icons");

--- Checks if a parser is available or not
---@param parser_name string
---@return boolean
local function parser_installed(parser_name)
return (ts_available and treesitter_parsers.has_parser(parser_name)) or pcall(vim.treesitter.query.get, parser_name, "highlights")
end

health.check = function ()
local ver = vim.version();

vim.health.start("Checking essentials:")

if vim.fn.has("nvim-0.10.0") == 1 then
vim.health.ok("Neovim version: " .. string.format("`%d.%d.%d`", ver.major, ver.minor, ver.patch));
else
vim.health.error("Unsupported neovim version. Minimum requirement `0.10.1`, found: " .. string.format("`%d.%d.%d`", ver.major, ver.minor, ver.patch));
end

if ts_available then
vim.health.ok("`nvim-treesitter/nvim-treesitter` found!")
else
vim.health.warn("`nvim-treesitter/nvim-treesitter` wasn't found! Ignore this if you manually installed the parsers!")
end

vim.health.start("Checking parsers:")

for _, parser in ipairs({ "markdown", "markdown_inline", "html", "latex" }) do
if parser_installed(parser) then
vim.health.ok("`" .. parser .. "` " .. "was found!");
else
vim.health.warn("`" .. parser .. "` " .. "wasn't found.");
end
end

vim.health.start("Checking icon providers:");

if devicons_loaded then
vim.health.ok("`nvim-tree/nvim-web-devicons` found!");
elseif mini_loaded then
vim.health.ok("`echasnovski/mini.icons` found!");
else
vim.health.warn("External icon providers weren't found! Using internal icon providers instead.")
end
end

return health;
2 changes: 1 addition & 1 deletion markview.nvim.wiki
5 changes: 5 additions & 0 deletions plugin/markview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ local utils = require("markview.utils");
local hls = require("markview.highlights");
local ts = require("markview.treesitter");

if vim.fn.has("nvim-0.10.1") == 0 then
vim.notify("[ markview.nvim ]: Neovim version 0.10+ required!", vim.diagnostic.severity.ERROR)
return;
end

---@diagnostic disable
ts.inject(markview.configuration.injections)
hls.create(markview.configuration.highlight_groups)
Expand Down

0 comments on commit b2d46d9

Please sign in to comment.