#1
by
Chris_oTree
Hello all, I have published a plugin for Visual Studio Code and Cursor to help you write oTree code. It provides comprehensive syntax highlighting and error checking for all aspects of oTree projects, from HTML templates to your __init__.py to settings.py. If you defined something invalid, it will tell you so. I highly recommend trying it out together with the AI model for writing oTree code: https://www.otreehub.com/forum/1377/. You might be impressed how much it can do. Recommendation: install Cursor (free version), set up the AI model linked above, then install the extension. The extensions marketplace is on the left side pane, with a "4 building blocks" icon. Search "oTree" or paste this URL in the search box: https://open-vsx.org/extension/otree/otree
#2
by
dwoods
Hi Chris, This is useful, thanks for implementing this. A few comments based on some usage, although I'm not sure how much of this is due to Cursor rather than the plugin. - It would be good to have common otree variables like player, group, etc. colored in. For example, in functions like vars_for_template() or before_next_page(), the player function in the parentheses is colored gold/yellow, but not in the function itself. Having that same color (or any color) for these variables could be quite helpful, as otherwise some complicated code can just be all white and thus not that readable. - It doesn't seem to work well with the Python extension that Cursor always prompts to install. That is, the Python extension will tell you things are wrong but are normal syntax in otree code. It's then not clear which plugin the message is coming from, and this also then interfaces weirdly with the AI assistant. One example was assigning something to a player field using e.g. player.foo - the default Python extension flags this, then if you ask the AI about it it runs off and tries to put .set() everywhere. - Probably a Cursor thing, but I had issues with it not saving changes as well as not updating file contents based on changes made elsewhere. This differs from what I'm used to with PyCharm, where changes near immediately affect the devserver, which is useful for testing. This is probably more a preference thing, however.
#3
by
Chris_oTree
Thank you for the feedback! This is super helpful to me as I am getting started!