Commit Graph

282 Commits

Author SHA1 Message Date
Qi Xiao
241f15de42 Clean up tests introduced in #1604 slightly. 2022-09-11 15:58:58 +01:00
kas
93c9f86555 Add support for completing invocations of local executables 2022-09-11 15:54:13 +01:00
rok
f4f96b47b8 vi append command binding 2022-09-11 15:36:53 +01:00
Qi Xiao
27e2df9394 Remove edit:-dump-buf.
This used to be used for taking ttyshots but is now obsolete.
2022-09-11 15:33:59 +01:00
Kurtis Rader
2f21892e0c
Documentation fixups (#1584)
I noticed these functions didn't have a "usage" while working on a `help` command.

Co-authored-by: Qi Xiao <xiaq@users.noreply.github.com>
2022-09-11 15:28:32 +01:00
Kurtis Rader
c6e10f12a2 Some minor documentation fixes
Mostly elimination of duplicated words but also a few other fixes such
as the output of commands such as `%`.
2022-08-29 12:04:59 +01:00
Qi Xiao
21e951427f pkg/edit/highlight: Highlight the catch keyword. 2022-08-29 11:18:57 +01:00
Qi Xiao
afc3c140d9 Improve doc on conditionally importing a module.
- Expand the example in edit:add-var, and give it a h3.

- Add a link from the language reference to the section in edit:add-var.

This fixes #1116.
2022-08-13 11:26:13 +01:00
Qi Xiao
551e246d96 webiste/cmd/macros: Strip leading $ from anchor targets of @cf.
Also add previously missing $'s in @cf arguments. This doesn't matter for the
anchor target, but matters for the link text.
2022-08-08 00:09:17 +01:00
Qi Xiao
2e788c846d Run gofmt.
https://tip.golang.org/doc/go1.19#go-doc
2022-08-07 22:30:11 +01:00
Qi Xiao
41fc578002 Merge branch 'ttyshot' 2022-08-04 23:41:11 +01:00
Qi Xiao
4afbb71c07 Move pkg/testutil/must.go to a new pkg/must. 2022-06-20 20:29:14 +01:00
Qi Xiao
6723b9a226 Use consistent pattern for mutating variables in tests.
- Use testutil.Set.

- Only export such variables to tests.
2022-06-19 23:56:18 +01:00
Kurtis Rader
4b4726b9a6 Make ttyshots scripted and reproducible
The main benefits of this change are:

1) It uses a hermetic "home" directory with a known command and location
   history. Which means it no longer depends on the interactive history
   and directory layout of the person creating the ttyshot. Which also
   means it no longer leaks the private history of anyone creating a
   ttyshot. This produces reproducible results when updating ttyshots.

2) The user no longer has to augment the ttyshot by manually adding the
   output of the commands to the generated HTML file. A process that is
   error prone. The output of the commands that generate the ttyshot is
   now captured and automatically included in the resulting HTML.

3) It makes it trivial to recreate every ttyshot. Simply execute these
   commands:

   ```
   make ttyshot
   for f [website/ttyshot/**.spec] { put $f; ./ttyshot $f }
   ```

4) It makes it easy to introduce new "ttyshot" images by creating a
   shell session "spec" file. This makes it easy to replace the existing
   "```elvish-transcript...```" examples with ttyshots in order to
   ensure a consistent representation and visual consistency with the
   transcripts that are currently generated as ttyshots.

The downside of this change is the introduction of a dependency on the
Tmux application. But that seems reasonable since Tmux is a mature
application available on Linux, macOS, BSD, and probably every other
UNIX like OS we care about. Note that generating the Elvish
documentation already depends on similar apps such as Pandoc.

Related #1459
2022-06-19 10:51:29 +01:00
Qi Xiao
75ee261fcb pkg/eval: Remove access methods for exported fields.
The exported fields are intended to be mutated directly.
2022-06-18 19:01:59 +01:00
Qi Xiao
4a6405eeb4 pkg/edit/complete: Improve analysis of variable definitions.
- Remove the sigil from the variable name.

- Recognize function parameters too.
2022-06-14 20:50:57 +01:00
Qi Xiao
e0ee14ad68 Support completing variables defined in the code being completed. 2022-06-13 23:00:06 +01:00
Qi Xiao
534be70bfb Simplify implementation of variable completion.
There is no need to enumerate namespaces separately, since namespaces are also
variables. The only exceptions are "e:" and "E:", which are handled as special
cases now.
2022-06-13 22:50:44 +01:00
Qi Xiao
6564b14898 Fix crash when completing code with unexpected rune.
This fixes #1530.
2022-06-12 21:39:51 +01:00
Qi Xiao
68bce3b4a4 Clarify error message when writing values to port not supporting it.
This fixes #1516.
2022-06-07 20:29:34 +01:00
Qi Xiao
f043bd33fb Fixup for #1549. 2022-06-05 22:37:52 +01:00
Kurtis Rader
fa704d6ac6 Implement edit:command-abbr
It turns out that the "small word" abbreviation mechanism I added isn't
really what I, or most users, want. What users really want, at least
most of the time, is the Fish shell abbreviation behavior of expanding
an abbreviation only in the command head position.

Resolves #1472
2022-06-05 22:15:07 +01:00
Kurtis Rader
345c5c66dd Don't dot import pkg/ui
Qualified imports of pkg/ui outnumber unqualified (82 to 1). Improve
consistency, and clarity, by changing the dot (unqualified) imports of
that package symbols to qualified.
2022-06-04 23:39:19 +01:00
Kurtis Rader
71cd3835bc Don't dot import pkg/tt
Qualified imports of pkg/tt outnumber unqualified (27 to 24). Improve
consistency, and clarity, by changing the dot (unqualified) imports of
that package symbols to qualified.
2022-06-04 23:39:19 +01:00
Kurtis Rader
14321f9e82 Make parse.Source naming more consistent
Fixes #1545
2022-05-29 17:36:29 +01:00
Qi Xiao
3a3b8f5700 pkg/edit/complete: Change Complete to take an Evaler.
The PureEvaler abstraction made things unnecessarily complex; it's better to
just create a real Evaler for tests is pretty.

The Evaler has a new ReplaceBuiltin method to make it easier to construct the
expected test result.
2022-04-11 21:39:29 +01:00
Qi Xiao
a8c2d165d3 Simplify pkg/edit/complete/node_path.go with generics.
staticcheck@master crashes when checkling code using generics, disable it in CI
for now.
2022-03-20 16:17:19 +00:00
Qi Xiao
51e4d97568 interface{} -> any now that Elvish requires Go 1.18. 2022-03-20 16:17:19 +00:00
Qi Xiao
f7cb556d9b Require Go 1.18.
- Run "go fix" to remove legacy build tags

- Use staticcheck@master until it has a release that supports Go 1.18

- Turn off autocrlf for Windows tasks
2022-03-20 15:28:23 +00:00
Kurtis Rader
603aae077d Improve searching PATH on Windows for completions
This was extracted from https://github.com/elves/elvish/pull/1326. It
augments that change by honoring $E:PATHEXT and some other
minor improvements.  This matches the behavior of the Go stdlib
os/exec.LookPath() function that is used to decide if what has been typed
(in a non-completion context) represents an external command.
2022-03-12 22:49:52 +00:00
Qi Xiao
5f1673c6c4 Use go-cmp to report unexpected test results.
cmp.Diff panics when comparing a struct that has unexported fields and no String
or Equal method, so change some structs to either export all their fields or
have an Equal method.

This fixes #1136.
2022-03-11 22:49:32 +00:00
Qi Xiao
92c7e4b303 pkg/lsp: Support textDocument/completion. 2022-03-07 14:27:26 +00:00
Qi Xiao
b8f4cb001d pkg/edit/highlight: Fix highlighting when "except" is followed by a lambda.
This fixes #1358.
2022-03-01 00:57:46 +00:00
Qi Xiao
e58e5a4e56 pkg/edit/complete: Refactor how parse tree is matched.
- Introduce nodePath to store the complete path to the leaf node.

- Introduce a nodesMatcher abstraction to do pattern matching on nodePath.

Parse tree matching previously requires deeply nested if statements to walk
multiple levels of the tree and (optionally) check the property of nodes. These
are replaced by a single "if np.match(...)", with a single level of nesting.
2022-02-27 11:56:58 +00:00
Qi Xiao
6efce297b2 Update completer for assignment.
- Offer variable names as arguments of "set" or "tmp".

- Stop offering "varname = " at the command head position.
2022-02-27 00:02:10 +00:00
Kurtis Rader
8c9414a0ec No-daemon build don't panic starting location mode
Fixes #1487
2022-02-20 23:27:24 +00:00
Qi Xiao
fda62502ad pkg/edit: Slighly refactor the handling of nil Store. 2022-01-16 21:18:55 +00:00
Christian Walter
f5b645cc2d pkg/edit: Don't call AddDir on storedefs if it is not ready
Signed-off-by: Christian Walter <christian.walter@9elements.com>
2022-01-16 21:18:05 +00:00
Qi Xiao
59459793e3 pkg/persistent: Cons -> Conj.
Cons was a misnomer for the operation of adding an element at the end of a
vector. Follow Clojure's naming here and call this operation Conj.
2022-01-05 22:34:55 +00:00
Qi Xiao
84b72af4ca Support using styled text in &display to edit:complex-candidate.
This fixes #1011.
2022-01-03 20:30:00 +00:00
Qi Xiao
38d4553833 Update assignment syntax in docs.
- Also remove the section for the legacy assignment syntax.

- Also add a paragraph to "eval" about upvalues.
2022-01-03 19:45:39 +00:00
Qi Xiao
4350ad48b1 Remove highlighting for legacy assignment syntax. 2022-01-03 00:59:48 +00:00
Qi Xiao
003557c22a Remove support for the legacy lambda syntax.
This fixes #664.
2022-01-03 00:47:41 +00:00
Qi Xiao
4fcffc5671 Remove most uses of the legacy assignment syntax.
The remaining few uses are in some of the tests, which will be removed later.

This addresses #645.
2022-01-03 00:47:41 +00:00
Qi Xiao
653c9f9d0f Remove dir-history, deprecated since 0.17.0. 2022-01-03 00:47:41 +00:00
Qi Xiao
d9eb0928e3 Bind Alt-Enter to inserting "\n". 2022-01-01 23:52:34 +00:00
Qi Xiao
097e32b375 pkg/eval/vals: Add ReprPlain, Repr without pretty-printing.
Also de-export NoPretty now that it is no longer needed.
2021-12-31 21:05:07 +00:00
Qi Xiao
5bf688cf4d New flag module. 2021-12-31 18:03:24 +00:00
Qi Xiao
e01e5dd2f5 pkg/getopt: Revamp the API and implementation.
- Don't require creating a Getopt object in the API.

- Add a new Parse function, and rename the existing method to Complete.

- Add an Unknown field to Option to indicate unknown options.

- Rewrite the tests.

- Numerous stylistic changes.
2021-12-31 14:36:01 +00:00
Qi Xiao
46774d7078 Use (*Evaler).Chdir for changing directory in navigation mode.
This will run the hooks and update $E:PWD correctly.
2021-12-28 17:52:09 +00:00