Comments (11)
Oops, the problem was in do
syntax I guess?...
This one works
let external_completer = {| spans |
{ $spans.0: { carapace $spans.0 nushell $spans | from json } } | merge {
nix: {
let index = ($spans | length | $in - 1)
if $index < 1 { } else {
with-env { NIX_GET_COMPLETIONS: $index } {
^$"($spans.0)" ($spans | skip 1)
}
| lines
| skip 1
| str trim
| parse -r '(?P<value>\S*)\s*(?P<description>.*)'
}
}
} | get ($spans.0) | each {|it| do $it}
}
do $external_completer ["nix" "edit" ".#"]
from nushell.github.io.
looks like we can close this maybe? ๐
from nushell.github.io.
looks like we can close this maybe? yum
don't think so, at least provided examples on website are broken
from nushell.github.io.
oooooh this is an example in the documentation, then yeah there is an issue with it ๐
from nushell.github.io.
@MrFoxPro
i do not see the do $external_completer
above in the book page, where does it come from?
*trying to see if that's a bug with Nushell or an out-of-date documentation ๐
from nushell.github.io.
@amtoine
My bad here, I didn't describe issue fully
Basically, for make completions work, you usually perform steps:
- Look at docs, take example and add personal custom completions in config.nu:
let external_completer = {|spans|
{
$spans.0: { default_completer $spans | from json }
"mycmd": { [[value, description]; ["compl1 ", "This is compl1"]; ["compl2 ", "This is compl2"]] }
} | get $spans.0 | each {|it| do $it}
}
- And this will make completions go away completely.
- You will try to debug this by running in script file or in CLI, so write it like this:
3.1
let external_completer = {|spans|
{
$spans.0: { default_completer $spans | from json }
"mycmd": { [[value, description]; ["compl1 ", "This is compl1"]; ["compl2 ", "This is compl2"]] }
} | get $spans.0 | each {|it| do $it}
}
["mycmd" "compl1"] | do $external_completer
it will result in unexpected error that I've described above.
3.2 Or like this:
let external_completer = {|spans|
{
$spans.0: { default_completer $spans | from json }
"mycmd": { [[value, description]; ["compl1 ", "This is compl1"]; ["compl2 ", "This is compl2"]] }
} | get $spans.0 | each {|it| do $it}
}
do $external_completer ["mycmd" "compl1"]
That will end up with an error:
Error: nu::shell::not_a_list
ร Record field used twice
โญโ[/home/foxpro/craft/foxpro-nix/test.nu:2:1]
2 โ {
3 โ $spans.0: { default_completer $spans | from json }
ยท โโโโโฌโโโ
ยท โฐโโ field first defined here
4 โ "mycmd": { [[value, description]; ["compl1 ", "This is compl1"]; ["compl2 ", "This is compl2"]] }
ยท โโโโฌโโโ
ยท โฐโโ field redefined here
5 โ } | get $spans.0 | each {|it| do $it}
โฐโโโโ
So I'm not sure if it's incorrect behaviour or outdated documentation.
from nushell.github.io.
โ what happens if you only take the default completion of the book without adding custom things?
๐ also is see there are a bunch of expected things here ๐
Note
as i do not have commands likedefault_completer
, i'll simplify the test case
you are trying to run something like
let closure = {|argv|
{
$argv.0: "first arg"
"arg0": "redefinition"
} | get $argv.0 | each {|it| print $it}
}
do $closure ["arg0" "arg1"]
and i do indeed get
Error: nu::shell::not_a_list
ร Record field used twice
โญโ[entry nushell/nushell#6:2:1]
2 โ {
3 โ $argv.0: "first arg"
ยท โโโโฌโโโ
ยท โฐโโ field first defined here
4 โ "arg0": "redefinition"
ยท โโโโฌโโ
ยท โฐโโ field redefined here
5 โ } | get $argv.0 | each {|it| print $it}
here is what i see ๐
- as
"arg0"
and$argv.0
are the same the second line of the record in$closure
is a redefinition or the"arg0"
field, which is not possible
you should either- remove the
"arg0": "redefinition"
line in the record - remove
"arg0"
from the list of args, e.g. with["arg1" "arg2"]
- remove the
- you define a record with a bunch of of field and then only
get
the$argv.0
, so"arg0"
is useless
you should either- remove the
"arg0": "redefinition"
line in the record - remove the
get $argv.0
to let all the lines live
- remove the
in the end this looks like an incorrect closure or arguments given to it? ๐ค
from nushell.github.io.
in the end this looks like an incorrect closure or arguments given to it? thinking
Yes, but this is how it's stated in example:
from nushell.github.io.
ooooh, yup
then i wouldn't say the documentation is out-of-date but completely crazy ๐ฑ ๐
this actually does not make any sense to me ๐
from nushell.github.io.
shall we transfer this to the website?
and then try to find the proper form that this closure should take and finally fix the doc? ๐ ๐ช
from nushell.github.io.
I'm newbie in Nushell and don't know how it should work in first place and if it is correct implementation
from nushell.github.io.
Related Issues (20)
- Issue with terminology in Thinking in Nu page HOT 3
- Add documentation for multi-dot paths HOT 2
- rewrite docs suggestion HOT 12
- Remove `$nothing` from document HOT 1
- Replace std testing with nupm HOT 5
- Explanations in the cheat sheet should come before the code that's explained HOT 2
- The Cookbook Setup page references the now-removed `env` command several times HOT 2
- Broken links HOT 4
- Quick Tour example not related to the text
- Something error syntax in zh-CN/README.md HOT 3
- [Overlays] Basic example is not usable with latest Nushell HOT 4
- Dataframe page polars dtypes command fails HOT 2
- `format date` is not listed in Strings category commands HOT 1
- Query help page should mention it's a plugin HOT 3
- Add Comparison with PowerShell / NGS HOT 6
- Determine how to handle Vuepress code snippets in docs HOT 1
- Language translations should not translate filenames
- Piping into a literal should be an error
- Add "Warning/Tip" to top of older Release Notes that they might have outdated info
- Coloring and Theming - Add closure doc
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nushell.github.io.