Skip to content

Commit f611f3a

Browse files
committed
feat(kinds): Add option to auto close loclist
1 parent 07dc9a9 commit f611f3a

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

lua/kustomize/config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ M.options = {
44
enable_key_mappings = true,
55
enable_lua_snip = false,
66
build = { additional_args = {} },
7-
kinds = { show_filepath = true, show_line = true, exclude_pattern = {} },
7+
kinds = { auto_close = false, show_filepath = true, show_line = true, exclude_pattern = {} },
88
-- the last argument of a run command is always a file with the current buffer's content
99
run = {
1010
validate = {

lua/kustomize/init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ M.setup = function(opts)
4242
M.set_default_mappings()
4343
end
4444

45+
if config.options.kinds.auto_close then
46+
utils.auto_close_loclist()
47+
end
48+
4549
if config.options.enable_lua_snip then
4650
if not utils.is_module_available("luasnip") then
4751
utils.error("Could not load L3MON4D3/LuaSnip")

lua/kustomize/utils.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,24 @@ M.reload_config = function()
213213
end
214214
end
215215

216+
M.auto_close_loclist = function()
217+
vim.api.nvim_create_autocmd("FileType", {
218+
pattern = "qf",
219+
callback = function()
220+
-- Check if this is a location list (not a quickfix list)
221+
local is_loclist = vim.fn.getwininfo(vim.fn.win_getid())[1].loclist == 1
222+
223+
if is_loclist then
224+
-- Get the location list title
225+
local loc_title = vim.fn.getloclist(0, { title = 0 }).title
226+
227+
-- Check if the title contains your plugin's name or identifier
228+
if loc_title:match("Kustomize") then
229+
vim.api.nvim_buf_set_keymap(0, "n", "<CR>", "<CR>:lclose<CR>", { noremap = true, silent = true })
230+
end
231+
end
232+
end,
233+
})
234+
end
235+
216236
return M

0 commit comments

Comments
 (0)