master
Alessandro Mauri 1 year ago
parent 745444b564
commit 713a9cde6a
  1. 6
      TODO.md
  2. 91
      src/comments.json
  3. 24
      src/extension.ts
  4. 1
      tsconfig.json

@ -0,0 +1,6 @@
[x] - in extensions.json add suffix for languages that require it such as css where comments are: /* stuff */
[] - test cancel token
[] - add fill in middle
[] - add config option to disable the extension
[] - add command to test and query connection to server
[] - add feedback when waiting response

@ -0,0 +1,91 @@
{
"ada": ["--", ""],
"agda": ["--", ""],
"alloy": ["//", ""],
"antlr": ["#", ""],
"applescript": ["--", ""],
"assembly": [";", ""],
"augeas": ["##", ""],
"awk": ["#", ""],
"batchfile": ["::", ""],
"bluespec": ["//", ""],
"c-sharp": ["///", ""],
"c": ["//", ""],
"clojure": [";;", ""],
"cmake": ["#", ""],
"coffeescript": ["#", ""],
"common-lisp": [";;;", ""],
"cpp": ["//", ""],
"css": ["/*", "*/"],
"cuda": ["//", ""],
"dart": ["//", ""],
"dockerfile": ["#", ""],
"elixir": ["#", ""],
"elm": ["--", ""],
"emacs-lisp": [";;;", ""],
"erlang": ["%", ""],
"f-sharp": ["//", ""],
"fortran": ["!", ""],
"glsl": ["//", ""],
"go": ["//", ""],
"groovy": ["//", ""],
"haskell": ["--", ""],
"html": ["<!--", "-->"],
"idris": ["|||", ""],
"isabelle": ["--", ""],
"java-server-pages": ["<%--", "--%>"],
"java": ["//", ""],
"javascript": ["//", ""],
"json": ["\"comment\":\"", "\","],
"julia": ["#", ""],
"jupyter-notebook": ["#", ""],
"kotlin": ["//", ""],
"lean": ["/--", "-/"],
"literate-agda": ["--", ""],
"literate-coffeescript": ["#", ""],
"literate-haskell": ["--", ""],
"lua": ["--", ""],
"makefile": ["#", ""],
"maple": ["#", ""],
"markdown": ["<!---", "-->"],
"mathematica": ["(*", "*)"],
"matlab": ["%", ""],
"ocaml": ["(*", "*)"],
"pascal": ["(*", "*)"],
"perl": ["#", ""],
"php": ["//", ""],
"powershell": ["#", ""],
"prolog": ["/*", "*/"],
"protocol-buffer": ["//", ""],
"python": ["#", ""],
"r": ["#", ""],
"racket": [";", ""],
"restructuredtext": [".. ", ""],
"rmarkdown": ["<!--", "-->"],
"ruby": ["#", ""],
"rust": ["//", ""],
"sas": ["/*", "*/"],
"scala": ["//", ""],
"scheme": [";", ""],
"shell": ["#", ""],
"smalltalk": ["\"", "\""],
"solidity": ["//", ""],
"sparql": ["#", ""],
"sql": ["--", ""],
"stan": ["//", ""],
"standard-ml": ["(*", "*)"],
"stata": ["//", ""],
"systemverilog": ["//", ""],
"tcl": ["#", ""],
"tcsh": [": ", ""],
"tex": ["%", ""],
"thrift": ["//", ""],
"typescript": ["//", ""],
"verilog": ["//", ""],
"vhdl": ["--", ""],
"visual-basic": ["'", ""],
"xslt": ["<xsl:comment>", "</xsl:comment>"],
"yacc": ["//", ""],
"yaml": ["#", ""],
"zig": ["//", ""]
}

@ -1,5 +1,6 @@
import { ok } from 'assert';
import * as vscode from 'vscode';
import commentPrefix from './comments.json';
// llama.cpp server response format
@ -92,22 +93,13 @@ export function activate(cotext: vscode.ExtensionContext) {
//doc_after = doc_before.replace(/\s+/gm, " ");
// prefix commented filename, is this the best way?
var comment_prefix: string = '';
switch (document.languageId) {
case 'c':
case 'js':
case 'ts':
comment_prefix = '//';
break;
case 'sh':
case 'bash':
case 'zsh':
case 'py':
case 'python':
comment_prefix = '#';
break;
}
doc_before = comment_prefix + ' ' + document.fileName + '\n' + doc_before;
var pfx: string = '';
var sfx: string = '';
const lang = document.languageId;
const prefixes = commentPrefix;
pfx = (prefixes as any)[lang][0] as string;
sfx = (prefixes as any)[lang][1] as string;
doc_before = pfx + ' ' + document.fileName + sfx + '\n' + doc_before;
// server request object
const request = {

@ -3,6 +3,7 @@
"module": "Node16",
"target": "ES2022",
"outDir": "out",
"resolveJsonModule": true,
"lib": [
"ES2022"
],

Loading…
Cancel
Save