Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.
/ dnh Public archive

Touhou Danmakufu extension for Visual Studio Code

License

Notifications You must be signed in to change notification settings

imtbl/dnh

Repository files navigation

Touhou Danmakufu extension for Visual Studio Code

Syntax highlighting example

This is a simple Visual Studio Code extension that adds some features to make developing Touhou Danmakufu scripts more comfortable. It currently features:

  • Syntax highlighting
  • Code completion for ph3 engine library functions, headers, routines and shot/item data
  • On-Demand documentation for ph3 engine library functions, headers, routines and shot/item data (on hover)
  • A variety of useful snippets

Table of contents

Install

Use Quick Open ( P on macOS, P on Windows/Linux) and run ext install dnh or search and install it via the Extensions tab manually.

Updating

VS Code should try to auto-update the extension at regular intervals, but you can also check for available updates manually via Extensions: Check for Updates.

Usage

Opening .dnh files with VS Code should automatically set the correct syntax highlighting and enable code completion, documentation and snippets, but you can also set it manually via Change Language Mode (e.g., for .txt files where VS Code would default to plain text without highlighting).

Completion

Code completion is currently available for ph3 engine library functions, headers, routines and shot/item data. The completion system is triggered simply by typing and will automatically try to match the most relevant result from the list. You can also navigate the list with and select a completion to use.

Hitting Tab ⇥ will insert the selected completion. Some completions (like functions) will have additional tab stops that allow you to navigate the inserted code with Tab ⇥. This is, for example, useful for function parameters.

Clicking on the icon displays more information about the completion while clicking on the icon hides this information again (depending on your settings, the info window might be opened by default).

Documentation

Documentation is available for the same types as completion (ph3 engine library functions, headers, routines and shot/item data). It comes in the form of info windows that are activated on hover and display similar information as when clicking on the icon on completion items.

Snippets

Snippets work in a similar way as completions. They are also activated automatically when typing and displayed in the same list as completion items. Instead of displaying documentation in an info window, they show the code they insert.

Selection and insertion also functions just like completions (with and Tab ⇥). Wherever necessary, snippets feature useful tab stops to make navigation easier after inserting them.

They do generally have a higher priority than completions, which means that you usually do not have to write the full keyword for VS Code to highlight the correct snippet in the list.

The following is a list of keywords that are associated to a snippet:

  • let
  • if
  • alternative
  • loop
  • while
  • ascent
  • local
  • yield (type y and hit Tab ⇥ instead of typing the full word)
  • function
  • task
  • include

Maintainer

mserajnik

Contribute

You are welcome to help out!

Open an issue or submit a pull request.

As an exception to the paragraph under License that mentions that you are not allowed to use the file server/src/dictionary/files/functions.json for your own software/projects:

You are hereby allowed to use this file for the purpose of contributing to this project. This includes forking this repository, making changes and creating pull requests for those changes. You are not allowed to fork this repository for intentions other than contributing (e.g, creating your own project without the intention to merge your changes back into upstream) without removing the file immediately afterwards.

Additionally, any fork of this project that is created under the purpose of contributing must include this section and the paragraph under License in an unaltered state to assure that no one that creates forks/copies of your fork or uses it or parts of it in their own software/projects is allowed to use server/src/dictionary/files/functions.json without permission.

License

MIT © Michael Serajnik

Explicitly excluded from the MIT license is the file server/src/dictionary/files/functions.json. It contains a parsed version of Sparen of Iría's ph3 function reference and requires you to get his permission to use it. The file is therefore under no license and you do not have permission to use it in your own software/projects.

Credits

The syntax configuration was originally created by drakeirving for his Sublime Text extension. I have merely converted his TextMate grammar file to JSON, made some VS Code-specific adjustments and expanded it a bit.

The built-in ph3 engine library function documentation is a parsed version of Sparen of Iría's ph3 function reference, for which he was so kind as to give me his permission to use it. The only thing I did was transforming it into a format that is easier for me to work with and applying some automatic text transformations.

If a function behaves differently than stated in this extension, please cross-reference with Sparen's ph3 function reference and the official Danmakufu ph3 documentation (Japanese, though Google Translate or other automatic translation services should work well enough in most cases) as they may be more up-to-date and/or contain fixes for errors.

Sparen's tutorials are brilliant and you should definitely check them out if you want to get into Danmakufu scripting.

The extension icon (of which you can also see a higher resolution version of at the top of this readme) is one of Alphes' Touhou portraits (free to use and edit for non-commercial projects). I have simply made it square and adjusted the size so it fits the VS Code Marketplace guidelines.