slackhq / vscode-hack Goto Github PK
View Code? Open in Web Editor NEWHack language & HHVM debugger support for Visual Studio Code
Home Page: https://marketplace.visualstudio.com/items?itemName=pranayagarwal.vscode-hack
License: MIT License
Hack language & HHVM debugger support for Visual Studio Code
Home Page: https://marketplace.visualstudio.com/items?itemName=pranayagarwal.vscode-hack
License: MIT License
FB extension.
Signature here: https://github.com/facebook/hhvm/blob/master/hphp/hack/src/utils/lsp.ml#L850
Efforts to standardize this at microsoft/language-server-protocol#245 and microsoft/language-server-protocol#511
extends |
/ require extends |
with classes / abstract classes ( no final classes should be suggested ) from all namespaces, while suggesting the nearest symbols fist.implements |
/ require implements |
with interfaces from all namespaces, while suggesting the nearest symbols fist.uses |
with traitnames from all namespaces, while suggesting the nearest symbols fist.type foo = |
) with builtin types, classish symbols, type definitions from all namespaces, while suggesting the builtin types first, followed by the nearest symbols.foo($|
) with variables form the current scoop first, followed by variables from the parent scoop if applicable ( e.g : inside a block, that being an async
block or lambda body. while inside concurrent
block, local scoop variables should not be suggested. )$string === $|
)bool
when dealing with boolean operators ( e.g $a || $|
)num
when dealing with mathematical operators ( e.g $a + $|
)Some of the features request above work perfectly when working on the global namespace, but as soon as namespaces are involved, the DX is not as pleasant.
note : |
in the given samples refers to the cursor position.
PHP files starting with <?hh
should be recognized as Hack
FB extension to the LSP.
Signatures here: https://github.com/facebook/hhvm/blob/master/hphp/hack/src/utils/lsp.ml#L687
Hello,
I recently installed vscode-hack but I can't get the autocomplete working the same way it is shown in the plugging readme. When I right click in the code I can't see the Go to definition
option.
I am using:
I tried the configuration for remote development without success. (See below)
"hack.remote.enabled": true,
"hack.remote.type": "ssh",
"hack.remote.ssh.host": "ssh [email protected] -p 2222 \"cd /vagrant/webroot && /usr/bin/hh_client\" ",
I also executed succesfully ssh [email protected] -p 2222 "cd /vagrant/webroot && /usr/bin/hh_client
as recommended.
Looking forward to hearing from you,
Cheers,
Sam
ps: Here is my full settings.json:
{
"window.enableMenuBarMnemonics": false,
"window.zoomLevel": 0,
"window.openFilesInNewWindow": "on",
"workbench.editor.enablePreviewFromQuickOpen": false,
"workbench.colorTheme": "Darcula Extended",
"workbench.editor.tabSizing": "shrink",
"workbench.colorCustomizations" : {
"terminal.foreground" : "#00A20E",
"terminal.background" : "#080808"
},
"explorer.autoReveal": false,
"explorer.confirmDelete": false,
"editor.renderWhitespace": "all",
"editor.renderIndentGuides": true,
"editor.renderLineHighlight": "all",
"editor.largeFileOptimizations": false,
"editor.suggestSelection": "first",
"editor.quickSuggestions": {
"other": true,
"comments": true,
"strings": true
},
"terminal.integrated.shell.windows": "cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/k", "C:\\Users\\Samy\\cmder\\vendor\\init.bat"
],
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"files.associations": {
"*.php": "hack"
} ,
//check php version
// "php.validate.executablePath": "[email protected] -p 2222 \"cd /usr/bin/php\"",
// "php.validate.executablePath": "C:\\Users\\Samy\\dev\\php\\php-5.6.40\\php.exe",
// "php.validate.executablePath": "C:\\Users\\Samy\\dev\\php\\php-7.0.33\\php.exe",
// "php.suggest.basic": false,
// "php-docblocker.qualifyClassNames": true,
// "php-docblocker.returnGap": true,
// "phpformatter.composer": true,
// "phpcs.executablePath": "C:\\Users\\Samy\\dev\\php\\phpcs\\phpcs.phar",
// "phpcs.standard": "PSR2",
// "phpcs.ignorePatterns": [
// "/database/*",
// "/tests/*",
// "/app/Http/Routes/*",
// ],
"hack.remote.enabled": true,
"hack.remote.type": "ssh",
"hack.remote.ssh.host": "ssh [email protected] -p 2222 \"cd /vagrant/webroot && /usr/bin/hh_client\" ",
//"hack.remote.workspacePath": "",
"git.enableSmartCommit": true,
"git.ignoreLegacyWarning": true,
"gitlens.codeLens.enabled": false,
"gitlens.advanced.messages": {
"suppressGitVersionWarning": true,
"suppressShowKeyBindingsNotice": true,
"suppressResultsExplorerNotice": true,
"suppressWelcomeNotice": true
},
"gitlens.keymap": "chorded",
//"gitlens.historyExplorer.enabled": true,
"gitlens.hovers.currentLine.over": "line",
"gitlens.views.fileHistory.enabled": true,
"gitlens.views.lineHistory.enabled": true,
"prettier.printWidth": 120,
"prettier.singleQuote": true,
"prettier.tabWidth": 4,
// "[php]": {
// "editor.rulers": [120],
// },
"[html]": {
"editor.rulers": [120],
},
"[css]": {
"editor.rulers": [120],
},
"[less]": {
"editor.rulers": [120],
},
"[scss]": {
"editor.rulers": [120],
},
"[javascript]": {
"editor.rulers": [120],
},
"projects.refreshIgnoreFolders": [
"bower_components",
"node_modules",
"typings",
".vscode",
".vagrant",
".docker",
"nbprojects",
],
"projects.viewAllEnabled": true,
"projects.checkDirty": true,
"projects.checkPaths": true,
"breadcrumbs.enabled": true,
"workbench.iconTheme": "vscode-icons"
}
I've been trying to get the extension to work like your readme screen share. The only thing that seems to happen is the Hack Language Extension is available but, adding invalid syntax or hovering over function calls are responsive. I also don't see the code coverage percentage in the footer section. I've tried setting the hack.clientPath and no difference. I disabled all extensions besides this and nothing as well.
Im using a mac book pro with Sierra 10.12.5. I've installed hhvm 3.20 via homebrew.
hhvm --version
Any suggestions
Hi,
I know probably this is not the place for this question but I don't know where to ask.
So, will this plugin be maintained in the future?
will slack keep working with hacklang even though the end of the php support?
"An internal error occurred while processing a debugger command"
Inspecting variables from the debug console works fine
Using HHVM 4.62 on MacOS Catalina
I have a repository that uses a few different programming languages and in order to keep things clean I put the dotfiles to support each language in the folder containing that language's code.
It seems like this extension only supports .hhconfig
in the root of the workspace. Would it be possible to support workspaceContains:**/.hhconfig
? Or alternatively to add onLanguage:hack
to activationEvents
?
I'm willing to write and test a Pull Request if this would be an acceptable change?
๐ I'm the lead maintainer of https://github.com/github/linguist which uses this grammar for syntax highlighting of Hack files on GitHub.com.
I'm in the process of making a new release and our grammar compiler has detected an error in your grammar that was introduced in #72:
'Repository[type-annotation].Patterns[3].EndCaptures[1]' expected a map, got 'string'
The error is because the first, and only, endCaptures
in the fourth pattern of type-annotation
is a string:
"endCaptures": {
"1": "keyword.operator.key.php"
},
It should be a map, ie:
"endCaptures": {
"1": {
"name": "keyword.operator.key.php"
}
},
PR coming up.
As with #76, our grammar compiler has found another error introduced in #72. This time it's an invalid unicode regex match:
Invalid regex in grammar: `source.hack` (in `syntaxes/hack.json`) contains a malformed regex (regex "`(?xi)([a-z_\x{7f}-\x{7fffffff}]`...": character value in \x{} or \o{} is too large (at offset 30))
... and ...
Invalid regex in grammar: `source.hack` (in `syntaxes/hack.json`) contains a malformed regex (regex "`(?i)[a-z_\x{7f}-\x{7fffffff}][a-`...": character value in \x{} or \o{} is too large (at offset 27))
The line numbers have been truncated. but they correspond to...
vscode-hack/syntaxes/hack.json
Line 910 in 62329f6
... and ...
vscode-hack/syntaxes/hack.json
Line 918 in 62329f6
... respectively.
I suspect the intent here was to cover all unicode chars from 0x7F
to the end, however 0x7FFFFFFF
is no longer a valid UTF-8 unicode char. As of 2003, the max is 0x10FFFF
.
From https://en.wikipedia.org/wiki/UTF-8#History:
In November 2003, UTF-8 was restricted by RFC 3629 to match the constraints of the UTF-16 character encoding: explicitly prohibiting code points corresponding to the high and low surrogate characters removed more than 3% of the three-byte sequences, and ending at U+10FFFF removed more than 48% of the four-byte sequences and all five- and six-byte sequences.
PR coming up to implement this change.
namespace Cast;
<<Lossy, Safe>>
//purple ^^^^
function num_int_round(num $num): int {
return $num is int ? $num : float_int_round($num as float);
}
namespace Cast;
<<Safe>>
function num_int_round(num $num): int {
return $num is int ? $num : float_int_round($num as float);
}
See: facebook/hhvm#8552
Same issue as facebookarchive/nuclide#814
Slightly less annoying as 'space' doesn't accept it, but newline still does.
Same as facebookarchive/nuclide#765
I'm using Arch Linux, and VSCode Hack 0.5.0. If there is no newline at the end of the file, the last line gets removed when formatting, which can remove closing braces and create syntax errors.
HipHop VM 4.28.0 (rel)
Compiler: 1571678629_197174034
Repo schema: c1068de11223e85fa6f517d694c9df37c23b7732
code --version
1.39.2
6ab598523be7a800d7f3eb4d92d7ab9a66069390
x64
Name: Hack
Id: pranayagarwal.vscode-hack
Description: Hack language & HHVM debugger support for Visual Studio Code
Version: 2.7.0
Publisher: Pranay Agarwal
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=pranayagarwal.vscode-hack
Ubuntu 18.04
class SomeClass {
public function someMethod(int $_1, int $_2): void {}
}
function main(): void {
$some_class = new SomeClass();
$some_class->s <--
}
class SomeClass {
public function someMethod(int $_1, int $_2): void {}
}
function main(): void {
$some_class = new SomeClass();
$some_class->someMethod()(, )
}
class SomeClass {
public function someMethod(int $_1, int $_2): void {}
}
function main(): void {
$some_class = new SomeClass();
$some_class->someMethod(, )
}
Would love to see VSCode's debugger work with HHVM. I'm willing to help but have no idea where to start.
I've tried getting xdebug debugging working in HHVM and failed, but I did have success with HHVM's built-in debugger--although it was a pain to use. Integrating that with VSCode would be a dream...
I installed your extension.
When I returned to a personal project which uses Elixir, I found the autocomplete extension was not working.
When I disabled your extension and reloaded, the Elixir extension worked again.
These features ( Go To Implementation / Go To Inheritor ) are provided by JetBrains PHPStorm, and they makes DX way much better specially when dealing with a large OOP code base.
hh_client
is fully capable of listing inheritance ancestors, and children, using --inheritance-ancestor*
, and --inheritance-children
modes , which could be used to implement those features.
hh_client makes a distinction between global options and per-command options. For example, hh_client --enhanced-hover lsp
is invalid, but hh_client lsp --enhanced-hover
is valid
Should be possible using VS Code extension APIs & hh_client rename command.
class ClassnameFoo{
public function bar(): void{}
}
function doSomething(ClassnameFoo $foo): void{
$foo-> //autocomplete this
}
The suggestions on pressing ctrl+space at the arrow are: 'ClassnameFoo', 'doSomething', 'foo', 'function', and 'void'
bar() //ClassnameFoo::bar(): void
Commands ran within the integrated terminal: hh_client
Result from hh_client: src/example.hack:2:11,11: A name or variable name is expected here. (Parsing[1002])
hhvm --version
HipHop VM 4.0.2 (rel)
Compiler: 1550605031_606999898
Repo schema: a46021ba5e51d676a396f711ef442e334fa9152a
hh_client --version
hh--4.0.2 Tue Feb 19 20:40:27 2019
vscode-hack
Name: Hack
Id: pranayagarwal.vscode-hack
Description: Hack language & HHVM debugger support for Visual Studio Code
Version: 1.2.1
Publisher: Pranay Agarwal
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=pranayagarwal.vscode-hack
const dict<string, (function(Webserver\RequestURL): Awaitable<void>)> CONSTANT_NAME = dict[];
//00000 000012222221 33333333333333333333333333333333 33333333333333330 4444444444444 0 0000111
In case github updates their version before you had a chance to see it, this is what I see right now.
0 -> red
1 -> black
2 -> green
3 -> purple
4 -> blue
The comma behind string is red.
The left angle bracket of the Awaitable is red, but the right one is gray.
The left paren of the (function) is blue, but the right one is gray.
The left angle bracket of the dict is gray, but the right one is white.
e.g. $foo as arraykey
is currently highlighted differently to $foo as string
May be easiest to restart the extension by default on every hack.*
config change.
Integrate with VS Code workspace symbols API to provide fuzzy search results for a symbol throughout the project in the command bar.
The coverage indicator in the status bar should be clickable, and should toggle coverage warnings on/off.
vscode is only showing me [Hack] Wrong type hint (17,42)
Nuclide and hh_client show me:
src/fbmarkdown/unparsed-blocks/Context.php:17:42,56: Wrong type hint (Typing[4110])
src/fbmarkdown/unparsed-blocks/Context.php:17:26,38: This is an object of type Facebook\Markdown\UnparsedBlocks\BlockProducer
src/fbmarkdown/unparsed-blocks/Context.php:27:5,15: It is incompatible with an object of type Facebook\Markdown\UnparsedBlocks\ListOfItems
Hi!
I tried to setup a development environment on Windows and running hhvm and hh_client in docker (Linux), unfortunately without luck.
Has anyone succeeded with similar setup? The diag log here is not really helpful as the lang server gracefully disconnects and after 3 tries the extension gives up.
.hack
files will not require - or allow - leading markup or <?hh
lines - they're always strict.
See facebook/hhvm#8421 for hack and hackc change, hhvm/vim-hack#46 for a corresponding change to vim
These two files are equivalent:
<?hh // strict
function foo(): void {
}
function foo(): void {
}
Useful for logs; e.g. hh_client --from vscode-hack
or hh_client lsp --from vscode-hack
Does this extension really work with ssh? I tried multiple versions and nothing happened in my editor -- no lint, no format, nothing.
My ssh and remote hh_client works fine though. I ran this test as suggested and I got output from hh_client
ubuntu@UbuntuDesktop:~$ ssh [email protected] "cd /home/ubuntu/git_root/www2 && hh_client"
/home/ubuntu/git_root/www2/index.php:4:18,21: Unbound name: nore (an object type) (Naming[2049])
/home/ubuntu/git_root/www2/index.php:4:25,28: Encountered unexpected token 'turn'. (Parsing[1002])
When using the debugger, everything in the variables panel gets collapsed on every step. This is especially annoying when trying to examine a nested structure.
I had initially thought this was a default VS Code behavior, but according to microsoft/vscode#32199 the state is determined by the debug server itself. Can dig bit deeper into this and see if this can be fixed in the extension debug adapter or by HHVM.
Should:
$ROOT/vendor/bin/hhast-lint
is present (or fail gracefully if it isn't)hhast-lint --mode lsp --from vscode
Additionally, --json isn't going to be in a release
Hi,
When you are selection and option from the autocompletition list, vscode don't remove
the last '
Example:
if you have a shape with field message
$test['message'] = 'hello world';
then you are accessing that field, vscode automatically create the quotation mark for close.
$test['']
then you pick 'message' from the autocompletition list, the result is
$test['message'']
the problem is the double quotation mark to close.
const vec<int> v = vec[0];
function foo(vec<int> $v = vec[0]): void {}
The first occurrence of int
is incorrectly highlighted here.
This is sometimes unavoidable and makes the warnings panel useless for these files
Useful for adding HH_IGNORE_ERROR - eg hh_client shows:
Too few arguments (Typing[4104])
vscode just shows "Too few arguments"
If I know what I'm doing, I can add:
/* HH_IGNORE_ERROR[4104] */
or
/* HH_FIXME[4104] */
The following code does not highlight properly:
function foo(int $arg): shape(...){
return shape();
}
in master, hh_client lsp
gets you a vscode LSP server
if you're on mac, you can get a recent enough build of HHVM/hh_client by following facebookarchive/nuclide#1358 (comment)
e.g. vscode is unaware that https://github.com/hhvm/hhast/blob/master/bin/hhast-lint is a Hack file
Exact same bug as facebookarchive/nuclide#711
Command palet Hack: Toggle Coverage Highlight
results in
command 'hack.toggleCoverageHighlight' not found
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.