Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement suggestion: intellisense #1

Open
Nanobot567 opened this issue Feb 24, 2023 · 6 comments
Open

Enhancement suggestion: intellisense #1

Nanobot567 opened this issue Feb 24, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@Nanobot567
Copy link

You don't have to add this if you don't want to, I just thought it would be a nice addition to the extension :)

@TIny-Hacker TIny-Hacker added the enhancement New feature or request label Feb 24, 2023
@TIny-Hacker
Copy link
Owner

This is something I've already considered and would like to add in the future. However, I don't know much about how it works and how long it would take.

TIny-Hacker pushed a commit that referenced this issue Mar 8, 2023
Add snippets for "if", "while", "repeat", and "for" statements
@nineteendo
Copy link
Contributor

nineteendo commented Jan 28, 2024

Maybe this could be of help: http://github.com/nineteendo/tmlx/tree/main/Extension
This is a fairly simple syntax highlighter with code completion using a language server (doesn't work on temp files).
The suggestions are generated like this:

const suggestions = ['black', 'blue', 'color', 'cyan', 'green', 'magenta', 'red', 'white', 'yellow'].map<CompletionItem>(label => {
	return {
		label,
		kind: CompletionItemKind.Constant,
	};
}).concat(['down', 'left', 'right', 'up', 'write'].map(label => {
	return {
		label,
		kind: CompletionItemKind.Function,
	};
})).concat(['else', 'exit', 'goto', 'if', 'while'].map(label => {
	return {
		label,
		kind: CompletionItemKind.Keyword,
	};
}));

Result:
Screenshot 2024-01-28 at 13 42 53

Though we'll have to decide whether we use snippets for functions or not.

@nineteendo
Copy link
Contributor

Also, you should probably remove the lower case prefixes for the snippets:
Screenshot 2024-01-28 at 13 40 44

@nineteendo
Copy link
Contributor

nineteendo commented Jan 28, 2024

Here is a slightly fancier solution:

const suggestions = [
	{
		kind: CompletionItemKind.Operator,
		items: [
			{
				label: ' or ',
				detail: 'valueA or valueB'
			},
			{
				label: ' xor ',
				detail: 'valueA xor valueB'
			}
		]
	},
	{
		kind: CompletionItemKind.Function,
		items: [
			{
				label: 'Pt-On(',
				detail: 'Pt-On(x,y[,mark])'
			},
			{
				label: 'Pt-Off(',
				detail: 'Pt-Off(x,y[,mark])'
			}
		]
	}
].flatMap(group =>
	group.items.map(item => ({
		kind: group.kind,
		label: item.label,
		detail: item.detail
	}))
);
Screenshot 2024-01-28 at 15 26 33

Note that you don't have to provide the detail.

@nineteendo
Copy link
Contributor

Any updates?

@TIny-Hacker
Copy link
Owner

TIny-Hacker commented Feb 1, 2024

I'm currently pretty busy right now with other stuff and I'm working on importing / exporting in #4 as well, so this is lower priority. I'll make the change to the snippets but since I'm changing some token formats to match this I feel like it makes sense to wait to work on this until after that is done.

Thanks for providing the examples though, that will certainly come in handy when I get around to it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants