Add new components

This commit is contained in:
Olivier Roques
2020-12-22 18:50:04 +01:00
parent 778b6b1219
commit 355aacba17
7 changed files with 65 additions and 1 deletions

View File

@@ -27,6 +27,11 @@ M.sections = {
require('hardline.mode'), ' ',
require('hardline.git'), ' ',
require('hardline.file'), ' ',
'%=',
-- require('hardline.lsp'),
-- require('hardline.whitespace'),
require('hardline.filetype'), ' ',
require('hardline.line'),
}
-------------------- HELPERS -------------------------------

View File

@@ -11,6 +11,7 @@ end
function M.get_component()
return table.concat({
[[%<]],
[[%{luaeval('require("hardline.file").get_name()')}]],
M.get_mode(),
})

15
lua/hardline/filetype.lua Normal file
View File

@@ -0,0 +1,15 @@
local vim = vim
local bo = vim.bo
local M = {}
function M.get_filetype()
return bo.filetype
end
function M.get_component()
return table.concat({
[[%{luaeval('require("hardline.filetype").get_filetype()')}]],
})
end
return M

View File

@@ -15,7 +15,10 @@ function M.get_hunks()
end
function M.get_branch()
return ''
if not g.loaded_gitgutter then
return ''
end
return string.format(' %s', fn.FugitiveHead())
end
function M.get_component()

24
lua/hardline/line.lua Normal file
View File

@@ -0,0 +1,24 @@
local cmd, fn, vim = vim.cmd, vim.fn, vim
local M = {}
function M.get_line()
return string.format('%03d/%03d', fn.line('.'), fn.line('$'))
end
function M.get_column()
return string.format('%03d/%03d', fn.col('.'), fn.col('$') - 1)
end
function M.get_percent()
return '%03p%%'
end
function M.get_component()
return table.concat({
[[%{luaeval('require("hardline.line").get_line()')}]], ':',
[[%{luaeval('require("hardline.line").get_column()')}]], ' ',
M.get_percent(),
})
end
return M

8
lua/hardline/lsp.lua Normal file
View File

@@ -0,0 +1,8 @@
local fn, vim = vim.fn, vim
local M = {}
function M.get_component()
return table.concat({})
end
return M

View File

@@ -0,0 +1,8 @@
local fn, vim = vim.fn, vim
local M = {}
function M.get_component()
return table.concat({})
end
return M