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

How to configure default/additional code? #155

Closed
dhruvppatel opened this issue Jun 6, 2019 · 6 comments
Closed

How to configure default/additional code? #155

dhruvppatel opened this issue Jun 6, 2019 · 6 comments
Labels

Comments

@dhruvppatel
Copy link

Big Thanks to TypeFox, Palantir and Microsoft team for building an ecosystem around Language Server Protocol for Monaco Editor.

We are building a cloud-based interactive learning platform primarily focused on Data Science Technologies. We are using Monaco Editor in our web application for online coding environment.

Currently, we are trying to integrate autocomplete capabilities in Monaco Editor with remote Python Language Server. With the help of opensource projects monaco-languageclient and python-language-server we were able to achieve the same.

Our application is designed for incremental learning through tasks. Learners attempt each task at a time by writing code in a Monaco Editor.

So while the learner is attempting Task2 we would like to support autocomplete for the modules and variables declared in Task1. Code of the previous tasks are not included in the editor of the current task and we have a separate provision to view the code of previous tasks for reference.

Task2 editor doesn't contain code of Task1.

Is there any way to handle such a scenario by providing additional/default code while initializing language client?

We are looking for a solution where we can configure default code which is not visible in editor but should be considered for autocomplete and other features.

Do let us know your thoughts and possibilities to achieve the same.

@dhruvppatel dhruvppatel changed the title How to configure default/additional code How to configure default/additional code? Jun 6, 2019
@rcjsuen
Copy link
Collaborator

rcjsuen commented Jun 7, 2019

@dhruvppatel Language servers are initialized with a rootUri (or the deprecated rootPath). It sounds to me like you want to initialize the Python language server with a rootUri that includes the student's other Python files...?

@dhruvppatel
Copy link
Author

dhruvppatel commented Jun 7, 2019

Yes in a way @rcjsuen. I have a code which I want Language server to include before it loads code from current editor instance.

@rcjsuen
Copy link
Collaborator

rcjsuen commented Jun 7, 2019

@dhruvppatel So it sounds like you need to investigate how the Python language server determines what's on its path and then see how you can structure your students' files on the server so that the language server is able to read those.

@dhruvppatel
Copy link
Author

dhruvppatel commented Jun 12, 2019

@rcjsuen Python Language Server does not contain code as a file on that server. Learner code stays in the database and we load the piece of code in the browser and initiate Monaco editor. We have done POC using Monaco Language Client(by TypeFox) and it's working fine for the editor instance.

We would like to use Monaco Language Client to send extra code at the time of initialization which is not present in the current editor instance but should be considered for Language Server Features.

Example: Let's say we need to teach python dict data structure and assignment is divided into two tasks.

Task1 Instruction:
Create a dict countries with country code as a key and value should have name and capital.

Sample Learner code for Task1:

countries = {
	'IN' : {
		'name': 'India',
		'capital': 'Delhi'
	},
	'US' : {
		'name': 'United States',
		'capital': 'Washington D.C.'
	},
	'AU' : {
		'name': 'Australia',
		'capital': 'Canberra'
	}
}

Task2 Instruction:
Iterate over a countries dict and display country information in the format of {name} - {capital}.

Sample Learner code for Task2:

for code,info in countries.items():
	print(info.name,'-',info.capital)

We initialize Monaco editor with the code of the current task in the browser. So while the learner is attempting Task2 editor is initially empty(learner can see the code of previous tasks separately which are not editable from current task screen). We would like to enable language server functionality for Task2 which should also include a code of Task1 for providing autocomplete.

Is there any provision where I can pass the code of Task1 as initial code(which is not in the current editor) to Monaco Language Client which then communicate to language server and also consider that code for functionalities like autocomplete. Leaner should see methods of dict when they type countries. in the Task2 editor.

@rcjsuen
Copy link
Collaborator

rcjsuen commented Jun 12, 2019

@dhruvppatel I don't think you have much of a choice here. It sounds like you should refer to microsoft/monaco-editor#45 if you want to hide pieces of your code.

@stale
Copy link

stale bot commented Aug 11, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 11, 2019
@stale stale bot closed this as completed Aug 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants