Commit Graph

51 Commits

Author SHA1 Message Date
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
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
Benjamin Sago
205f18e848 It looks like you’re writing a letter 2017-05-07 17:39:01 +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