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.
|
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
--
|
--
|
||||||
require("mini.statusline").setup()
|
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
|
return cwd
|
||||||
end
|
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)
|
NV_Darcula_Grab_Selection = function(cb)
|
||||||
local selection = utils.get_visual_text()
|
local selection = utils.get_visual_text()
|
||||||
vim.schedule(
|
vim.schedule(
|
||||||
|
|||||||
@@ -42,14 +42,15 @@ return {
|
|||||||
git = {
|
git = {
|
||||||
added = "",
|
added = "",
|
||||||
blame = "",
|
blame = "",
|
||||||
|
branch = "",
|
||||||
conflict = "",
|
conflict = "",
|
||||||
unstaged = "",
|
deleted = "",
|
||||||
|
ignored = "◌",
|
||||||
|
renamed = "",
|
||||||
staged = "",
|
staged = "",
|
||||||
unmerged = "",
|
unmerged = "",
|
||||||
renamed = "",
|
unstaged = "",
|
||||||
untracked = "",
|
untracked = ""
|
||||||
deleted = "",
|
|
||||||
ignored = "◌"
|
|
||||||
},
|
},
|
||||||
indent = "│",
|
indent = "│",
|
||||||
listchars = {
|
listchars = {
|
||||||
|
|||||||
Reference in new issue
Block a user