Commit Graph

16874 Commits

Author SHA1 Message Date
Fabian Boehm
7b8684e469 completions/netcat: Use path 2023-02-10 20:50:14 +01:00
Fabian Boehm
cac483c67a completions: Quote some tests 2023-02-10 20:47:49 +01:00
Fabian Boehm
6fe4b0c24d completions/kb: Fix 2023-02-10 20:46:34 +01:00
NextAlone
c587b2ffcc completions/fastboot: fix flash completion
Signed-off-by: NextAlone <12210746+NextAlone@users.noreply.github.com>
2023-02-09 20:44:12 -08:00
Johannes Altmanninger
a8c992236e Document some porting bits 2023-02-09 00:39:01 +01:00
Johannes Altmanninger
39f3c894d7 Port tokenizer.cpp to Rust
In hindsight, I should probably have split this into three different commits.
2023-02-09 00:37:22 +01:00
Johannes Altmanninger
7f8d247211 Port parse_constants.h to Rust 2023-02-09 00:37:22 +01:00
Johannes Altmanninger
25816627de Port redirection.cpp to Rust 2023-02-09 00:37:22 +01:00
Johannes Altmanninger
9ca160eac2 Convert parse_error_code_t to a scoped enum
This will make the Rust port's diff smaller.
2023-02-08 21:49:54 +01:00
Johannes Altmanninger
8fd1db06ed Remove unused parse error code 2023-02-08 21:49:54 +01:00
Johannes Altmanninger
4639f7ec40 Follow Rust naming convention for some types
But don't do it for enum variants just yet.
2023-02-08 21:49:54 +01:00
Johannes Altmanninger
958ad3a9e7 ffi.rs: silence warning about get_procs()
We should fix this warning eventually.  Silence it for now to make Clippy
pass without warnings, which makes it much more useful.

       Compiling fish-rust v0.1.0 (/home/johannes/git/fish-riir/fish-rust)
    error: mutable borrow from immutable input(s)
      --> src/ffi.rs:79:32
       |
    79 |     pub fn get_procs(&self) -> &mut [UniquePtr<process_t>] {
       |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
    note: immutable borrow here
      --> src/ffi.rs:79:22
       |
    79 |     pub fn get_procs(&self) -> &mut [UniquePtr<process_t>] {
       |                      ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mut_from_ref
       = note: `#[deny(clippy::mut_from_ref)]` on by default

    error: could not compile `fish-rust` due to previous error
2023-02-08 21:49:41 +01:00
Johannes Altmanninger
29a2c4b718 gettext.rs: allow translating non-literal strings
A following commit will pass global string constants to the gettext macro.
This is not ideal because we might accidentally use the constants without
gettext (which we should never do). To fix that we might need to define a
macro per constant, or use a proc macro which is maybe not worth it.
2023-02-08 21:49:41 +01:00
Johannes Altmanninger
47cc98fd57 wutil.h: enable implicit conversion from wcharz_t to wcstring
This allows to write

    wcstring result = some_rust_function_that_returns_wcharz_t();
2023-02-08 21:49:41 +01:00
Johannes Altmanninger
bfa94bfa7a Fix rustc warning about auto deref
warning: deref which would be done by auto-deref
      --> src/wchar_ffi.rs:81:5
       |
    81 |     &*EMPTY_WSTRING
       |     ^^^^^^^^^^^^^^^ help: try this: `&EMPTY_WSTRING`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref
       = note: `#[warn(clippy::explicit_auto_deref)]` on by default
2023-02-08 21:49:41 +01:00
bagohart
ef07e21d40
Add separate completions for neovim (#9543)
Separate the neovim completions from the vim ones, as their supported
options have diverged considerably.

Some documented options are not yet implemented, these are added but
commented out.

Closes #9535.

---------

Co-authored-by: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
2023-02-08 12:47:08 -06:00
Xiretza
a16e2ecb1b Port echo builtin to Rust 2023-02-07 22:25:47 +01:00
Xiretza
4b85c2f6db builtin: propagate status from Rust builtins
The return type of `builtin_run_rust()` reflects that of C++ builtins.
2023-02-07 22:25:47 +01:00
Xiretza
cfb5bb2505 builtin: correctly flush streams after running Rust builtin 2023-02-07 22:25:47 +01:00
Fabian Boehm
8ff78eddf0 man: Reroute ".",":","[" to the proper names
Fixes #9552
2023-02-07 19:23:26 +01:00
Fabian Boehm
e90f003d2d Silence ENODEV errors for fstatat
Some broken gdrive filesystem can return these.

Fixes #9550
2023-02-06 21:49:07 +01:00
Fabian Boehm
f6b390dc61 completions/git: Remove a for-loop
This is an easy win for `git add ` completion time if we have multiple descriptions.

What happened was we did things once per description string, but the
things included a bunch of computation (including multiple `string`
calls and even a `realpath`!). Because these don't change, we can
simply do them once.

And it turns out we can just use a cartesian product:

for d in $desc
    printf '%s\t%s\n' $file $d
end

becomes

printf '%s\n' $file\t$desc
2023-02-06 21:49:07 +01:00
Mahmoud Al-Qudsi
0b160ebe71 Drop lazy_static from Cargo.toml
This should have been included as part of the previous commit, mea culpa.
2023-02-05 18:20:26 -06:00
Mahmoud Al-Qudsi
d7febd4f3e Use once_cell instead of lazy_static
lazy_static has better ergonomics at the call/access sites (it returns a
reference to the type directly, whereas with once_cell we get a static Lazy<T>
that we must dereference instead) but the once_cell api is slated for
integration into the standard library [0] and has been the "preferred" way to
declare static global variables w/ deferred initialization. It's also less
opaque and easier to comprehend how it works, I guess?

(Both `once_cell` and `lazy_static` are already in our dependency tree, so this
should have no detrimental effect on build times. It actually negligibly
*improves* build times by not using macros, reducing the amount of expansion the
compiler has to do by a miniscule amount.)

[0]: https://github.com/rust-lang/rust/issues/74465
2023-02-05 17:58:33 -06:00
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