From 579b90e6a8aea0f902be7936dd36f511e3e584af Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 29 Feb 2024 19:50:10 +0000 Subject: [PATCH] lsp: remove definitions from vendor-bin --- lua/opdavies/lsp/handlers.lua | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lua/opdavies/lsp/handlers.lua b/lua/opdavies/lsp/handlers.lua index b49a3de..0fd582c 100644 --- a/lua/opdavies/lsp/handlers.lua +++ b/lua/opdavies/lsp/handlers.lua @@ -4,11 +4,23 @@ M.definition = function() local params = vim.lsp.util.make_position_params() vim.lsp.buf_request(0, "textDocument/definition", params, function(err, result, ctx, config) - local new_result = vim.tbl_filter(function(v) - -- TODO: remove definitions within vendor-bin directory for PHP files? + local bufnr = ctx.bufnr + local ft = vim.api.nvim_buf_get_option(bufnr, "filetype") + local new_result = vim.tbl_filter(function(v) -- Remove any definitions within the nix store via the .direnv directory. - return not string.find(v.targetUri, ".direnv") + if string.find(v.targetUri, ".direnv") then + return false + end + + -- Remove definitions within vendor-bin directory for PHP files. + if ft == "php" then + if string.find(v.targetUri, "vendor%-bin") then + return false + end + end + + return true end, result) if #new_result > 0 then