diff --git a/filemanager-plugin/README.md b/filemanager-plugin/README.md index 79d983d..44adc9d 100644 --- a/filemanager-plugin/README.md +++ b/filemanager-plugin/README.md @@ -20,11 +20,11 @@ If the directory is expanded, there will be a `+` to the left of it. If it is co | Option | Purpose | Default | | :--------------------------- | :----------------------------------------------------------- | :------ | -| `filemanager-showdotfiles` | Show dotfiles (hidden if false) | `true` | -| `filemanager-showignored` | Show gitignore'd files (hidden if false) | `true` | -| `filemanager-compressparent` | Collapse the parent dir when left is pressed on a child file | `true` | -| `filemanager-foldersfirst` | Sorts folders above any files | `true` | -| `filemanager-openonstart` | Automatically open the file tree when starting Micro | `false` | +| `filemanager.showdotfiles` | Show dotfiles (hidden if false) | `true` | +| `filemanager.showignored` | Show gitignore'd files (hidden if false) | `true` | +| `filemanager.compressparent` | Collapse the parent dir when left is pressed on a child file | `true` | +| `filemanager.foldersfirst` | Sorts folders above any files | `true` | +| `filemanager.openonstart` | Automatically open the file tree when starting Micro | `false` | ### Commands and Keybindings diff --git a/filemanager-plugin/filemanager.lua b/filemanager-plugin/filemanager.lua index fef17d4..727b16b 100644 --- a/filemanager-plugin/filemanager.lua +++ b/filemanager-plugin/filemanager.lua @@ -74,7 +74,7 @@ end local function get_ignored_files(tar_dir) -- True/false if the target dir returns a non-fatal error when checked with 'git status' local function has_git() - local git_rp_results = shell.ExecCommand('git -C "' .. tar_dir .. '" rev-parse --is-inside-work-tree') + local git_rp_results = shell.ExecCommand('git', '-C', tar_dir, 'rev-parse', '--is-inside-work-tree') return git_rp_results:match("^true%s*$") end local readout_results = {} @@ -82,7 +82,7 @@ local function get_ignored_files(tar_dir) if has_git() then -- If the dir is a git dir, get all ignored in the dir local git_ls_results = - shell.ExecCommand('git -C "' .. tar_dir .. '" ls-files . --ignored --exclude-standard --others --directory') + shell.ExecCommand('git', '-C', tar_dir, 'ls-files', '.', '--ignored', '--exclude-standard', '--others', '--directory') -- Cut off the newline that is at the end of each result for split_results in string.gmatch(git_ls_results, "([^\r\n]+)") do -- git ls-files adds a trailing slash if it's a dir, so we remove it (if it is one) @@ -335,7 +335,7 @@ end local function compress_target(y, delete_y) -- Can't compress the top stuff, or if there's nothing there, so exit early if y == 0 or scanlist_is_empty() then - return + return false end -- Check if the target is a dir, since files don't have anything to compress -- Also make sure it's actually an uncompressed dir by checking the gutter message @@ -401,7 +401,7 @@ local function compress_target(y, delete_y) elseif config.GetGlobalOption("filemanager.compressparent") and not delete_y then goto_parent_dir() -- Prevent a pointless refresh of the view - return + return true end -- Put outside check above because we call this to delete targets as well @@ -433,6 +433,8 @@ local function compress_target(y, delete_y) end refresh_and_select() + + return true end -- Prompts the user for deletion of a file/dir when triggered @@ -516,6 +518,7 @@ local function try_open_at_y(y) -- 2 is the zero-based index of ".." if y == 2 then go_back_dir() + return true elseif y > 2 and not scanlist_is_empty() then -- -2 to conform to our scanlist "missing" first 3 indicies y = y - 2 @@ -530,8 +533,10 @@ local function try_open_at_y(y) -- Resizes all views after opening a file -- tabs[curTab + 1]:Resize() end + return true else micro.InfoBar():Error("Can't open that") + return false end end @@ -539,7 +544,7 @@ end local function uncompress_target(y) -- Exit early if on the top 3 non-list items if y == 0 or scanlist_is_empty() then - return + return false end -- Only uncompress if it's a dir and it's not already uncompressed if scanlist[y].dirmsg == "+" then @@ -591,6 +596,10 @@ local function uncompress_target(y) end refresh_and_select() + + return true + else + return false end end @@ -841,6 +850,8 @@ local function open_tree() tree_view.Buf:SetOptionNative("softwrap", true) -- No line numbering tree_view.Buf:SetOptionNative("ruler", false) + -- No diff gutter + tree_view.Buf:SetOptionNative("diffgutter", false) -- Is this needed with new non-savable settings from being "vtLog"? tree_view.Buf:SetOptionNative("autosave", false) -- Don't show the statusline to differentiate the view from normal views @@ -877,14 +888,18 @@ end function uncompress_at_cursor() if micro.CurPane() == tree_view then - uncompress_target(get_safe_y()) + return uncompress_target(get_safe_y()) + else + return false end end function compress_at_cursor() if micro.CurPane() == tree_view then -- False to not delete y - compress_target(get_safe_y(), false) + return compress_target(get_safe_y(), false) + else + return false end end @@ -892,7 +907,7 @@ end -- Not local so it can be bound function goto_prev_dir() if micro.CurPane() ~= tree_view or scanlist_is_empty() then - return + return false end local cur_y = get_safe_y() @@ -906,17 +921,18 @@ function goto_prev_dir() -- Jump to its parent (the ownership) tree_view.Cursor:UpN(move_count) select_line() - break + return true end end end + return false end -- Goes down 1 visible directory (if any) -- Not local so it can be bound function goto_next_dir() if micro.CurPane() ~= tree_view or scanlist_is_empty() then - return + return false end local cur_y = get_safe_y() @@ -935,17 +951,18 @@ function goto_next_dir() -- Jump to its parent (the ownership) tree_view.Cursor:DownN(move_count) select_line() - break + return true end end end + return false end -- Goes to the parent directory (if any) -- Not local so it can be keybound function goto_parent_dir() if micro.CurPane() ~= tree_view or scanlist_is_empty() then - return + return false end local cur_y = get_safe_y() @@ -954,15 +971,18 @@ function goto_parent_dir() -- Jump to its parent (the ownership) tree_view.Cursor:UpN(cur_y - scanlist[cur_y].owner) select_line() + return true + else + return false end end function try_open_at_cursor() if micro.CurPane() ~= tree_view or scanlist_is_empty() then - return + return false end - try_open_at_y(tree_view.Cursor.Loc.Y) + return try_open_at_y(tree_view.Cursor.Loc.Y) end -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~