Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(builtin.lsp): respect file_ignore_patterns opt for direct jumps #3173

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lua/telescope/builtin/__lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,25 @@ local apply_action_handler = function(action, items, opts)
return items
end

---@param items vim.lsp.util.locations_to_items.ret[]
---@param opts table
---@return vim.lsp.util.locations_to_items.ret[]
local function filter_file_ignore_patters(items, opts)
local file_ignore_patterns = vim.F.if_nil(opts.file_ignore_patterns, conf.file_ignore_patterns, {})
if vim.tbl_isempty(file_ignore_patterns) then
return items
end

return vim.tbl_filter(function(item)
for _, patt in ipairs(file_ignore_patterns) do
if string.match(item.filename, patt) then
return false
end
end
return true
end, items)
end

---@param action telescope.lsp.list_or_jump_action
---@param title string prompt title
---@param funname string: name of the calling function
Expand Down Expand Up @@ -176,6 +195,7 @@ local function list_or_jump(action, title, funname, params, opts)
local offset_encoding = vim.lsp.get_client_by_id(ctx.client_id).offset_encoding
local items = vim.lsp.util.locations_to_items(locations, offset_encoding)
items = apply_action_handler(action, items, opts)
items = filter_file_ignore_patters(items, opts)

if vim.tbl_isempty(items) then
utils.notify(funname, {
Expand Down