regex filter for lsp_references #1210
-
Thank you for this I just tried the I want to generate a list of regex "matchers" for several languages, that will exclude the import statements from the Something like: local exclude_imports = {
python = {"regex_pattern_1", ...}, -- could match anything but "from main import main" or "import main"
javascript = {"regex_pattern_1", ...}, -- could match anything but "import React from 'react'" or "const react = require('react')"
etc, etc
} I don't think fzf-lua should worry about implementing a new config option just for this (something like Are there any other available options to use regex on the lsp_references? Maybe any of the advance entries could help on this? I'm willing to dig further and maybe create my own lsp_references just for my config. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
We can have |
Beta Was this translation helpful? Give feedback.
-
@serranomorante, see a9e5755 Added some improvements including the below: :FzfLua lsp_references regex_filter={"import.*from.*",exclude=true}
-- equal to:
:lua require("fzf-lua").lsp_finder({ regex_filter = {"import.*from.*", exclude=true} }) You can also define -- Explore `ctx` and `item` with `vim.print` so you can decide on your filtering logic
-- `ctx` contains buffer number and so you can determine `filetype`, etc
:lua require("fzf-lua").lsp_finder({regex_filter=function(e,ctx) vim.print(ctx); return true end}) When a function is used the header will display |
Beta Was this translation helpful? Give feedback.
@serranomorante, see a9e5755
Added some improvements including the below:
You can also define
regex_filter
as a function, when it returnsfalse
the item will be filtered out:When a function is used the header will display
<function>
, can be disabled withheader=false
: