added branch to statusline
This commit is contained in:
1 parent
3879bf8751
commit
787505258d
3 files changed
+56
-5
No files matched your search
@@ -18,3 +18,40 @@
|
||||
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
--
|
||||
require("mini.statusline").setup()
|
||||
|
||||
local symbols = require("darcula.utils.symbols")
|
||||
local statusline = require("mini.statusline")
|
||||
|
||||
local section_branch = function()
|
||||
local branch = NV_Darcula_Git_Branch()
|
||||
if branch == nil or branch == "" then
|
||||
return ""
|
||||
end
|
||||
|
||||
return symbols.git.branch .. " " .. branch
|
||||
end
|
||||
|
||||
statusline.setup {
|
||||
content = {
|
||||
active = function()
|
||||
local mode, mode_hl = statusline.section_mode({trunc_width = 120})
|
||||
local branch = section_branch()
|
||||
local diagnostics = statusline.section_diagnostics({trunc_width = 75})
|
||||
local filename = statusline.section_filename({trunc_width = 140})
|
||||
local fileinfo = statusline.section_fileinfo({trunc_width = 120})
|
||||
local location = statusline.section_location({trunc_width = 75})
|
||||
|
||||
return statusline.combine_groups(
|
||||
{
|
||||
{hl = mode_hl, strings = {mode}},
|
||||
{hl = "MiniStatuslineDevinfo", strings = {branch, diagnostics}},
|
||||
"%<",
|
||||
{hl = "MiniStatuslineFilename", strings = {filename}},
|
||||
"%=",
|
||||
{hl = "MiniStatuslineFileinfo", strings = {fileinfo}},
|
||||
{hl = mode_hl, strings = {location}}
|
||||
}
|
||||
)
|
||||
end
|
||||
}
|
||||
}
|
||||
@@ -121,6 +121,19 @@ NV_Darcula_Git_Root = function(cwd)
|
||||
return cwd
|
||||
end
|
||||
|
||||
NV_Darcula_Git_Branch = function(cwd)
|
||||
cwd = cwd or vim.loop.cwd()
|
||||
local output =
|
||||
vim.fn.systemlist(
|
||||
{"git", "-C", cwd, "symbolic-ref", "--quiet", "--short", "HEAD"}
|
||||
)
|
||||
if vim.v.shell_error == 0 and output[1] and #output[1] > 0 then
|
||||
return output[1]
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
NV_Darcula_Grab_Selection = function(cb)
|
||||
local selection = utils.get_visual_text()
|
||||
vim.schedule(
|
||||
|
||||
@@ -42,14 +42,15 @@ return {
|
||||
git = {
|
||||
added = "",
|
||||
blame = "",
|
||||
branch = "",
|
||||
conflict = "",
|
||||
unstaged = "",
|
||||
deleted = "",
|
||||
ignored = "◌",
|
||||
renamed = "",
|
||||
staged = "",
|
||||
unmerged = "",
|
||||
renamed = "",
|
||||
untracked = "",
|
||||
deleted = "",
|
||||
ignored = "◌"
|
||||
unstaged = "",
|
||||
untracked = ""
|
||||
},
|
||||
indent = "│",
|
||||
listchars = {
|
||||
|
||||
Reference in new issue
Block a user