-
-
Notifications
You must be signed in to change notification settings - Fork 610
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
Improve git icons on directories #1809
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5736db5
coding style
chomosuke cd1df4f
outlined git.show_on_open_dirs behavior
chomosuke f65dc0d
show some icon on opendir even if show_on_open_dir=false
chomosuke 5c6acd5
fixed renamed icon not showing
chomosuke 75cd0d1
sorted icons
chomosuke ac8fb08
removed DU from deleted as file will show up in tree
chomosuke a342de0
fixed update_git_status in reloaders not tested
chomosuke 3af4d14
fixed Api.git.reload()
chomosuke 10fc0eb
sort icon only if not git signcolumn
chomosuke 627dde9
fixed crashing when root dir isn't git dir
chomosuke bdc2c70
made git.show_on_dirs doc more concise
chomosuke 23d4113
git_statuses -> git_status for consistency
chomosuke a61763f
explorer/common.lua -> explorer/node.lua
chomosuke c4b93db
fixed #1784 conflict
chomosuke 23f6276
don't order icons
chomosuke d5faa8f
Revert "don't order icons"
chomosuke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
local M = {} | ||
|
||
-- node.git_status structure: | ||
-- { | ||
-- file = string | nil, | ||
-- dir = { | ||
-- direct = { string } | nil, | ||
-- indirect = { string } | nil, | ||
-- } | nil, | ||
-- } | ||
|
||
local function get_dir_git_status(parent_ignored, status, absolute_path) | ||
if parent_ignored then | ||
return { file = "!!" } | ||
end | ||
|
||
return { | ||
file = status.files and status.files[absolute_path], | ||
dir = status.dirs and { | ||
direct = status.dirs.direct[absolute_path], | ||
indirect = status.dirs.indirect[absolute_path], | ||
}, | ||
} | ||
end | ||
|
||
local function get_git_status(parent_ignored, status, absolute_path) | ||
local file_status = parent_ignored and "!!" or status.files and status.files[absolute_path] | ||
return { file = file_status } | ||
end | ||
|
||
function M.has_one_child_folder(node) | ||
return #node.nodes == 1 and node.nodes[1].nodes and vim.loop.fs_access(node.nodes[1].absolute_path, "R") | ||
end | ||
|
||
function M.update_git_status(node, parent_ignored, status) | ||
local get_status | ||
if node.nodes then | ||
get_status = get_dir_git_status | ||
else | ||
get_status = get_git_status | ||
end | ||
|
||
-- status of the node's absolute path | ||
node.git_status = get_status(parent_ignored, status, node.absolute_path) | ||
|
||
-- status of the link target, if the link itself is not dirty | ||
if node.link_to and not node.git_status then | ||
node.git_status = get_status(parent_ignored, status, node.link_to) | ||
end | ||
end | ||
|
||
function M.get_git_status(node) | ||
local git_status = node.git_status | ||
if not git_status then | ||
-- status doesn't exist | ||
return nil | ||
end | ||
|
||
if not node.nodes then | ||
-- file | ||
return git_status.file and { git_status.file } | ||
end | ||
|
||
-- dir | ||
if not M.config.git.show_on_dirs then | ||
return nil | ||
end | ||
|
||
local status = {} | ||
if not node.open or M.config.git.show_on_open_dirs then | ||
-- dir is closed or we should show on open_dirs | ||
if git_status.file ~= nil then | ||
table.insert(status, git_status.file) | ||
end | ||
if git_status.dir ~= nil then | ||
if git_status.dir.direct ~= nil then | ||
for _, s in pairs(node.git_status.dir.direct) do | ||
table.insert(status, s) | ||
end | ||
end | ||
if git_status.dir.indirect ~= nil then | ||
for _, s in pairs(node.git_status.dir.indirect) do | ||
table.insert(status, s) | ||
end | ||
end | ||
end | ||
else | ||
-- dir is open and we shouldn't show on open_dirs | ||
if git_status.file ~= nil then | ||
table.insert(status, git_status.file) | ||
end | ||
if git_status.dir ~= nil and git_status.dir.direct ~= nil then | ||
local deleted = { | ||
[" D"] = true, | ||
["D "] = true, | ||
["RD"] = true, | ||
["DD"] = true, | ||
} | ||
for _, s in pairs(node.git_status.dir.direct) do | ||
if deleted[s] then | ||
table.insert(status, s) | ||
end | ||
end | ||
end | ||
end | ||
if #status == 0 then | ||
return nil | ||
else | ||
return status | ||
end | ||
end | ||
|
||
function M.is_git_ignored(node) | ||
return node.git_status and node.git_status.file == "!!" | ||
end | ||
|
||
function M.node_destroy(node) | ||
if not node then | ||
return | ||
end | ||
|
||
if node.watcher then | ||
node.watcher:destroy() | ||
end | ||
end | ||
|
||
function M.setup(opts) | ||
M.config = { | ||
git = opts.git, | ||
} | ||
end | ||
|
||
return M |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
good catch