Skip to content

Erlang - integrate Gradualizer#2115

Closed
erszcz wants to merge 12 commits intoneomake:masterfrom
erszcz:erlang-gradualizer
Closed

Erlang - integrate Gradualizer#2115
erszcz wants to merge 12 commits intoneomake:masterfrom
erszcz:erlang-gradualizer

Conversation

@erszcz
Copy link
Copy Markdown
Contributor

@erszcz erszcz commented Oct 25, 2018

Gradualizer implements a gradual typing system for Erlang. Although still under development, it's already useful, while integration with Vim/NeoMake will hopefully foster early adoption a bit.

This PR refactors the existing Erlang erlc support code for reuse with the new gradualizer maker. The maker is not enabled by default, since Gradualizer still rarely crashes on some code files - this doesn't affect Vim, though. One has to opt-in with:

let g:neomake_erlang_enabled_makers = ['erlc', 'gradualizer']

The maker by default calls gradualizer.sh - a shim shell script which processes Gradualizer output so that it is consumable with a simple pattern - this script is not included in this PR, but will be PRed to Gradualizer.

try
let root = tempname()
let root = tempname() . '/'
call mkdir(root, 'p')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like vim73 does not like the extra slash here with the mkdir.

Copy link
Copy Markdown
Member

@blueyed blueyed Oct 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also use neomake#utils#Slash() for Windows compatibility in the future.. (related: see neomake#utils#fname in 119dc9b - not in master though yet)

@erszcz
Copy link
Copy Markdown
Contributor Author

erszcz commented Oct 26, 2018

I hope the last commit fixes current issues. If neomake#utils#fname lands in master before this PR I'll refactor accordingly.

I'll also like to add the mentioned gradualizer.sh script to this PR, so please wait for another commit with it - Gradualizer folks suggested it might make more sense to keep it with the plugin.

@erszcz erszcz changed the title Erlang - add integration with Gradualizer Erlang - integrate Gradualizer Oct 26, 2018
@erszcz
Copy link
Copy Markdown
Contributor Author

erszcz commented Nov 6, 2018

@blueyed Any remarks / necessary changes?

Copy link
Copy Markdown
Member

@blueyed blueyed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks really decent already, but there is no rush to merge it - as you can see from your last commit there is usually stuff that pops up while using it.

As for gradualizer.sh and only skimming this quickly I think it might not really be necessary after all, since errorfornat and or post-processing could also handle this?!

#set -x

# Set to your gradualizer location or make sure the command is in PATH
GRADUALIZER=gradualizer
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be gradualizer=${GRADUALIZER:-gradulizer} (and then use $gradulizer below), if this should be more easily configurable.

Also consider using NEOMAKE_GRADUALIZER first then, if it makes sense.

SED=gsed
else
SED=sed
fi
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look that good: it shells out to uname for once.
Is GNU sed really required?
And shouldn't the errorformat just handle this (the replacement) maybe even?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GNU and BSD sed do behave differently with the present command and I was not able to come up with a sed script/command which would achieve the same but work for both of them.
Then, it's arguable, but I think more probable that a developer using a Mac will have gsed installed, than a Linux person a BSD sed installed.

I'll look into errorformat, maybe you're right that it's possible to ditch the shell script altogether.

SED=sed
fi

$GRADUALIZER $@ | $SED '/\(.*on line \([0-9]*\)\)/ {s//\2:\1/}' | sort -n | uniq
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally: why the sort and uniq?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, my mistake. The surplus let args += [expand('%')] in neomake#makers#ft#erlang#GradualizerArgs was the reason, because the file was processed twice.

@erszcz
Copy link
Copy Markdown
Contributor Author

erszcz commented Nov 15, 2018

[...] as you can see from your last commit there is usually stuff that pops up while using it.

Definitely. I just had some spare time and figured it couldn't hurt to ask. Thanks for the pointers!

…default

It's possible to enable the maker with the standard Neomake setting:

  let g:neomake_erlang_enabled_makers = ['erlc', 'gradualizer']
In the longer run gradualizer itself might print consumable output.
Until then, though, a thin shell script sanitizes the messages for Vim.
Using Vim `errorformat` it's possible to consume Gradualizer output directly.
@erszcz erszcz force-pushed the erlang-gradualizer branch from 7985a52 to 4dbc28c Compare December 15, 2018 20:59
@erszcz erszcz closed this Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants