Skip to content

Conversation

mosheavni
Copy link

@mosheavni mosheavni commented Jun 18, 2025

Describe what this PR does / why we need it

It respects the user search on fzf-lua "search" | "mentionable" | "assignable".
also adds highlight to organization name if the search opt is search

Does this pull request fix one issue?

Describe how you did it

I copied some of the logic from telescope provider.
Upon testing, I saw we didn't implement yet requesting a review from a team:

-- for teams use `teamIds`

so I added a "not implemented yet" message.

Describe how to verify it

I tested on multiple PRs and multiple repos

Special notes for reviews

Checklist

  • Passing tests and linting standards
  • Documentation updates in README.md and doc/octo.txt

@mosheavni mosheavni changed the title feat/fzf-assignable feat(fzf): respect users option Jun 18, 2025
@mosheavni
Copy link
Author

@pwntester @williambdean anything here?

local fzf = require "fzf-lua"
local gh = require "octo.gh"
local graphql = require "octo.gh.graphql"
local picker_utils = require "octo.pickers.fzf-lua.pickers.utils"
local utils = require "octo.utils"

return function(cb)
local formatted_users = {}
local orgs = {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be scoped here or defined within function?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use if for the inception picker of orgs.
if its an org, I need to open another picker with the org teams, so I keep the orgs on the module level so I can access it another time.
Basically this is the same thing that was before my PR, but now just for orgs and not for users.
for users I can keep everything I need in the results table and use with-nth option of fzf to not show the irrelevant data.

Comment on lines +45 to +67
local end_idx = output:find "}{"
-- add a newline after }{ if it exists
if end_idx then
output = output:sub(1, end_idx) .. "\n" .. output:sub(end_idx + 1)
end
local jsons = vim.split(output, "\n", { plain = true })
-- parse each JSON object
for _, json_raw in ipairs(jsons) do
local responses = utils.get_pages(json_raw)
for _, resp in ipairs(responses) do
for _, user in ipairs(resp.data.search.nodes) do
if not user.teams then
-- regular user
if not vim.tbl_contains(vim.tbl_keys(users), user.login) then
users[user.login] = {
id = user.id,
login = user.login,
}
if user.name then
users[user.login].name = user.name
end
end
elseif user.teams and user.teams.totalCount > 0 then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does vim.json.decode not work here for some reason?

Copy link
Author

@mosheavni mosheavni Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does vim.json.decode not work here for some reason?

yes good question!
there's a bug, also on telescope provider BTW, where my org is yielding an error.

the json is not separated, you'll see the response being {......}{......}:

on telescope:

[telescope] [WARN  10:18:18] /Users/mosheavni/.local/share/nvim/lazy/telescope.nvim/lua...to.nvim/lua/octo/utils.lua:790: Expected the end but found T_OBJ_BEGIN at character 6417

on fzf-lua (without my PR):

Error executing vim.schedule lua callback: /Users/mosheavni/Repos/octo.nvim/lua/octo/utils.lua:790: Expected the end but found T_OBJ_BEGIN at character 6297
stack traceback:
        [C]: in function 'decode'
        /Users/mosheavni/Repos/octo.nvim/lua/octo/utils.lua:790: in function 'get_pages'
        ...pos/octo.nvim/lua/octo/pickers/fzf-lua/pickers/users.lua:24: in function '__fn_reload'
        ...vni/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/shell.lua:187: in function 'fn'
        ...vni/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/shell.lua:77: in function <...vni/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/shell.lua:76>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be another function in utils.lua that does this processing. It shouldn't exist only in this function

@mosheavni mosheavni requested a review from williambdean June 23, 2025 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants