d1y / bash.zed

7 stars 0 forks source link

Different colors for built-in commands, conditional statement and custom functions #4

Open datgausaigon opened 1 month ago

datgausaigon commented 1 month ago

Hi,

Can I request a feature like this?

Currently you are giving the same color format for built-in commands and custom functions.

For convenience and better, the color of built-in commands, conditional statements and custom functions should be 3 different colors.

I would like to send screenshots showing bash script code of the following IDEs: JetBrains IDE when using BashSupport Pro, shellcheck.net (note the color of built-in commands is rgb(60, 76, 114), the color of custom functions is rgb(0, 0, 0), the color of conditional statements is rgb(0, 0, 255)) and your Zed Plugin.

JetBrains IDE when using BashSupport Pro: Screenshot 2024-09-07 at 13 07 48

shellcheck.net: Screenshot 2024-09-07 at 13 07 31

bash.zed: Screenshot 2024-09-07 at 13 08 05

My sample code for testing:

#!/bin/bash

# String variables
string_one="foo"
string_two="bar"

# Number variables
number_one=5
number_two=3

# Function to perform addition and subtraction
foo_cal() {
    local a=$1
    local b=$2
    local operation=$3

    if [ "$operation" == "add" ]; then
        result=$((a + b))
        echo "The result of adding $a + $b is: $result"
    elif [ "$operation" == "subtract" ]; then
        result=$((a - b))
        echo "The result of subtracting $a - $b is: $result"
    else
        echo "Invalid operation. Please use 'add' or 'subtract'."
    fi
}

# Clear the screen
clear

# Display strings
echo "This is string variable 1: $string_one"
echo "This is string variable 2: $string_two"

# Call foo_cal function with different values
foo_cal $number_one $number_two "add"
foo_cal $number_one $number_two "subtract"
foo_cal $number_one $number_two "multiply" # Invalid operation

echo "Script has completed!"

Thanks 🐻

datgausaigon commented 1 month ago

Hi, We found the issue in the tree-sitter and posted it to their repository. Let's follow together https://github.com/tree-sitter/tree-sitter-bash/issues/271 Thanks 🐻