-
Notifications
You must be signed in to change notification settings - Fork 189
feat(fzf): respect users
option
#1106
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
base: master
Are you sure you want to change the base?
Conversation
@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 = {} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
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
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:
octo.nvim/lua/octo/gh/mutations.lua
Line 911 in a8dbac0
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