2021-05-11 19:22:58 +00:00
|
|
|
-- Copyright (c) 2020-2021 hoob3rt
|
|
|
|
-- MIT license, see LICENSE for more details.
|
2021-05-19 20:36:55 +00:00
|
|
|
--
|
|
|
|
local function is_loclist()
|
2021-09-03 18:28:20 +00:00
|
|
|
return vim.fn.getloclist(0, { filewinid = 1 }).filewinid ~= 0
|
2021-05-19 20:36:55 +00:00
|
|
|
end
|
2021-05-11 19:22:58 +00:00
|
|
|
|
2021-05-19 20:36:55 +00:00
|
|
|
local function label()
|
|
|
|
return is_loclist() and 'Location List' or 'Quickfix List'
|
|
|
|
end
|
|
|
|
|
|
|
|
local function title()
|
|
|
|
if is_loclist() then
|
2021-09-03 18:28:20 +00:00
|
|
|
return vim.fn.getloclist(0, { title = 0 }).title
|
2021-05-19 20:36:55 +00:00
|
|
|
end
|
2021-09-03 18:28:20 +00:00
|
|
|
return vim.fn.getqflist({ title = 0 }).title
|
2021-05-19 20:36:55 +00:00
|
|
|
end
|
2021-09-03 18:28:20 +00:00
|
|
|
local empty = {
|
|
|
|
function()
|
|
|
|
return ' '
|
|
|
|
end,
|
2021-09-14 15:14:23 +00:00
|
|
|
padding = 0,
|
2021-09-03 18:28:20 +00:00
|
|
|
}
|
2021-05-11 19:22:58 +00:00
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
2021-08-13 01:20:56 +00:00
|
|
|
function M.init()
|
|
|
|
-- Make sure ft wf doesn't create a custom statusline
|
|
|
|
vim.g.qf_disable_statusline = true
|
|
|
|
end
|
|
|
|
|
2021-05-11 19:22:58 +00:00
|
|
|
M.sections = {
|
2021-09-03 18:28:20 +00:00
|
|
|
lualine_a = { label },
|
|
|
|
lualine_b = { title },
|
|
|
|
lualine_c = { empty },
|
|
|
|
lualine_z = { 'location' },
|
2021-05-11 19:22:58 +00:00
|
|
|
}
|
|
|
|
|
2021-09-03 18:28:20 +00:00
|
|
|
M.filetypes = { 'qf' }
|
2021-05-11 19:22:58 +00:00
|
|
|
|
|
|
|
return M
|