Raised This Month: $48 Target: $400
 12% 

[Editor] AMXXPawn for Visual Studio Code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KliPPy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-25-2017 , 00:04   [Editor] AMXXPawn for Visual Studio Code
Reply With Quote #1

AMXXPawn Language Service for VSCode


An extension for Visual Studio Code that adds support for the AMXXPawn language.


Features

Right now this is pretty much an early preview/beta version with features lacking, and some features even not working properly. Even though it's unfinished, I've posted this solely to get feedback. I encourage you to post in this topic and help me improve this extension.

However, here is a basic preview of currently implemented features:
  • Syntax highlight.

  • Checks if included files are valid, provides links to the AMXX Web API reference:


  • Allows you to 'Go to Definition' and open the included file in a new editor tab, or to 'Peek Definition', which opens an 'inline' view (called Code Lens) of the included file:


  • Provides function signature help as a pop-up when you start typing a function call:


  • Symbol suggestions as you type:


  • Document symbol lookup (Ctrl+Shift+O) - easy way to navigate to any symbol that's been defined in the currently open file:


  • Has compiler support - you can compile your plugin by running the 'AMXXPawn: Compile Plugin' command from the command palette (Ctrl+Shift+P by default) or by going to Keyboard Shortcuts page (which is really intuitive in VSCode by the way) and binding it to a key combination:




    However, to use the compiler you have to configure you environment first through the Settings page in VSCode:

    An example:


Visual Studio Code

In case you haven't heart of Visual Studio Code (VSCode) yet - it's an open-source multiplatform text/code editor developed and maintained by Microsoft. It's entirely written in TypeScript using Electron framework. It has many great built-in features like Git integration and Debugging support, but also has support for extensions (just like this one), of which there are many.
VSCode has been my go-to editor for many other languages (especially for Node.js development) for a while now, but it never had proper Pawn support. This extension aims at improving Pawn language support in VSCode.

Official site & Downloads


Installation Instructions

Installation is pretty straightforward, thanks to VSCode's great support for extensions.
All you have to do is to open the Extensions View (by using the bar on the left hand side or pressing Ctrl+Shift+X), search for "amxxpawn" and click the "Install" button, then reload VSCode.
Make sure to install the one with my name as there are two registered amxxpawn extensions.




Source Code
Change Log

Contributions are welcome.
Also, if you have any ideas/suggestions/critiques, please post in this topic.

TODO:
Code:
- Properly parse and resolve #include directives.
    - Right now only #include <filename> format is supported
    - #include "filename" and #include filename should look in the current directory and the list of include directories.
    - #include <filename> should only look in the list of include directories.

- Handle #tryinclude

- Properly handle block comments and scopes (brackets) when parsing files, some edge cases may break the parser

- In addition to functions, parse:
    - Global variables/constants (not completely done)
    - Enumerations
    - #define directives

- Add Go to Definition/Peek Definition for symbols

- Parse doc-comments and display them together with completions and signature help

- Handle dependency timestamps - if a dependency has changed, reparse it

- (maybe) Add basic IntelliSense implementation (requires a new parser):
    - Detect tag mismatches
    - Detect unreachable code
    - Wrong syntax

- (maybe) Make function parameters tag-aware and suggest only (or prioritize) symbols that have the same tag
- (maybe) Make array element access enum-aware and sugest only (or prioritize) members of the same enum

- (maybe) Make the parser scope aware and parse symbols in scopes too so completions can suggest local variables and parameters

Last edited by KliPPy; 08-29-2017 at 17:31.
KliPPy is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Location: tunisia
Old 08-25-2017 , 07:45   Re: [Editor?] AMXXPawn Language Service for Visual Studio Code
Reply With Quote #2

nice, i have a suggestion can you add an option like "Compile plugin" called "Compile plugin local" so it search amxxpc.exe where the .sma folder.
__________________
JusTGo is offline
KliPPy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-25-2017 , 08:11   Re: [Editor?] AMXXPawn Language Service for Visual Studio Code
Reply With Quote #3

Quote:
Originally Posted by JusTGo View Post
nice, i have a suggestion can you add an option like "Compile plugin" called "Compile plugin local" so it search amxxpc.exe where the .sma folder.
Strange thing to request. Would you like it to be a setting, so that when it's set to true it first looks for amxxpc in the input path, or just make it a command?
KliPPy is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Location: tunisia
Old 08-25-2017 , 08:16   Re: [Editor?] AMXXPawn Language Service for Visual Studio Code
Reply With Quote #4

a command, its not strange its usefull just one press this command it looks for amxxpc.exe or compile.exe in the opened file folder.
__________________
JusTGo is offline
KliPPy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-25-2017 , 09:07   Re: [Editor?] AMXXPawn Language Service for Visual Studio Code
Reply With Quote #5

I've pushed an update for your request. You can update your extension by going to the Extensions View and clicking the "Update" button on the extension entry.
KliPPy is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Location: tunisia
Old 08-25-2017 , 09:21   Re: [Editor?] AMXXPawn Language Service for Visual Studio Code
Reply With Quote #6

if possible also check for include folder ect..., like when you open a sma in amxmodx/scripting/ you get evry thing in that folder.
__________________
JusTGo is offline
KliPPy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-25-2017 , 16:00   Re: [Editor?] AMXXPawn Language Service for Visual Studio Code
Reply With Quote #7

Version 0.2.0 has been published, you can install/update it from the Extensions View, as usual.

Code:
[Version 0.2.0] - 2017-08-25

Added
    - Document symbol lookup (Ctrl+Shift+O) - Easy way to search and navigate to any symbol in the currently opened document
    - Symbol completion - displays suggestions as you type

Fixed
    - Included dependencies are now properly managed, no more data leaks
Completions:



Document symbol lookup:
KliPPy is offline
Hedgehog95
Senior Member
Join Date: Jun 2010
Old 08-25-2017 , 17:23   Re: [Editor?] AMXXPawn Language Service for Visual Studio Code
Reply With Quote #8

Good job. Can you make project directory variable for compiler paths?
__________________


[CS] Halloween Mod - This is a completely new gamemode for Halloween Holidays.

[CS] Custom Entities API - API to register custom entities. It's provides some new and more comfortable architecture for complex projects.

Hedgehog95 is offline
KliPPy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-25-2017 , 17:38   Re: [Editor?] AMXXPawn Language Service for Visual Studio Code
Reply With Quote #9

Quote:
Originally Posted by Hedgehog95 View Post
Good job. Can you make project directory variable for compiler paths?
Thanks. I don't think I understand what you mean by that. Could you elaborate please?
KliPPy is offline
Hedgehog95
Senior Member
Join Date: Jun 2010
Old 08-26-2017 , 03:23   Re: [Editor?] AMXXPawn Language Service for Visual Studio Code
Reply With Quote #10

KliPPy,
I mean support of relative paths or special variable for project directory.

For example:

PHP Code:
amxxpawn.compiler.includePaths: [
    
"${project_dir}/compiler/include"
    "
${project_dir}/src/include"

or

PHP Code:
amxxpawn.compiler.includePaths: [
    
"compiler/include"
    "src/include"

So, if compiler/include directory exists in current project then load include from this directory.
__________________


[CS] Halloween Mod - This is a completely new gamemode for Halloween Holidays.

[CS] Custom Entities API - API to register custom entities. It's provides some new and more comfortable architecture for complex projects.

Hedgehog95 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:27.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode