Commit Graph

47 Commits

Author SHA1 Message Date
Izhak Jakov 5f49a2e840 Add extension ".bkp" as temp file 2021-08-22 21:11:35 -04:00
Mélanie Chauvel 439b629d90
Merge pull request #933 from billrisher/fix/add_podfile_to_immediate
Added 'Podfile' to list of immediate files
2021-08-20 18:18:06 +02:00
Bill Risher 79cd5d448a Added 'Podfile' to list of immediate files 2021-08-17 21:21:02 -05:00
xxkfqz 8de5b97804 fix: more JPG extensions 2021-07-02 15:02:06 +05:00
Christian Göttsche 61ec153bcd Cleanup clippy warnings
warning: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
 --> src/output/escape.rs:4:1
  |
4 | pub fn escape<'a>(string: String, bits: &mut Vec<ANSIString<'a>>, good: Style, bad: Style) {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |

warning: this lifetime isn't used in the function definition
 --> src/output/escape.rs:4:15
  |
4 | pub fn escape<'a>(string: String, bits: &mut Vec<ANSIString<'_>>, good: Style, bad: Style) {
  |               ^^
  |

warning: single-character string constant used as pattern
   --> src/output/table.rs:310:41
    |
310 |                     if file.starts_with(":") {
    |                                         ^^^ help: try using a `char` instead: `':'`
    |

warning: single-character string constant used as pattern
   --> src/output/table.rs:310:41
    |
310 |                     if file.starts_with(":") {
    |                                         ^^^ help: try using a `char` instead: `':'`
    |

warning: methods called `new` usually return `Self`
  --> src/output/render/git.rs:38:5
   |
38 |     fn new(&self) -> Style;
   |     ^^^^^^^^^^^^^^^^^^^^^^^
   |

warning: this lifetime isn't used in the function definition
  --> src/output/icons.rs:40:22
   |
40 | pub fn iconify_style<'a>(style: Style) -> Style {
   |                      ^^
   |

warning: lint `clippy::find_map` has been removed: this lint has been replaced by `manual_find_map`, a more specific lint
  --> src/main.rs:11:10
   |
11 | #![allow(clippy::find_map)]
   |          ^^^^^^^^^^^^^^^^
   |

warning: redundant else block
   --> src/fs/dir.rs:124:18
    |
124 |               else {
    |  __________________^
125 | |                 return None
126 | |             }
    | |_____________^
    |

warning: redundant else block
  --> src/options/view.rs:60:18
   |
60 |               else {
   |  __________________^
61 | |                 // the --tree case is handled by the DirAction parser later
62 | |                 return Ok(Self::Details(details));
63 | |             }
   | |_____________^
   |

warning: all variants have the same postfix: `Bytes`
   --> src/output/table.rs:170:1
    |
170 | / pub enum SizeFormat {
171 | |
172 | |     /// Format the file size using **decimal** prefixes, such as “kilo”,
173 | |     /// “mega”, or “giga”.
...   |
181 | |     JustBytes,
182 | | }
    | |_^
    |

warning: all variants have the same postfix: `Bytes`
   --> src/output/table.rs:171:1
    |
171 | / pub enum SizeFormat {
172 | |
173 | |     /// Format the file size using **decimal** prefixes, such as “kilo”,
174 | |     /// “mega”, or “giga”.
...   |
182 | |     JustBytes,
183 | | }
    | |_^
    |

warning: useless use of `format!`
   --> src/options/mod.rs:181:50
    |
181 |               return Err(OptionsError::Unsupported(format!(
    |  __________________________________________________^
182 | |                 "Options --git and --git-ignore can't be used because `git` feature was disabled in this build of exa"
183 | |             )));
    | |_____________^ help: consider using `.to_string()`: `"Options --git and --git-ignore can't be used because `git` feature was disabled in this build of exa".to_string()`
    |

warning: stripping a prefix manually
   --> src/fs/filter.rs:287:33
    |
287 |         if n.starts_with('.') { &n[1..] }
    |                                 ^^^^^^^
    |

warning: case-sensitive file extension comparison
  --> src/info/filetype.rs:24:19
   |
24 |         file.name.ends_with(".ninja") ||
   |                   ^^^^^^^^^^^^^^^^^^^
   |
2021-04-30 15:37:31 +02:00
0xflotus 7b15f32da8
feat: add support Typescript and ReasonML projects
Close #771
2020-12-16 00:08:04 +01:00
Benjamin Sago 3419afa7cf Massive theming and view options refactor
This commit significantly refactors the way that options are parsed. It introduces the Theme type which contains both styling and extension configuration, converts the option-parsing process into a being a pure function, and removes some rather gnarly old code.

The main purpose of the refactoring is to fix GH-318, "Tests fail when not connected to a terminal". Even though exa was compiling fine on my machine and on Travis, it was failing for automated build scripts. This was because of what the option-parsing code was trying to accomplish: it wasn't just providing a struct of the user's settings, it was also checking the terminal, providing a View directly.

This has been changed so that the options module now _only_ looks at the command-line arguments and environment variables. Instead of returning a View, it returns the user's _preference_, and it's then up to the 'main' module to examine the terminal width and figure out if the view is doable, downgrading it if necessary.

The code that used to determine the view was horrible and I'm pleased it can be cut out. Also, the terminal width used to be in a lazy_static because it was queried multiple times, and now it's not in one because it's only queried once, which is a good sign for things going in the right direction.

There are also some naming and organisational changes around themes. The blanket terms "Colours" and "Styles" have been yeeted in favour of "Theme", which handles both extensions and UI colours. The FileStyle struct has been replaced with file_name::Options, making it similar to the views in how it has an Options struct and a Render struct.

Finally, eight unit tests have been removed because they turned out to be redundant (testing --colour and --color) after examining the tangled code, and the default theme has been put in its own file in preparation for more themes.
2020-10-22 22:34:00 +01:00
Laurent Arnoud bf883884ed
Add more immediate files 2020-10-18 10:41:44 +02:00
Sudhip Nashi 42b9a5802e
Add extra coloring 2020-10-15 15:38:38 -05:00
Benjamin Sago 3dc86c99ad New set of lints, and Rust 2018 idioms 2020-10-13 01:36:41 +01:00
Benjamin Sago f8df02dae7 Batch source formatting
I read through every file and applied a couple of rustfmt suggestions. The brace placement and alignment of items on similar lines has been made consistent, even if neither are rustfmt's default style (a file has been put in place to enforce this). Other changes are:

• Alphabetical imports and modules
• Comma placement at the end of match blocks
• Use newlines and indentation judiciously
• Spaces around associated types
• Spaces after negations (it makes it more clear imho)
• Comment formatting
• Use early-returns and Optional `?` where appropriate
2020-10-10 20:02:55 +01:00
Benjamin Sago c167046c34
Merge pull request #735 from Finermeerkat137/pull_req
add ko to compiled objects
2020-10-08 22:42:30 +01:00
Benjamin Sago 083cf147be
Merge pull request #709 from poliorcetics/add-apple-filetypes
Add the documents extension for Apple file formats
2020-10-08 22:17:45 +01:00
Sudhip Nashi c17cf95f4c add ko to compiled objects 2020-09-12 21:15:57 -05:00
Alexis Bourget f872027cfe Add the documents extension for Apple file formats 2020-08-02 18:50:32 +02:00
Alain Schlesser 2ccc8fa093
Add immediate file types for PHP ecosystem
Added the following imemdiate file types for PHP:
- `composer.json` for [Composer](https://getcomposer.org/), the defactor standard package manager for PHP;
- `RoboFile.php`, for [Robo](https://robo.li/), the PHP task runner.

Note: [Phing]() uses `build.xml`, which was already included in the list.
2020-06-21 11:52:33 +02:00
Eric Nielsen 501fbf7182 Add pom.xml and zwc filetypes
pom.xml (Maven) is popularly used for Java projects, along with the
already existing build.xml (Ant) and build.gradle (Gradle) immediate
files.

zwc stands for Zsh Word Code and contains compiled Z Shell scripts or
functions.
2020-01-19 09:08:07 -05:00
Benjamin Sago d13cce7d94
Merge pull request #593 from ariasuni/add-new-filetypes
Add a few frequent filetypes
2020-01-19 00:53:34 +00:00
ariasuni efbd46351c Add a few frequent filetypes 2019-10-03 22:45:21 +02:00
Bond_009 f599c7ce93 Update to Rust 2018 2019-07-19 20:40:21 +02:00
Michael Hackner e3fc2de088 Add BUILD.bazel as another Bazel file type
This seems to be preferred now, though both are valid.
2019-07-17 01:05:33 -07:00
Benjamin Sago 9497b30b33 Merge branch 'glyphs' of https://github.com/asoderman/exa into asoderman-glyphs
# Conflicts:
#	src/options/flags.rs
#	src/options/view.rs
#	src/output/grid.rs
2019-07-15 03:54:31 +01:00
Ben Mezger (seds) 99167429ed
Feat: add JPF to image filetype 2019-04-03 15:10:03 -03:00
Benjamin Sago 57e4c08411 Highlight README~ as temp, not immediate
Fixes #313.
2018-10-14 16:21:13 +01:00
Lucas Rooyakkers 9b446c03e8 Add support for Apple's M4V format 2018-10-02 01:47:51 -04:00
Alex Soderman c448b3747f added icons for video/audio/images
remove unnecessary clone
2018-03-27 13:18:49 -04:00
Benjamin Sago b16a78942c
Merge pull request #366 from dguo/ts-extension
Don't treat .ts as a video file extension
2018-03-15 20:42:26 +00:00
Benjamin Sago 3614f5513d
Merge pull request #356 from joshleeb/highlight-lowercase-readme
Case Insensitive README.* Files As immediate
2018-03-15 20:41:44 +00:00
Danny Guo e711dbc0b6
Don't treat .ts as a video file extension
It's arguably more frequently used for TypeScript files.
2018-03-14 20:34:46 -04:00
Benjamin Sago 9bd0334d1a
Merge pull request #342 from ogham/exa/patch-1
Add Bazel and ANT files to immediate files types
2018-03-11 09:41:09 +00:00
Josh Leeb-du Toit d9c9dbe89e Case insensitive README.* files are immediate
Files with the prefix `README` are now classified as immediate, meaning
they will be highlighted amongst other things, in a case insensitive
way.
2018-02-15 21:55:52 +11:00
Marco Farrugia c635031661
Add Bazel and ANT files to immediate files types 2018-01-28 19:26:37 -05:00
ne-sted 5fae489717 Update filetype.rs
add `zst` extension
2017-11-20 13:50:08 +02:00
Clar Charr eda3e56e4c Add .bk extension to is_temp. 2017-09-17 23:08:25 -04:00
Benjamin Sago bfb8a5a573 Extract trait above file name colours
This commit meddles about with both the Colours and the FileExtensions.

Even though all the renderable fields were turned into traits, the FileName struct kept on accessing fields directly on the Colours value instead of calling methods on it. It also did the usual amount of colour misappropriation (such as ‘punctuation’ instead of specifying ‘normal_arrow’)

In preparation for when custom file colours are configurable (any day now), the colourise-file-by-kind functionality (links, sockets, or directories) was separated from the colourise-file-by-name functionality (images, videos, archives). The FileStyle struct already allowed for both to be separate; it was only changed so that a type other than FileExtensions could be used instead, as long as it implements the FileColours trait. (I feel like I should re-visit the naming of all these at some point in the future)

The decision to separate the two means that FileExtensions is the one assigning the colours, rather than going through the fields on a Colours value, which have all been removed. This is why a bunch of arbitrary Styles now exist in filetype.rs.

Because the decision on which colourise-file-by-name code to use (currently just the standard extensions, or nothing if we aren’t colourising) is now determined by the Colours type (instead of being derived), it’s possible to get it wrong. And wrong it was! There was a bug where file names were colourised even though the rest of the --long output wasn’t, and this wasn’t caught by the xtests. It is now.
2017-08-26 20:43:47 +01:00
Christopher Vittal 1bce51c9c8 Add extra types to compressed filetype filter.
This adds a few more common compressed filetypes to the is_compressed
fuction. Notably, xz, and two common package file formats, deb and rpm.
2017-08-07 00:57:29 -04:00
Nontawat Numor e43e288d19 Add raw file type for Olympus and Nikon 2017-08-06 17:47:15 +07:00
pskuza d76ce048c3 Update filetype.rs
Added a few video and audio extensions
2017-08-04 16:03:16 +02:00
Benjamin Sago c29170e345 Get the list of file extensions from the Options
The FileExtensions in the FileName is now a reference to the one in the original FileStyle, which gets put there in the options module.

This allows the extensions to be derived from the user, somehow, in the future when that part’s done.
2017-07-10 14:01:38 +01:00
Benjamin Sago 0d8d723408 Reify file extensions
Instead of having a File do its own extension checking, create a new type that takes a file and checks *that*. This new type (FileExtensions) is currently empty, but were it to contain values, those values could be used to determine the file’s colour.
2017-07-10 13:31:20 +01:00
Benjamin Sago 31148eda7b Match up fields with parameter names
The arguments passed to File’s constructor were different from the field names used — these might as well both be the same.

Also, move ext and filename to be File methods to save an import, and add tests.

Also also, by passing a PathBuf in to the constructor directly, we can save one (possibly two) instance/s where we pass in a reference to something we were going to lose ownership of anyway, only to have it basically cloned.
2017-06-29 13:07:45 +01:00
Raphaël Pinson 8ac68f9964
Add cr2 as image 2017-04-19 00:08:29 +02:00
Daniel Lockyer 91459d608c Replace double-quote with single-quote 2017-03-31 17:10:18 +01:00
Ben S 36d9b6844e Add .tgz to the compressed file extensions
Fixes #129
2016-10-29 19:28:41 +01:00
Ben S 331d5ea724 Rename underscored lifetimes
See https://github.com/rust-lang/rfcs/pull/1177
2016-06-11 13:35:40 +01:00
Benjamin Sago 45c93b1b63 Correct the list of crypto extensions
They were the same as the archive/compressed extensions, and I never noticed!
2016-04-16 22:17:12 +01:00
Benjamin Sago fae0f3874e Create info module with business logic routines
Currently these routines number two: file type checking based on a file's name, and source file checking, also based on the file's name.
2016-04-16 22:05:50 +01:00