Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
dashboard-backers dashboard.txt /*dashboard-backers*
dashboard-configuration dashboard.txt /*dashboard-configuration*
dashboard-configuration-options dashboard.txt /*dashboard-configuration-options*
dashboard-configuration-theme-config dashboard.txt /*dashboard-configuration-theme-config*
dashboard-donate dashboard.txt /*dashboard-donate*
dashboard-feature dashboard.txt /*dashboard-feature*
dashboard-install dashboard.txt /*dashboard-install*
dashboard-license dashboard.txt /*dashboard-license*
dashboard-links dashboard.txt /*dashboard-links*
dashboard-table-of-contents dashboard.txt /*dashboard-table-of-contents*
dashboard.txt dashboard.txt /*dashboard.txt*
14 changes: 12 additions & 2 deletions lua/dashboard/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ local uv = vim.loop
local utils = {}

utils.is_win = uv.os_uname().version:match('Windows')
local is_nvim_11_or_newer = vim.version().minor >= 11 -- check nvim minor ver
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vim.fn.has 'nvim-0.11' == 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glepnir is it the right way to check?

If you have access to a neovim version < 0.11, can you try this in the cmdline.

:print(vim.version().minor)

if it prints anything below 11, the line i have put should work.

Will vim.fn.has 'nvim-0.11' == 1 keep working for the future as well?. Seems to me it only verifies a single version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is i used in nvim-lspcofig

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, then that's confirmed to be working. I'll switch to that then.


function utils.path_join(...)
local path_sep = utils.is_win and '\\' or '/'
return table.concat({ ... }, path_sep)
end

-- dynamically use correct validate form method
local function validate_table(name, value)
if is_nvim_11_or_newer then
vim.validate(name, value, 'table')
else
vim.validate({ [name] = { value, 't' } })
end
end

function utils.element_align(tbl)
local lens = {}
vim.tbl_map(function(k)
Expand All @@ -26,7 +36,7 @@ function utils.element_align(tbl)
end

function utils.get_max_len(contents)
vim.validate('contents', contents, 'table')
validate_table('contents', contents)
local cells = {}
for _, v in pairs(contents) do
table.insert(cells, vim.api.nvim_strwidth(v))
Expand All @@ -37,7 +47,7 @@ end

-- draw the graphics into the screen center
function utils.center_align(tbl)
vim.validate('tbl', tbl, 'table')
validate_table('tbl', tbl)
local function fill_sizes(lines)
local fills = {}
for _, line in pairs(lines) do
Expand Down
Loading