Compare commits

...

2 Commits

Author SHA1 Message Date
SimonFJ20
86f26b0f91 add vscode syntax 2023-03-16 14:54:52 +01:00
SimonFJ20
13ff4d49cd add vim syntax 2023-03-16 14:07:56 +01:00
14 changed files with 463 additions and 0 deletions

View File

@ -0,0 +1,6 @@
# make sure to run this in repository root directory
rm -r ~/.vscode-oss/extensions/couch
cp -r editors/vscode ~/.vscode-oss/extensions/couch

View File

@ -0,0 +1,6 @@
# make sure to run this in repository root directory
rm -r ~/.vscode/extensions/couch
cp -r editors/vscode ~/.vscode/extensions/couch

View File

@ -0,0 +1 @@
au BufRead,BufNewFile *.chl set filetype=chl

View File

@ -0,0 +1,30 @@
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
if (!has("cindent") || !has("eval"))
finish
endif
setlocal cindent
" L0 -> 0 indent for jump labels (i.e. case statement in c).
" j1 -> indenting for "javascript object declarations"
" J1 -> see j1
" w1 -> starting a new line with `(` at the same indent as `(`
" m1 -> if `)` starts a line, match its indent with the first char of its
" matching `(` line
" (s -> use one indent, when starting a new line after a trailing `(`
setlocal cinoptions=L0,m1,(s,j1,J1,l1
" cinkeys: controls what keys trigger indent formatting
" 0{ -> {
" 0} -> }
" 0) -> )
" 0] -> ]
" !^F -> make CTRL-F (^F) reindent the current line when typed
" o -> when <CR> or `o` is used
" O -> when the `O` command is used
setlocal cinkeys=0{,0},0),0],!^F,o,O

102
editors/vim/syntax/chl.vim Normal file
View File

@ -0,0 +1,102 @@
" Vim syntax file
" Language: Couch Lang
" Maintainer: Simon From Jakobsen
" Latest Revision: 1 January 1970
if exists("b:current_syntax")
finish
endif
let s:cpo_save = &cpo
set cpo&vim
let s:chl_syntax_keywords = {
\ 'chlConditional' :["if"
\ , "else"
\ , "match"
\ , ]
\ , 'chlRepeat' :["while"
\ , "for"
\ , ]
\ , 'chlExecution' :["return"
\ , "break"
\ , "continue"
\ , ]
\ , 'chlBoolean' :["true"
\ , "false"
\ , ]
\ , 'chlKeyword' :["fn"
\ , ]
\ , 'chlWordOperator' :["not"
\ , "and"
\ , "or"
\ , "as"
\ , "in"
\ , ]
\ , 'chlVarDecl' :["mut"
\ , "let"
\ , ]
\ , }
function! s:syntax_keyword(dict)
for key in keys(a:dict)
execute 'syntax keyword' key join(a:dict[key], ' ')
endfor
endfunction
call s:syntax_keyword(s:chl_syntax_keywords)
syntax match chlDecNumber display "\v<\d%(_?\d)*"
syntax match chlHexNumber display "\v<0x\x%(_?\x)*"
syntax match chlFatArrowOperator display "\V=>"
syntax match chlRangeOperator display "\V.."
syntax match chlOperator display "\V\[-+/*=^&?|!><%~:;,]"
syntax match chlFunction /\w\+\s*(/me=e-1,he=e-1
syntax region chlBlock start="{" end="}" transparent fold
syntax region chlCommentLine start="//" end="$" contains=chlTodo
syntax region chlCommentBlock matchgroup=chlCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=chlTodo,chlCommentBlockNest
syntax region chlCommentBlockNest matchgroup=chlCommentBlock start="/\*" end="\*/" contains=chlTodo,chlCommentBlockNest contained transparent
syntax keyword chlTodo contained TODO FIXME XXX NB NOTE SAFETY
syntax region chlString matchgroup=chlStringDelimiter start=+"+ skip=+\\\\\|\\"+ end=+"+ oneline contains=chlEscape
syntax match chlEscape display contained /\\./
highlight default link chlDecNumber chlNumber
highlight default link chlHexNumber chlNumber
highlight default link chlWordOperator chlOperator
highlight default link chlFatArrowOperator chlOperator
highlight default link chlRangeOperator chlOperator
highlight default link chlKeyword Keyword
highlight default link chlCommentLine Comment
highlight default link chlCommentBlock Comment
highlight default link chlString String
highlight default link chlStringDelimiter String
highlight default link chlChar String
highlight default link chlCharDelimiter String
highlight default link chlEscape Special
highlight default link chlBoolean Boolean
highlight default link chlConstant Constant
highlight default link chlNumber Number
highlight default link chlOperator Operator
highlight default link chlStructure Structure
highlight default link chlExecution Keyword
highlight default link chlConditional Conditional
highlight default link chlRepeat Repeat
highlight default link chlVarDecl Define
highlight default link chlFunction Function
delfunction s:syntax_keyword
let b:current_syntax = "chl"
let &cpo = s:cpo_save
unlet! s:cpo_save

17
editors/vscode/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,17 @@
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
}
]
}

View File

@ -0,0 +1,4 @@
.vscode/**
.vscode-test/**
.gitignore
vsc-extension-quickstart.md

View File

@ -0,0 +1,9 @@
# Change Log
All notable changes to the "couch" extension will be documented in this file.
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
## [Unreleased]
- Initial release

65
editors/vscode/README.md Normal file
View File

@ -0,0 +1,65 @@
# couch README
This is the README for your extension "couch". After writing up a brief description, we recommend including the following sections.
## Features
Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file.
For example if there is an image subfolder under your extension project workspace:
\!\[feature X\]\(images/feature-x.png\)
> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow.
## Requirements
If you have any requirements or dependencies, add a section describing those and how to install and configure them.
## Extension Settings
Include if your extension adds any VS Code settings through the `contributes.configuration` extension point.
For example:
This extension contributes the following settings:
* `myExtension.enable`: Enable/disable this extension.
* `myExtension.thing`: Set to `blah` to do something.
## Known Issues
Calling out known issues can help limit users opening duplicate issues against your extension.
## Release Notes
Users appreciate release notes as you update your extension.
### 1.0.0
Initial release of ...
### 1.0.1
Fixed issue #.
### 1.1.0
Added features X, Y, and Z.
---
## Working with Markdown
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux).
* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux).
* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets.
## For more information
* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)
**Enjoy!**

View File

@ -0,0 +1,30 @@
{
"comments": {
// symbol used for single line comment. Remove this entry if your language does not support line comments
"lineComment": "//",
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments
"blockComment": [ "/*", "*/" ]
},
// symbols used as brackets
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
// symbols that are auto closed when typing
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
// symbols that can be used to surround a selection
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}

View File

@ -0,0 +1,25 @@
{
"name": "couch",
"displayName": "couch",
"description": "Based programming language",
"version": "0.0.1",
"engines": {
"vscode": "^1.76.0"
},
"categories": [
"Programming Languages"
],
"contributes": {
"languages": [{
"id": "couch",
"aliases": ["couch", "couch"],
"extensions": [".chl"],
"configuration": "./language-configuration.json"
}],
"grammars": [{
"language": "couch",
"scopeName": "source.chl",
"path": "./syntaxes/couch.tmLanguage.json"
}]
}
}

View File

@ -0,0 +1,127 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "couch",
"patterns": [
{
"include": "#comments"
},
{
"include": "#keywords"
},
{
"include": "#numbers"
},
{
"include": "#strings"
},
{
"include": "#entity"
},
{
"include": "#constants"
},
{
"include": "#operator"
},
{
"include": "#punctuation"
},
{
"include": "#variable"
}
],
"repository": {
"comments": {
"patterns": [
{
"name": "comment.line.dansk",
"begin": "//",
"end": "\\n"
},
{
"name": "comment.block.dansk",
"begin": "/\\*",
"end": "\\*/"
}
]
},
"numbers": {
"patterns": [{
"name": "constant.numeric.couch",
"match": "\\b0|[1-9][0-9]*(\\.[0-9]+)?\\b"
}]
},
"keywords": {
"patterns": [{
"name": "keyword.control.couch",
"match": "\\b(if|else|match|while|for|return|break|continue|fn|not|and|or|as|in|mut|let)\\b"
}]
},
"strings": {
"name": "string.quoted.double.couch",
"begin": "\"",
"end": "\"",
"patterns": [
{
"name": "constant.character.escape.couch",
"match": "\\\\."
}
]
},
"entity": {
"patterns": [
{
"match": "(?>[a-zA-Z_](\\w+)?)\\s*(?=(?>\\:\\:<.*?>)?\\()",
"name": "entity.name.function.couch"
},
{
"match": "(?<=funktion\\s+)(?>[a-zA-Z_](\\w+)?)\\s*(?=(?><.*?>)?\\()",
"name": "entity.name.function.couch"
}
]
},
"constants": {
"patterns": [{
"name": "constant.language.couch",
"match": "\\b(false|true)\\b"
}]
},
"operator": {
"patterns": [
{
"match": "\\+=|-=|!=|<=|(?!\\-)>=|==|<|>|=|%|/|\\-(?!>)|\\+|\\.(?!\\.)",
"name": "keyword.operator.couch"
},
{
"match": "->|:|;|::",
"name": "keyword.operator.couch"
}
]
},
"punctuation": {
"patterns": [
{
"match": ";",
"name": "punctuation.terminator.statement.couch"
},
{
"match": ",",
"name": "punctuation.separator.delimiter.couch"
}
]
},
"variable": {
"patterns": [
{
"match": "(?>[a-z_]\\w*)\\s*(?=\\=)",
"name": "variable.other.assign.couch"
},
{
"match": "(?>[a-z_]\\w*)",
"name": "variable.other.couch"
}
]
}
},
"scopeName": "source.chl"
}

View File

@ -0,0 +1,29 @@
# Welcome to your VS Code Extension
## What's in the folder
* This folder contains all of the files necessary for your extension.
* `package.json` - this is the manifest file in which you declare your language support and define the location of the grammar file that has been copied into your extension.
* `syntaxes/couch.tmLanguage.json` - this is the Text mate grammar file that is used for tokenization.
* `language-configuration.json` - this is the language configuration, defining the tokens that are used for comments and brackets.
## Get up and running straight away
* Make sure the language configuration settings in `language-configuration.json` are accurate.
* Press `F5` to open a new window with your extension loaded.
* Create a new file with a file name suffix matching your language.
* Verify that syntax highlighting works and that the language configuration settings are working.
## Make changes
* You can relaunch the extension from the debug toolbar after making changes to the files listed above.
* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.
## Add more language features
* To add features such as IntelliSense, hovers and validators check out the VS Code extenders documentation at https://code.visualstudio.com/docs
## Install your extension
* To start using your extension with Visual Studio Code copy it into the `<user home>/.vscode/extensions` folder and restart Code.
* To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension.

12
test.chl Normal file
View File

@ -0,0 +1,12 @@
let a = 5;
if 1 == 0 and true {
return true;
}
// safadkjasda
/*
sdasd
*/