Commit Graph

16900 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
96deaae7d8 completions/apt: Read from the dpkg cache directly
I have no idea why `apt-cache --no-generate show` is so slow since it basically
dumps the contents of the cache file located at `/var/lib/dpkg/status`. We are
technically bypassing any waits on the cache lock file so this may produce
incorrect results if the cache is being regenerated in the moment, but that's a
small price to pay and the results are likely confined to simply not generating
comprehensive results.

With this change, we no longer need to truncate results to the first n matches
and we no longer only print packages beginning with the commandline argument
enabling fish's partial completions logic to offer less-perfect suggestions when
no better options are available.

Even though we are generating more usable completions, we still trounce the old
performance by leaps and bounds:

```
Benchmark #1: fish -c "complete -C\"apt install ac\""
  Time (mean ± σ):      2.165 s ±  0.033 s    [User: 267.0 ms, System: 1932.2 ms]
  Range (min … max):    2.136 s …  2.256 s    10 runs

Benchmark #2: build/fish -c "complete -C\"apt install ac\""
  Time (mean ± σ):     111.1 ms ±   1.8 ms    [User: 38.9 ms, System: 72.9 ms]
  Range (min … max):   108.2 ms … 114.9 ms    26 runs

Summary
  'build/fish -c "complete -C\"apt install ac\""' ran
   19.49 ± 0.44 times faster than 'fish -c "complete -C\"apt install ac\""'
```
2023-02-05 16:30:34 -06:00
Mahmoud Al-Qudsi
6f3711902b completions/apt: Use is_first_token instead of seen_subcommand_from
I think this should be preferred for all subcommand completions because it
handles typos or subcommands we don't recognize better (`apt foo <TAB>` no
longer suggests subcommands since the subcommand position has been taken).
2023-02-05 16:15:15 -06:00
Johannes Altmanninger
39c3faeaf4 gettext.rs: make trailing comma actually optional 2023-02-05 12:24:29 +01:00
Johannes Altmanninger
f167ec9063 clippy: silence manual_is_ascii_check
It's debatable whether is_ascii_digit() is better than (0..=9).contains().
(Probably we want to go with the mainstream Rust choice eventually.)
Let's disable the warning for now since it's not terribly important.
2023-02-05 12:24:29 +01:00
Johannes Altmanninger
c8bf2be408 wchar_ffi.rs: implement from_ffi() for more FFI strings 2023-02-05 12:22:42 +01:00
Johannes Altmanninger
dcca3cfe3c Prefer taking native Rust strings instead of wcharz_t
We should only be dealing with wcharz_t at the language boundary.
Rust callers should prefer the equivalent &wstr.
Since wcsfilecmp() is no longer exposed directly it can take &wstr only.
2023-02-05 12:22:42 +01:00
NextAlone
3604e8854b completion/adb: remove wait-for-device from subcommand detect
wait-for-device should not be used in subcommand detect, cause it is used as seperate command, following with others.
2023-02-05 12:13:45 +01:00
Branch Vincent
d69a290c2f completions: add pre-commit 2023-02-05 12:12:47 +01:00
Wout De Puysseleir
43a7c20ddb completions/mix: Add mix phx
- Added phx completions. These are very common completions for the Elixir Phoenix Framework.
  Documentation can be found here: https://hexdocs.pm/phoenix/1.7.0-rc.2/Mix.Tasks.Local.Phx.html#content
- Added argument completions
- Made all descriptions start with an uppercase for better consistency
- Update CHANGELOG.rst
2023-02-05 12:10:31 +01:00
Johannes Altmanninger
a446a16471 flog.rs: use qualified name in FLOG! macro
Otherwise this macro fails when used in a context that doesn't import
this name.
2023-02-05 12:02:48 +01:00
Johannes Altmanninger
7347c90d1e builtins.rs: correct error message on unknown option 2023-02-05 12:02:48 +01:00
Johannes Altmanninger
476b12e06a util.rs: simplify wcsfilecmp a bit further 2023-02-05 12:02:48 +01:00
Johannes Altmanninger
ba1c5d495f util.rs: fix Yoda condition 2023-02-05 12:02:48 +01:00
Xiretza
8460b37b6a rust: util: use Ordering instead of integers 2023-02-05 11:57:25 +01:00
Xiretza
8b483735b4 rust: fix doc comments 2023-02-05 11:57:25 +01:00
Xiretza
cee13531e3 rust: silence warnings on auto-generated FFI bindings 2023-02-05 11:57:25 +01:00
Xiretza
cba03fc1e8 rust: remove unnecessary newline 2023-02-05 11:57:25 +01:00
Xiretza
35083c72ef rust: silence some clippy warnings 2023-02-05 11:57:25 +01:00
Xiretza
853649f8dc rust: fix issues reported by clippy 2023-02-05 11:57:25 +01:00
ridiculousfish
c2df63f586 Remove an errant printf from fish_tests 2023-02-04 11:24:54 -07:00
Johannes Altmanninger
83fd7ea7c4 Port future_feature_flags.cpp to Rust
This is early work but I guess there's no harm in pushing it?
Some thoughts on the conventions:

Types that live only inside Rust follow Rust naming convention
("FeatureMetadata").

Types that live on both sides of the language boundary follow the existing
naming ("feature_flag_t").
The alternative is to define a type alias ("using feature_flag_t =
rust::FeatureFlag") but that doesn't seem to be supported in "[cxx::bridge]"
blocks. We could put it in a header ("future_feature_flags.h").

"feature_metadata_t" is a variant of "FeatureMetadata" that can cross
the language boundary. This has the advantage that we can avoid tainting
"FeatureMetadata" with "CxxString" and such. This is an experimental approach,
probably not what we should do in general.
2023-02-03 18:55:06 +01:00
Johannes Altmanninger
132d99a27b Call rust_init() in fish_indent too
The initial port of feature flags requires a global initialization. Since
fish_indent accesses feature flags, let's make sure to initialize them here.
In future, we can stop initializing things fish_indent doesn't need (like
the topic monitor) but that's no big deal. Global initialization should
always be a benign addition.
2023-02-03 18:55:06 +01:00
Johannes Altmanninger
517d53dc46 Port util.cpp to Rust
The original implementation without the test took me 3 hours (first time
seriously looking into this)

The functions take "wcharz_t" for smooth integration with existing C++ callers.
This is at the expense of Rust callers, which would prefer "&wstr".  Would be
nice to declare a function parameter that accepts both but I don't think
that really works since "wcharz_t" drops the lifetime annotation.
2023-02-03 18:55:06 +01:00
Johannes Altmanninger
44d75409d0 build.rs: re-run autocxx if any ffi module changed
I'm not 100% sure this is the right thing but it seems to fix a scenario
where a change to a Rust module was not propagated by "make".
2023-02-03 18:55:06 +01:00
Johannes Altmanninger
a502cb16c3 ffi.rs: prevent rustfmt from breaking "use" statements
rustfmt removes the "::" prefix from qualifiers. This breaks the build because
I think a later "pub use ffi::*" results in "std" being an ambiguous reference.
2023-02-03 18:55:05 +01:00
Mahmoud Al-Qudsi
91be7489bc CI: Disable some Cirrus CI jobs during RIIR transition
We can re-enable these once we're nearing a RIIR release (or if someone thinks
it's a good use of their time to fix them before then). Otherwise we're just
going to have GitHub reporting CI failure for all commits instead of just the
ones that actually broke something.

(I'm mainly trying to get the branch in a good state to merge into master.)
2023-02-03 11:52:01 -06:00
Mahmoud Al-Qudsi
2dc2c8de3b Fix FreeBSD CI builds of rust-enabled codebase
Use rustup to install the latest version of rust. The latest version of rust
available from pkg is 1.66.0 while the code currently needs 1.67.0 or later.
2023-02-03 11:36:21 -06:00
Mahmoud Al-Qudsi
60bd186e21 Fix linking errors under FreeBSD
The nix crate had all its default features enabled, which included features that
are not present under BSD. We should only enable the select subset of crate
features that we know are available cross-platform (or else use conditional
targeting in Cargo.toml to only enable Linux-only features when compiling for
Linux targets).

For now, it seems we can just use the nix crate with all features disabled as it
still builds under Linux and FreeBSD in this state.
2023-02-03 11:36:21 -06:00
Mahmoud Al-Qudsi
c18fb74fa8 Fix rust-invoked build of c/cpp sources under FreeBSD
Due to an upstream issue with cc-rs [0], the rust-generated C++ interface would
fail to compile. A PR has been opened to patch the issue upstream [1], but in
the meantime `Cargo.toml` has been patched to use a fork of cc-rs with the
relevant fixes.

[0]: https://github.com/rust-lang/cc-rs/issues/463
[1]: https://github.com/rust-lang/cc-rs/pull/785
2023-02-03 11:36:21 -06:00
Mahmoud Al-Qudsi
538518cdf3 CI: Use the cmake-core package on FreeBSD
The `cmake` meta package pulls in `cmake-core`, `cmake-docs`, and `cmake-man` -
we don't need the latter two.

(It seems to be available on all the versions/architectures we target.)
2023-02-02 20:41:57 -06:00
Mahmoud Al-Qudsi
608f2bab31 CI: Use git-lite instead of git under FreeBSD
The git-lite flavor, being significantly smaller and downloading/installing much
faster with fewer dependencies, is much better suited for CI environments (at
the cost of not supporting interactive git commands).
2023-02-02 20:41:57 -06:00
Mahmoud Al-Qudsi
440dcb48c5 CI: Upgrade FreeBSD 13 to 13.1
By default /etc/pkg/FreeBSD.conf uses either the /quarterly or /latest pkg
builds, which are built against the latest minor release of FreeBSD for the
given ${ABI} string at the time they were last updated.

The nature of the shared binary packages means everyone (across all minor
versions of the same major version on the same architecture, all of which share
the same stable ABI) gets the same binary build.

There are however packages which depend on symbols exported by system-provided
libraries (rather than by other packages, which are always going to be in sync)
that *aren't* stable across minor releases, leaving packages like llvm
broken if you install the latest llvm from pkg's binary repos built against,
say, FreeBSD 13.1 while running FreeBSD 13.0.

The other option is to use the "snapshots" of the binary packages available upon
the release of each minor version, by using /release_0, /release_1, etc instead
of /quarterly or /latest, but then you're limited to the ports that were
available at that specific date and those old versions.

tl;dr just make sure we're always using the latest minor release for each major
version of FreeBSD we intend to support.
2023-02-02 20:41:57 -06:00
ridiculousfish
76adfed0e7 Implement builtin_wait in Rust
This implements builtin_wait in Rust.
2023-02-02 19:34:48 -07:00
ridiculousfish
f38543ccb7 Rename ast::job_t to ast::job_pipeline_t
This works around an autocxx limitations where different types cannot
have the same name even if they live in different namespace.

ast::job_t conflicts with job_t.
2023-02-02 19:34:48 -07:00
ridiculousfish
e674678ea4 Add a printf implementation
This allows using existing format strings.
The implementation is adapted from https://github.com/tjol/sprintf-rs
2023-02-02 19:34:48 -07:00
ridiculousfish
55f655f003 Add a gettext wrapper in Rust
This allows the wgettext! macro, which calls into C++.
2023-02-02 19:34:48 -07:00
ridiculousfish
681a165721 Add an FFI test facility
This allow testing Rust functions (from fish_tests.cpp) which need to
cross the FFI. See the example in smoke.rs.
2023-02-02 19:34:48 -07:00
ridiculousfish
096b254c4a Port fish_wcstoi to Rust
This adds an implementation of fish_wcstoi in Rust, mirroring the one in
fish. As Rust does not have a string to number which infers the radix
(i.e. looks for leading 0x or 0), we add that manually.
2023-02-02 19:34:48 -07:00
ridiculousfish
d843b67d2d Initial Rust commit 2023-02-02 19:34:47 -07:00
David Adam
fb3056d7a1 fish.spec: drop long-obsolete BuildRoot directive
Ignored since RPM 4.6.0, released in 2009!
2023-02-01 22:26:30 +08:00
LingMan
0af2a7a9b7 Upgrade GitHub action dessant/lock-threads to v4
In v3 several input parameters where renamed and since v4 it requires Node.js 16.

This resolves warnings about Node.js 12 and `set-output` being deprecated and
slated for removal in the `Lock threads` workflow.
2023-02-01 10:40:46 +08:00
Mahmoud Al-Qudsi
31f63b2f87 Upgrade GitHub CI actions/checkout to v3
This addresses the node v12 deprecation warning in the GitHub CI, caused by the
dependency on actions/checkout@v2.

While actions/checkout@v3 introduces some new features and changes some
defaults, the subset of features that we use should not be affected by this
migration.

The "breaking change" from v2 to v3 can be seen at [0]. Since we are tracking
only v2 without a dot release specified, we are already opting into any breakage
across minor versions, so really the only change of note is the node version
upgrade.

[0]: https://github.com/actions/checkout/compare/v2.4.2...v3.0.0
2023-01-31 11:50:57 -06:00
nat-418
cf67709931
feat: add support for fossil-scm in prompt (#9500)
* feat: add support for fossil-scm in prompt

* fix: change directory testing and string matching
2023-01-29 16:54:39 +01:00
Fabian Boehm
d239e26f6b docs: Add a missing newline
Sphinx is annoyingly specific here
2023-01-29 14:46:35 +01:00
Fabian Boehm
177ce0d40e __fish_make_completion_signals: Check for "kill" 2023-01-29 14:44:59 +01:00
Fabian Boehm
dd7d432cd6 Only define kill wrapper if we have a kill to wrap 2023-01-29 14:44:45 +01:00
David Adam
2a24295e50 debian packaging: add dependency on procps
See https://bugs.debian.org/1029940
2023-01-29 21:21:47 +08:00
Johannes Altmanninger
243ade838b completions/git: also complete filepaths as second argument to git grep
Fixes a regression in f81e8c7de (completions/git: complete refs for "git
grep", 2022-12-08).

Fixes #9513
2023-01-28 21:25:42 +01:00
Fabian Boehm
7f2cb47437 fish_key_reader: Don't translate things to "\v" and friends
This translated ctrl-k to "\v", which is a "vertical tab", and ctrl-l
to "\f" and ctrl-g to "\a".

There is no "vertical tab" or "alarm" or "\f" *key*, so these
shouldn't be translated. Just drop these and call them `\ck` and such.

(vertical tab specifically is utterly useless and I would be okay with
dropping it entirely, I have never seen it used anywhere)
2023-01-27 17:07:18 +01:00
Johannes Altmanninger
befa240756 completions/git: use builtin path for finding subcommands
This is more elegant and efficient. No functional change.

As suggested by 2da1a4ae7 (completions/git: Fix git-foo commands, 2023-01-09).
2023-01-24 20:37:38 +01:00