phidica / sublime-fish Goto Github PK
View Code? Open in Web Editor NEWA robust Sublime Text syntax package for fish
License: MIT License
A robust Sublime Text syntax package for fish
License: MIT License
The following snippet shows that the closing parenthesis is not recognized:
#!/usr/bin/env fish
set result (echo a = b)
echo $result
From here: https://github.com/gcuisinier/jenv/blob/master/fish/export.fish
See wbond/package_control#1570. Until Package Control has 3.8 support, the pyyaml dependency in highlighter_compat.py
keeps us on 3.3.
Consider the code
if true
end
(without a newline after end
). Then end
is highlighted as if it were a command name rather than a keyword; in Monokai, blue instead of red.
In other syntax highlighters (try the same code highlighted like MATLAB), this behaves as expected.
I'd like to see
foo -a -b --a-long-option
# ^ should be punctuation.definition.parameter
# ^^ should be variable.parameter
# ^ should be punctuation.definition.parameter
# ^^ should be variable.parameter
# ^^ should be punctuation.definition.parameter
# ^^^^^^^^^^^^^^^ should be variable.parameter
#!/usr/bin/env fish
function die
echo $argv
exit 1
end
set tokens foo bar
[ (count $tokens) -eq 3 ] ; or die whoops
# <- should ideally be support.function.test.begin
# ^ should ideally be support.function.test.end
Not sure if there is a way to make this plugin override that as the default everywhere.
It seems to be the case that end
doesn't end up correctly highlighted in function
/begin
/etc blocks when the block's final line that isn't just a comment is a pipeline ending with a comment. I gave a bunch of examples below to show when this does and doesn't trigger.
And the text from the screenshot:
# Example 1
begin
cat file.txt # print file.txt
end
# Example 2
begin
cat file.txt # print file.txt
# comment
end
# Example 3
begin
cat file.txt | grep 'word' # Find `word` in file.txt
end
# Example 4
begin
cat file.txt | grep 'word' # Find `word` in file.txt
end
# Example 5
begin
cat file.txt | grep 'word' # Find `word` in file.txt
echo "hello world"
end
# Example 6
begin
cat file.txt | grep 'word'
# Find `word` in file.txt
end
# Example 7
begin
cat file.txt | grep 'word' # Find `word` in file.txt
# comment
end
make fish 2>| less
# ^^^ pipe stderr to stdin of "less"
The newish &&
and ||
fish 3 syntax is causing the remainder of the line to be highlighted like a syntax error.
function svn-update-recursive
find . -name ".svn" -type d | xargs -I '{}' dirname '{}' | xargs svn update
# ^ should not be constant.numeric
end
complete -c node -l es52_globals -d 'activate new semantics for global var declarations. type: bool default: false'
# ^ should this be a constant.numeric?
#!/usr/local/bin/fish
set equals =
echo "$equals"
# <- missing variable.function
I am absolutely loving the new variable.parameter scopes :)
I found that the stderr redirect append operator ^^
(which is like >>
but for redirecting stderr instead of stdout) gets a deprecation message suggesting you replace it with 2>
, but I believe that since this is an append operator, 2>>
would be the appropriate replacement.
The current behavior is misleading and can lead to people accidentally introducing changes in the logic of their fish scripts.
Thanks so much for maintaining this awesome package! It's super useful!
Would be fantastic if this plugin supported using fish_indent
Would be awesome to see this package included by default in sublime text.
In the snippet files, all snippets that apply an indentation indent with 2 spaces. If you use a tab character for the indent, Sublime will automatically translate that to 4 spaces, or tabs, or whatever. Right now I have my settings set to 4 spaces + translate tabs to spaces, but inserting a snippet gives me a 2 space indent.
Also it's probably a good idea to organize those snippet files in a subfolder snippets
.
This looks very good, thanks for this! There are a few issues with it though.
https://www.sublimetext.com/docs/3/scope_naming.html
echo $$v[1][2]
# ^ should be punctuation.section.brackets.begin
# ^ should be punctuation.section.brackets.end
# ^ should be punctuation.section.brackets.begin
# ^ should be punctuation.section.brackets.begin
foobar
# ^^^^ variable.function, not support.function
foo -a -b --a-long-option
# ^ should be punctuation.definition.parameter
# ^^ should be variable.parameter
# ^ should be punctuation.definition.parameter
# ^^ should be variable.parameter
# ^^ should be punctuation.definition.parameter
# ^^^^^^^^^^^^^^^ should be variable.parameter
ls \
# ^ should be punctuation.separator.continuation
-a
foo\
bar
#^^ still part of foo, this reads "invoke the command foobar"
function show --no-scope-shadowing
# ^^^^^^^^^^^^^^^^^^^^ variable.parameter
ls
end
for i in $PATH; echo $i is in the path; end
# ^ should be keyword.operator
# ^ should be keyword.operator
echo $FOO
# ^^^ variable.other.readwrite ?
echo hello > output.txt
# ^ should be keyword.operator
cat < output.txt
# ^ shoul be keyword.operator
echo Hello > all_output.txt ^&1
# ^ should be keyword.operator ("redirect stderr to")
# ^^ ("filedescriptor 1 aka stdout")
cat foo.txt | head
# ^ keyword.operator
# ^^^^ excellent!
make fish 2>| less
# ^^^ pipe stderr to stdin of "less"
emacs &
# ^ keyword.operator ("do this in the background")
You could consider copying my bash rewrite here and adjusting the function and parameter syntax accordingly.
Could you add this as a package to packagecontrol?
That would make finding it more easy and probably bring some users to it.
Another bonus is more comfortable installation and deinstallation, thanks.
packagecontrol docs: https://packagecontrol.io/docs/submitting_a_package
If the base scope is source.shell.fish
, the ShellScript.sublime-build
can pick it up and then we can run our fish scripts from within sublime with cmdB.
sublime will often hang up when using this package to write fish codes.
hang up which means CPU's usage is 100% then not responding, I have to kill the sublime process to force quit.
for example, following codes will make my sublime hang up:
function crash
# going to rewrite it to fish code
function name {
help_message="help message, usage example: name"
if [[ $# -eq 0 ]]; then
echo $help_message
else
code=$1
if [ "$code" == '--help' ]; then
echo $help_message
else
echo "param: $code"
fi
fi
}
end
my sublime version is v2.0.2
Any idea?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.