Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix broken/buggy lua examples #943

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Changes from all 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
18 changes: 11 additions & 7 deletions doc/bufferline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ The available configuration are:
},
sort_by = 'insert_after_current' |'insert_at_end' | 'id' | 'extension' | 'relative_directory' | 'directory' | 'tabs' | function(buffer_a, buffer_b)
-- add custom logic
return buffer_a.modified > buffer_b.modified
local modified_a = vim.fn.getftime(buffer_a.path)
local modified_b = vim.fn.getftime(buffer_b.path)
return modified_a > modified_b
end
}
}
Expand Down Expand Up @@ -483,7 +485,9 @@ are available to use using >lua
sort_by = function(buffer_a, buffer_b)
print(vim.inspect(buffer_a))
-- add custom logic
return buffer_a.modified > buffer_b.modified
local modified_a = vim.fn.getftime(buffer_a.path)
local modified_b = vim.fn.getftime(buffer_b.path)
return modified_a > modified_b
end
<

Expand Down Expand Up @@ -573,7 +577,7 @@ A user can also execute arbitrary functions against a buffer using the
function _G.bdel(num)
require('bufferline').exec(num, function(buf, visible_buffers)
vim.cmd('bdelete '..buf.id)
end
end)
end

vim.cmd [[
Expand Down Expand Up @@ -1126,19 +1130,19 @@ to be shown in a list of tables. For example:
local hint = #vim.diagnostic.get(0, {severity = seve.HINT})

if error ~= 0 then
table.insert(result, {text = "  " .. error, fg = "#EC5241"})
table.insert(result, {text = "  " .. error, link = "DiagnosticError"})
end

if warning ~= 0 then
table.insert(result, {text = "  " .. warning, fg = "#EFB839"})
table.insert(result, {text = "  " .. warning, link = "DiagnosticWarn"})
end

if hint ~= 0 then
table.insert(result, {text = "  " .. hint, fg = "#A3BA5E"})
table.insert(result, {text = "  " .. hint, link = "DiagnosticHint"})
end

if info ~= 0 then
table.insert(result, {text = "  " .. info, fg = "#7EA9A7"})
table.insert(result, {text = "  " .. info, link = "DiagnosticInfo"})
end
return result
end,
Expand Down
Loading