Full language support for Visual Prolog 5.2 in Visual Studio Code, including syntax highlighting, code snippets, and IntelliSense features.
- Directives: domains,predicates,clauses,goal,facts,database,constants
- Class/Object-Oriented Keywords: class,object,interface,implement,end class,end object
- Control Flow: if,then,else,elseif,not,fail,true,and,or,repeat,cut
- Modifiers: determ,nondeterm,multi,procedure,single,static,abstract,virtual,override,final
- Built-in Types: char,byte,short,ushort,word,integer,unsigned,long,ulong,dword,real,real4,real8,string,symbol,pointer,binary,file
- Built-in Predicates: write,read,assert,retract,findall,member,append,concat, and many more
- Operators: Arithmetic (+,-,*,/,mod,div), Comparison (=,<>,<,>,<=,>=), Logical (and,or,not), Bitwise (shl,shr,xor)
Type the prefix and press Tab to expand:
program - Full program template
% Program Name
% Description
domains
    DomainName = type
predicates
    predicateName(arguments)
clauses
    predicateName(Args) :-
        body.
goal
    predicateName(actualArgs).domain - Domain declaration
domains
    DomainName = typepredicate - Predicate declaration
predicates
    predicateName(arguments)clause - Clause definition
clauses
    predicateName(Args) :-
        body.goal - Goal section
goal
    goalPredicate.class - Class declaration
class ClassName
predicates
    predicateName(arguments)
clauses
    predicateName(Args) :-
        body.
end class ClassNameinterface - Interface declaration
interface InterfaceName
predicates
    predicateName(arguments)
end interface InterfaceNameimplement - Implementation section
implement ClassName
clauses
    predicateName(Args) :-
        body.
end implement ClassNameif - If-then-else statement
if condition then
    thenBody
else
    elseBody
end ifdeterm - Deterministic predicate
predicates
    determ predicateName(arguments)nondeterm - Non-deterministic predicate
predicates
    nondeterm predicateName(arguments)database - Database section
database
    databaseName
predicates
    predicateName(arguments)fact - Fact declaration
facts
    factName(arguments)assert - Assert clause
assert(fact)retract - Retract clause
retract(fact)findall - Find all solutions
findall(Template, Goal, ResultList)write - Write output
write(output)read - Read input
read(variable)openread - Open file for reading
openread(FileName, FileHandle)openwrite - Open file for writing
openwrite(FileName, FileHandle)list - List pattern
[Head|Tail]member - Member check
member(Element, List)append - Append lists
append(List1, List2, Result)concat - String concatenation
concat(String1, String2, Result)- Auto-closing pairs: Automatically closes (),[],{}, and""
- Comment toggling: Use Cmd+/(macOS) orCtrl+/(Windows/Linux) to toggle line comments (%)
- Block comments: Select code and use comment shortcut for multi-line comments (/* */)
- Bracket matching: Highlights matching brackets, parentheses, and braces
- Smart indentation: Proper indentation for Visual Prolog code structure
- Types/Domains: Names starting with uppercase letters are highlighted as types (e.g., Person,StudentList)
- Predicates/Functions: Names starting with lowercase letters are highlighted as predicates (e.g., factorial,processData)
- Variables: Uppercase identifiers in code are recognized as variables
- Atoms: Lowercase identifiers are recognized as atoms/constants
- .pro- Visual Prolog program files
- .cl- Clause files
- .pack- Package files
- .ph- Prolog header files
Type program and Tab to get the template, then modify:
% Factorial Calculator
% Calculates factorial of a number
domains
    Number = integer
predicates
    factorial(Number, Number)
clauses
    factorial(0, 1) :- !.
    factorial(N, Result) :-
        N > 0,
        N1 = N - 1,
        factorial(N1, R1),
        Result = N * R1.
goal
    factorial(5, X),
    write("Factorial of 5 is: ", X),
    nl.% List Processing Example
domains
    IntList = integer*
predicates
    sumList(IntList, integer)
    member(integer, IntList)
clauses
    sumList([], 0).
    sumList([H|T], Sum) :-
        sumList(T, RestSum),
        Sum = H + RestSum.
    
    member(X, [X|_]).
    member(X, [_|T]) :-
        member(X, T).
goal
    List = [1, 2, 3, 4, 5],
    sumList(List, Total),
    write("Sum: ", Total), nl.Type class and Tab:
class Student
domains
    Name = string
    Age = integer
    
predicates
    create(Name, Age)
    displayInfo()
    
clauses
    StudentName : Name
    StudentAge : Age
    
    create(N, A) :-
        StudentName := N,
        StudentAge := A.
    
    displayInfo() :-
        write("Name: ", StudentName), nl,
        write("Age: ", StudentAge), nl.
end class Student
goal
    S = Student::new(),
    S:create("John Doe", 20),
    S:displayInfo().Type database and Tab:
database
    phoneBook
predicates
    nondeterm phone(string, string)
    addPhone(string, string)
    findPhone(string)
clauses
    addPhone(Name, Number) :-
        assertz(phone(Name, Number)).
    
    findPhone(Name) :-
        phone(Name, Number),
        write(Name, ": ", Number), nl,
        fail.
    findPhone(_).
goal
    addPhone("Alice", "555-1234"),
    addPhone("Bob", "555-5678"),
    findPhone("Alice").- Visual Studio Code version 1.50.0 or higher
- Visual Prolog 5.2 compiler (for running programs)
- Download the .vsixfile
- Open VS Code
- Go to Extensions (Cmd+Shift+XorCtrl+Shift+X)
- Click on the ...menu at the top
- Select "Install from VSIX..."
- Choose the downloaded file
- Clone or download this repository
- Copy the folder to your VS Code extensions directory:
- Windows: %USERPROFILE%\.vscode\extensions
- macOS/Linux: ~/.vscode/extensions
 
- Windows: 
- Restart VS Code
- Type the snippet prefix and press Tabto expand
- Use Ctrl+Spaceto see all available snippets for Visual Prolog
- Cmd+Shift+O(macOS) or- Ctrl+Shift+O(Windows/Linux) - Go to symbol in file
- F12- Go to definition (when supported by workspace indexing)
- Cmd+/or- Ctrl+/- Toggle line comment (- %)
- Shift+Option+A(macOS) or- Shift+Alt+A(Windows/Linux) - Toggle block comment (- /* */)
- Option+Click(macOS) or- Alt+Click(Windows/Linux) - Add cursor
- Useful for editing multiple similar predicates at once
- Semantic analysis and IntelliSense are limited to syntax highlighting
- Go to Definition requires manual workspace symbol indexing
- No integrated compiler/debugger (use external Visual Prolog tools)
Initial release of Visual Prolog Language Support:
- Complete syntax highlighting for Visual Prolog 5.2
- 25+ code snippets for common patterns
- Auto-closing pairs and bracket matching
- Support for .pro,.cl,.pack, and.phfiles
- Comment toggling with standard VS Code shortcuts
Found a bug or have a feature request? Please open an issue on the repository.
MIT License - see LICENSE file for details
Enjoy coding in Visual Prolog! π