Giter Club home page Giter Club logo

vscode-language-pascal's Introduction


Pascal Logo

What's new in Pascal 9.8

  • Published to Open VSX
  • Improves Syntax Highlighting support for FreePascal and Oxygene
  • Adds Web support
  • Adds Getting Started / Walkthrough

Support

Pascal is an open source extension created for Visual Studio Code. While being free and open source, if you find it useful, please consider supporting it

Pascal

It adds support for the Pascal language and its dialects like Delphi and FreePascal.

Here are some of the features that Pascal provides:

  • Syntax highlighting for files, forms and projects
  • A huge set of Snippets
  • Source code navigation

Features

Coding with style

Syntax Highlighting

Pascal supports full syntax highlighting for Delphi and FreePascal

syntax

Snippets

Almost 40 snippets are available

snippets

Format Code

Check out Pascal Formatter documentation.

Code Navigation

Navigate to any language element (methods, attributes, classes, interfaces, and so on) inside Pascal files. It supports native VS Code commands like:

  • Go to Symbol
  • Go to Definition
  • Peek Definition
  • Find All References

It uses GNU Global, a source code tagging system, which means that it has some limitations if you compare with an AST parsing.

Installing and Configuring GNU Global

  1. You have to install 4 tools:
  1. Update your %PATH% Environment Variable (System)

Let's say you extract GNU Global and CTags in C:\gnu folder. The two new entries in %PATH% should be:

  • GNU Global: C:\gnu\glo653wb\bin
  • Excuberant Tags: C:\gnu\ctags58\ctags58

Also make sure Python is in %PATH%

  1. Create 2 new Environment Variables (System)

GNU Global uses CTags + Python Pygments as plugin in order to recognizes Pascal source code, so you have to configure them.

  • GTAGSCONF: C:\gnu\glo653wb\share\gtags\gtags.conf
  • GTAGSLABEL: pygments

py-envvar

NOTE: For now, it was tested only on Windows, but since these tools are multiplatform (in fact, it comes from Unix), it should work on Linux and Mac.

Available commands

Code Navigation

To enable Code Navigation, the extension depends on GNU Global and Exuberant Tags and for that, you must run gtags on the Root folder, so the tags are created. In order to make life easier, two commands where added:

  • Pascal: Generate Tags: Use this to create or reset the tags in the current project. You just have to do it once.
  • Pascal: Update Tags: Use this to update the tags for current project. You should use this command to update the references when any source code is updated.

Available Settings

Controls how the code navigation should work. Specially useful if you work with huge projects

  • workspace: Full featured code navigation
  • file: Limited to Go to Symbol in File command
    "pascal.codeNavigation": "workspace"
  • Controls if the extension should automatically generate tags in projects opened for the first time
    "pascal.tags.autoGenerate": true

For huge projects, its recommended to use:

    "pascal.codeNavigation": "file",
    "pascal.tags.autoGenerate": false

Task Build

Use this Task Examples, so you can:

  • Compile Delphi and FreePascal projects:
  • Navigate to Errors/Warnings/Hints, using the native View / Errors and Warnings command

compile

Building Tasks

If you want to build tasks (Task: Run Task Build) you can use the snippets below.

Delphi

Update two tags:

  • DCC32.EXE_PATH: The compiler location
  • YOUR_DELPHI_PROJECT.DPR: The project being built.
   "version": "2.0.0",
   "tasks": [
      {
         "label": "Pascal",
         "type": "shell",
         "windows": {
            "command": "DCC32.EXE_PATH"
         },
         "linux": {
            "command": "FPC_BIN_PATH"
         },
         "presentation": {
            "reveal": "always",
            "panel": "new"
         },
         "args": [
            {
               "value": ""YOUR_DELPHI_PROJECT.DPR"",
               "quoting": "escape"
            }
         ],
         "problemMatcher": {
            "owner": "external",
            "pattern": {
               "regexp": "^(.*.(pas|dpr|dpk))\\((\\d+)\\)\\s(Fatal|Error|Warning|Hint):(.*)",
               "file": 1,
               "location": 3,
               "message": 5
            }
         },
         "group": {
            "kind": "build",
            "isDefault": true
         }
      }
   ]

FreePascal

Update two tags:

  • FPC_BIN_PATH: The full compiler location. If its PATH is already in Environment Variables, simply use FPC_BIN filename
  • YOUR_FREEPASCAL_PROJECT_OR_FILE: The project/file being built.

{
   "version": "2.0.0",
   "tasks": [
      {
         "label": "Pascal",
         "type": "shell",
         "windows": {
            "command": "FPC_BIN_PATH"
         },
         "linux": {
            "command": "FPC_BIN_PATH"
         },
         "presentation": {
            "reveal": "always",
            "panel": "new"
         },
         "args": [
            {
               "value": "YOUR_FREEPASCAL_PROJECT_OR_FILE",
               "quoting": "escape"
            }
         ],
         "problemMatcher": {
            "owner": "external",
            "pattern": {
               "regexp": "^([\\w]+\\.(p|pp|pas))\\((\\d+)\\,(\\d+)\\)\\s(Fatal|Error|Warning|Note):(.*)",
               "file": 1,
               "line": 3,
               "column": 4,
               "message": 6
            }
         },
         "group": {
            "kind": "build",
            "isDefault": true
         }
      }
   ]
}

Contributors

Special thanks to the people that have contributed to the project:

  • Midas (Wither) (@TheWitheredStriker) - Missing keywords from FreePascal and Oxygene (see PR)
  • creativelaides (@creativelaides) - Task upgrade (see PR)
  • space (@SpaceEEC) - Fixed parentesis in snippet (see PR)
  • AnsonYeung (@AnsonYeung) - Fixed autocomplete in snippet (see PR)
  • AnsonYeung (@AnsonYeung) - Added .lpr file extension support (see PR)
  • Jonathan Carter (@lostintangent) - Support Live Share (see PR)
  • Jan T. Sott (@idleberg) - Fixed escape in snippet (see PR)
  • Wade Anderson (@waderyan) - Updated marketplace category (see PR)

Also thanks to everyone who helped opening issues with ideas and bug reports.

License

MIT © Alessandro Fragnani

vscode-language-pascal's People

Contributors

alefragnani avatar ansonyeung avatar bero1985 avatar creativelaides avatar dependabot[bot] avatar idleberg avatar lostintangent avatar robdaemon avatar spaceeec avatar thewitheredstriker avatar wade-ryan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-language-pascal's Issues

read iss files?

Hi,

I'm using inno setup and I'd love to edit the files in code with fun colors. How do I get your pascal tool to recognize iss files?

Formatter issues on 0.3.0

Two issues with the initial release:

  1. The parameters are not available (package.json error)
  2. The JCF formatter is running for folders by default. (It should be forced to files -F )

Add Telemetry

The idea is to have telemetry for things like:

  • most executed commands - to understand how many commands are useless
  • common user settings - to understand if any setting should have its default value changed
  • activity bar usage - to understand if it was a good idea to create that UI
  • context menu usage - to understand how many commands are useless
  • OS platform - to know if my Windows machine is enough

Better messages when some error occurs while formatting code

When an error occurs while formatting code, specially when using Jedi Code Format, the message displayed does not say much information. Mostly because the showErrorMessage API only displayes one line.

Find a way to display the console error so the user can detect what has happened, without needing to look at the Developer Tool / Console.

The filename, directory name, or volume label syntax is incorrect.

I created the tasks.json but when i try to Run Task Build I get "The filename, directory name, or volume label syntax is incorrect."

"command": "‪C:\FPC\3.0.2\bin\i386-win32\fpc.exe"

"args": ["‪C:\Users\me\Desktop\helloworld.pas"]

Is maybe something wrong with my paths?

Update grammar based on Monaco Language PR

While developing the PR to add Pascal support in Monaco Editor, I have noted some errors in the current grammar. Also, a few updates could be made to add new features recently added in VS Code.

News Features / Updates

  • Add code folding for $REGION
  • Add < > as AutoClosingPair and SurroundingPairs
  • Add "hex" as a new identifier for numbers
  • Add #number as a valid string pattern

Fixes

  • Remove " (doublequotes) as AutoClosingPair and SurroundingPairs
  • 0x is not a valid number pattern
  • -- is not a valid line comment pattern (like previoulsy fixed in Atom)
  • "..." (doublequotes) is not a valid string pattern

Cannot run gtags on Mac OS X

I installed everything by Homebrew. the environmental variables are set as below:
declare -x GTAGSCONF="/usr/local/Cellar/global/6.5.7/share/gtags/gtags.conf" declare -x GTAGSLABEL="pygments"
declare -x PATH="/usr/local/Cellar/global/6.5.7/bin:/usr/local/Cellar/ctags/5.8_1:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" declare -x PWD="/Users/Administrator/Documents/Pascal"
but when I run the gtag command, the result was less than satisfactory:
Traceback (most recent call last): File "/usr/local/Cellar/global/6.5.7/share/gtags/script/pygments_parser.py", line 27, in <module> import pygments.lexers ImportError: No module named pygments.lexers gtags: unexpected EOF.

So what causes this problem? Is that about the operating system I used? Is there any way to fix it?

gtags: directory '' not found

After installing dependencies (GNU Global, ctags, gtags, python and pygments), reloading everything and editing *.pas, I keep getting following error in VSC:

Some error occured: Error: Command failed: gtags 
gtags: directory '' not found.

Consequently, I cannot harness extension's code navigation.

OS: Ubuntu 20.04 (Linux x64 5.4.0-31-generic)
Visual Studio Code: 1.45.1

Build tasks automation

Instead of copy/pasting the same build tasks into tasks.json for every pascal project folder that a user has, have you found any way to automate the process?
For example: A user has a fully functional build script that points to DCC32.exe, is there a way for the extension to automatically create a tasks.json with those parameters to each created pascal project?

Got troubles in configuring

Hey, i got some troubles in configuring the run build task in the tasks.json file, can you please give an example for it, or may be a tutorial video for it? Maybe you could also make the whole installation tutorial if you want to.
Also, i can't seem to configure debugging for it, any help please?
Thanks

Problem in Task building and Tags settings

First,I don't know what does 'update two tags' exactly mean. What should I do to update it? Is that correct to create two new files?
Also, when i run the command Pascal:Generate Tagsin VS Code ,it returnsSome error occured: Error: Command failed: gtags . But when I run gtags in Terminal in the root folder, it works fine and creates three new files in the folder. So is that a bug?
When I run Pascal:update Tags in VS Code, it returnsThe tags where updated. I was confused.I do not even understand what that means.
And, it seems that I cannot 'Peek Defination' although you added that feature in README. The software returns 'Defination not found.'
So would you tell me what exactly should I do to debug and run Pascal project in VS Code? And how to enable code navigation?Thanks

Adopt VS Code's 'asWebviewUri' API

Hi, I maintain VS Code's Webview API

Issue

Our telemetry suggests that your extension uses webviews and may be loading resources in these webviews using hardcoded vscode-resource: URIs. These URIs have some important limitations and don't work properly when VS Code is run in a browser. We are also making changes in the desktop version of VS Code that may cause these URIs to not work properly in future versions of VS Code.

While we are making our best effort to continue support existing webview extensions that use vscode-resource: URIs on desktop versions of VS Code, we will not able to fully support all uses cases.

Fix

To ensure that your extension continues to work in as many environments as possible—including on web and remotely—please:

These APIs shipped around 2 years ago so they should be available in all modern versions of VS Code. You can find additional information about the issue here: microsoft/vscode#97962

Let me know if you have any questions about this change

Block Comments

All of the block comment controls don't operate, (default ctrl + /).
Any chance we could get that fixed?

Add Linux support to the FreePascal task snippet

Please add this code to tasks.json snippet for FreePascal so it can be used in Linux:

 		"windows": {
 			"command": "FPC.EXE_PATH"
 		},
+		"linux": {
+			"command": "fpc"
+		},

And maybe change "args": ["YOUR_FREEPASCAL_PROJECT"] to the "args": ["${relativeFile}"] so the task will compile the current opened file?

Extension issue

  • Issue Type: Bug
  • Extension Name: pascal
  • Extension Version: 8.0.2
  • OS Version: Linux x64 5.0.0-26-lowlatency
  • VSCode version: 1.35.0

⚠️ We have written the needed data into your clipboard. Please paste! ⚠️

{
	"messages": [],
	"activationTimes": {
		"startup": true,
		"codeLoadingTime": 10,
		"activateCallTime": 1,
		"activateResolvedTime": 163,
		"activationEvent": "*"
	},
	"runtimeErrors": []
}

Unable to compile project

Hi! I forked you project to make a support for «Component Pascal» aka «BlackBoxComponentBuilder».
Actually I have a syntax highlight working already, but due to its dynamic nature blackbox allows to do interesting things like dynamic completion from RTTI and so on. This is in a far future...
Meanwhile It looks like you forgot to add some files to git, like src/whats-new/* and vscode-whats-new/*

Now trying to disable all references to missing files...

Enhance Language Features

Increase the support other Programmatic Language Features available in VS Code, which makes IntelliSense experience so great.

Currently, the extension only supports a few set of features:

There are another set of features which would make the coding experience even richer.

More info:

There should be a way to disable update popup

When the extension updates, it opens a popup to tell you what is new. Most extensions don't do that. You should either disable the update popup, or add a way to optionally disable it.

No symbols found

Hi! I have an issue with symbols navigation and I am not sure whether this is configuration or something with the extension: I have configured global (with ctags, pygments etc.) and it seems to be working correctly. I can see the symbols table is building correctly (e.g. with gtags -v --explain) and dump symbols (e.g. with gtags -d GRTAGS) but they do not appear in any of VSCodes lists: that is when I press Ctrl+T (#) or Ctrl+P (@) etc.

Am I doing something wrong? Is there anything else I can test to determine whether something is wrong with my configuration or is it something with the extension?

Debug?

Does debug work with FPC?

Adding syntax highlighting

Hi! Can I define a new syntax highlighting?
Or is there a file in your extension that holds the highlighted syntax?

Update Syntax definitions

Better syntax definitions

  • basic types
  • hexa values
  • includes
  • properties
  • modifiers
  • operators
  • flow control

Breakpoints totally disabled?

I'm testing Visual Studio Code now (1.21.1 for Mac) and got it working just fine using C++ (debugging, building, breakpoints). Now I'm trying to setup a Pascal project using the extension "Language Pascal" but breakpoints seem to be entirely disabled, i.e. clicking in gutter doesn't toggle anything, "Debug > Toggle Breakpoint" menu doesn't work either (nothing is added in the breakpoints pane).

Is this a bug or does the extension have to explicitly opt into breakpoints? Creating a new empty file has breakpoints disabled also so maybe I'm missing something.

Sorry if this is a bad place to ask questions but I didn't know where else to go. Thanks in advance.

Problems with autocompletion

Some of the auto complete does not work well.

Example:
When I type
if ... then
Then I pressed enter, the enter key will be eaten.
What I want is skip to the next line with indent.
This only happens when I pressed the enter key second time.

Besides, the snippet of begin...end is bad.
It inserts two position, one between begin end and one after the end keyword.
However, when I type code between begin end, the auto complete function will not work at all. There will be no hint at all.

Also, can you make a option to capitalize the first letter of keywords?
For example, when I type "if" then pressed space, the "if" keyword will become "If"

Lastly, it will be good if the main begin end will be automatically insert the dot instead of a semicolon.

Improve code navigation

Since gtags fails to work well for huge projects when all features are requested (Declarations and References), there should be a way to still use at least for Go to Symbols in File, as it was used at the beginning of the projects.

Let's create a setting for that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.