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-05-11 19:22:58 +00:00
|
|
|
|
2023-03-31 15:07:07 +00:00
|
|
|
local qf_colours = {
|
|
|
|
ll = vim.api.nvim_get_hl_by_name('Constant', false).foreground,
|
|
|
|
qf = vim.api.nvim_get_hl_by_name('Identifier', false).foreground,
|
|
|
|
}
|
|
|
|
|
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 = {
|
2023-03-31 15:07:07 +00:00
|
|
|
lualine_a = {
|
|
|
|
{
|
|
|
|
label,
|
|
|
|
color = function()
|
|
|
|
return is_loclist() and { bg = qf_colours['ll'] } or { bg = qf_colours['qf'] }
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
2021-09-03 18:28:20 +00:00
|
|
|
lualine_b = { title },
|
|
|
|
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
|