From 2f0f1fc49d9ff092ea5317d571bf9bfc93a587af Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez Date: Wed, 19 May 2021 22:36:55 +0200 Subject: [PATCH] feat: quickfix/locationlist extension(#248) --- lua/lualine/extensions/quickfix.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lua/lualine/extensions/quickfix.lua b/lua/lualine/extensions/quickfix.lua index 8df915e..0e87a35 100644 --- a/lua/lualine/extensions/quickfix.lua +++ b/lua/lualine/extensions/quickfix.lua @@ -1,14 +1,26 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. -local function quickfix() return 'Quickfix List' end +-- +local function is_loclist() + return vim.fn.getloclist(0, {filewinid = 1}).filewinid ~= 0 +end -local function quickfix_title() return vim.fn.getqflist({title = 0}).title end +local function label() + return is_loclist() and 'Location List' or 'Quickfix List' +end + +local function title() + if is_loclist() then + return vim.fn.getloclist(0, {title = 0}).title + end + return vim.fn.getqflist({title = 0}).title +end local M = {} M.sections = { - lualine_a = {quickfix}, - lualine_b = {quickfix_title}, + lualine_a = {label}, + lualine_b = {title}, lualine_z = {'location'} }