-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show count of modified/normal buffers
- Loading branch information
1 parent
3eec7b0
commit 349dbe1
Showing
4 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
return { | ||
init = function(self) | ||
self.all = vim.api.nvim_list_bufs() | ||
|
||
self.normal = vim.tbl_filter(function(bufnr) | ||
return not require("dko.utils.buffer").is_special(bufnr) | ||
end, self.all) | ||
|
||
self.modified = vim.tbl_filter(function(bufnr) | ||
return vim.api.nvim_buf_get_option(bufnr, "modified") | ||
end, self.normal) | ||
end, | ||
{ | ||
provider = " ", | ||
hl = "StatusLineNC", | ||
}, | ||
{ | ||
provider = function(self) | ||
return ("%d"):format(#self.modified) | ||
end, | ||
hl = function(self) | ||
return #self.modified > 0 and "TODO" or "StatusLineNC" | ||
end, | ||
}, | ||
{ | ||
provider = function(self) | ||
return ("/%d"):format(#self.normal) | ||
end, | ||
hl = "StatusLineNC", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
-- Operations on multiple buffers | ||
--- | ||
|
||
local M = {} | ||
|
||
---@param bufnrs table like vim.api.nvim_list_bufs() | ||
---@return table only modified | ||
M.filter_modified = function(bufnrs) | ||
return vim.tbl_filter(function(bufnr) | ||
return vim.api.nvim_buf_get_option(bufnr, "modified") | ||
end, bufnrs) | ||
end | ||
|
||
---@param bufnrs table like vim.api.nvim_list_bufs() | ||
---@return table only special | ||
M.filter_special = function(bufnrs) | ||
return vim.tbl_filter(function(bufnr) | ||
return require('dko.utils.buffer').is_special(bufnr) | ||
end, bufnrs) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters