FixedBit / lslint-for-vscode

LSLint support for Microsoft Visual Studio Code
GNU General Public License v3.0
6 stars 1 forks source link

Allow a custom execution of lslint #3

Open Corysia opened 1 year ago

Corysia commented 1 year ago

If I stick with regular LSL, this lslint and this plugin work great. When you get in to more advanced LSL, however, you really want to use a preprocessor to tighten up your code. For example, declaring a variable for each constant you want to have is expensive. It's far better to use a #define to give a friendly name to a number.

In order for me to use lslint, I've got to use the local C Preprocessor in order to generate code first. In Windows, I've installed cygwin, so I can use bash and g++. The script I use to call lslint is as follows:

#!/bin/bash

INCLUDE=/cygdrive/c/Users/Corysia/SecondLife/LSL
if [ "$1" == "" ]; then
        echo "Usage: $0 <filename>";
        exit 1;
fi

cat $* | cpp -I"$INCLUDE" -E - | lslint -i

I'd really like to be able to configure the equivalent of that script in this plugin. But it has to be flexible enough for people who don't use a local preprocessor.

FixedBit commented 1 year ago

In order for me to use lslint, I've got to use the local C Preprocessor in order to generate code first. In Windows, I've installed cygwin, so I can use bash and g++. The script I use to call lslint is as follows:

#!/bin/bash

INCLUDE=/cygdrive/c/Users/Corysia/SecondLife/LSL
if [ "$1" == "" ]; then
        echo "Usage: $0 <filename>";
        exit 1;
fi

cat $* | cpp -I"$INCLUDE" -E - | lslint -i

You know this is not a bad idea and can actually look into that and maybe find a way to give an option in the plugin. Well thinking about it I am not 100% sure how to tie it back to the original file once parsed...

As it stands the problem is with lslint proper.

I will research it again but basically what people seem to suggest is kind of what you are saying too, spit it into another parser first then check it, will research and see as you got me to dig deeper into it and will take some research... Will keep you posted on what I find!

I mean I can't promise anything like for people who run it on Windows, but there is some interesting discussion here:

https://github.com/Makopo/lslint/issues/47 https://github.com/XenHat/SublimeLinter-contrib-lslint/issues/6

Corysia commented 1 year ago

I realized after I posted that, my script is more complicated than it needed to be.

cpp -I"$INCLUDE" -E $* | lslint -i

The -i flag on lslint is required because of the output cpp creates. So that's a consideration you'd have to have when setting up the configuration.

You'd also need to have a field to provide the path to cpp. On Mac/Linux, it's usually in the path. With Windows, they may be using Visual Studio.