Commit Graph

62 Commits

Author SHA1 Message Date
Victor Song cd715a6e00 Safely derive `Eq` whenever we derive `PartialEq` 2023-02-24 18:29:37 -05:00
Mélanie Chauvel fc6a6d0b38
Merge pull request #1045 from sorairolake/format/cpio
Add cpio filetype
2022-03-22 15:17:15 +01:00
Shun Sakai bced9841f4 Add JPEG 2000 filetype 2022-03-20 12:36:54 +09:00
Shun Sakai f5bbfa7871 Add cpio filetype 2022-03-18 16:51:06 +09:00
jim4067 4220b6f41e add lz4 file type and icon 2021-10-03 13:16:47 +03:00
hellosway 659def7138
Recognize .jxl and .avif as image files 2021-09-22 17:07:06 -07:00
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
Mélanie Chauvel 13b91cced4
Merge pull request #772 from 0xflotus/patch-2 2021-01-14 14:29:34 +01:00
0xflotus d11ac5d49b
Recognize SCSS and Stylus as source for CSS files (#770) 2021-01-14 13:54:45 +01: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 f0c139ca68 Better referencing
This commit makes changes to the way variables are referenced:

• Make types Copy when possible
• Make methods take `self` instead of `&self` where possible (trivially_copy_pass_by_ref)
• Remove unnecessary borrowing (needless_ref)
• Remove unnecessary cloning (clone_on_copy)
• Remove `ref` from match arms where possible (new Rust match ergonomics)
2020-10-10 15:30:19 +01:00
Benjamin Sago dee447213c
Merge pull request #743 from jonhoo/patch-1
Add additional TeX compiled files
2020-10-08 22:43:24 +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
Jon Gjengset c0f01310c4
Add bcf biblatex control file 2020-10-03 20:25:24 -04:00
Jon Gjengset f37aeebef0
Add additional TeX compiled files
Specifically .fls and .fdb_latexmk, which the popular `latexmk` tool produces.
2020-10-03 19:46:06 -04: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
Benjamin Sago 8a711358ee
Merge pull request #579 from ericbn/unused-code
Remove unused code in File#get_source_files
2020-01-19 00:42:44 +00:00
ariasuni efbd46351c Add a few frequent filetypes 2019-10-03 22:45:21 +02:00
Eric Nielsen cb933a6f62 Remove unused code in File#get_source_files
as the "class", "elc", "hi", "o", "pyc" extensions are first tested in
FileExtensions#is_compiled, so removed code is redundant and neved
called.
2019-09-10 09:51:08 -05: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