Ren'Py Integration: gVim Portable

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
pwisaguacate
Veteran
Posts: 356
Joined: Mon Mar 11, 2013 11:03 pm
Contact:

Ren'Py Integration: gVim Portable

#1 Post by pwisaguacate »

[See Post #3 for 30 May 2013 Update]

PortableApps.com: http://portableapps.com/apps/development/gvim_portable
SourceForge.net: http://portablegvim.sourceforge.net/downloads.html
NOTE: Windows only

I took gVim Portable from PortableApps.com and trimmed it down to resemble the lightweight version from SourceForge, meaning "doc", "spell", "vimtutor" and a few other things were removed.

Current .zip (can be run but not directly within Ren'Py launcher yet):
gVimPortableLW-7.3.zip
WARNING: Do NOT run gVim from the Ren'Py launcher. If you do, then it will crash and you'll need to clear persistent data.
(3.26 MiB) Downloaded 96 times
Contains:
  • Light version of gVim Portable
  • renpy.vim in \Data\settings\vimfiles\syntax (thanks, Musashi)
  • gVim.edit.py in root folder (orig. by Musashi; needs to be rewritten)
  • _vimrc in \Data\settings (thanks, Casey):

    Code: Select all

    colorscheme murphy
    set guifont=Consolas:h11:cANSI
    
    set nobackup
    set nowritebackup
    set noswapfile
    set lines=40
    set columns=100
    set tabstop=4
    set shiftwidth=4
    set softtabstop=4
    set autoindent
    set smarttab
    set expandtab
    filetype indent on
    filetype on
    filetype plugin on
    
    au BufRead,BufNewFile *.rpy setfiletype renpy
    set encoding=utf-8
    
TODO (help needed):
  • gVim.edit.py needs to be written to allow the Ren'Py launcher to run gVim Portable!*
  • Syntax highlighting in screen language is nonexistent; renpy.vim needs to be updated.**
  • Better color scheme for renpy syntax, which looks iffy compared to python**
  • It stays on the same indentation level whenever <ENTER> is hit.
* Maybe I'll post in the Cookbook forum after this main issue is solved? The rest aren't as important.
** I am currently taking care of the syntax highlighting using renpy.xml from jEdit as a guide.

TIPS (to be posted in Cookbook release post; I'm just placing it here first):
  • Extract gVimPortableLW-7.3.zip and place the folder in the Ren'Py root directory where Editra / jEdit is.
  • Not for the faint of heart, though I'm sure you know that by now. I included The Vim Tutor in English as a text file available for download [here] (right click and save as).
  • To set font in _vimrc (thanks, qqx):
    1. Start a graphical vim session.
    2. Type :e $MYVIMRC <ENTER>. This will open _vimrc.
    3. Use the graphical font selection dialog to select a font (Edit > Select Font...).
    4. Type :set guifont= <TAB> <ENTER>.
    5. Insert a line somewhere and type <CTRL> + <R> followed by <:>.
    The command in step 6 will insert the contents of the : special register which contains the last ex-mode command used. Here that will be the command from step 4, which has the properly formatted font name thanks to the tab completion of the value previously set using the GUI dialog.
Last edited by pwisaguacate on Fri May 31, 2013 12:32 am, edited 3 times in total.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Ren'Py Integration: gVim Portable

#2 Post by xela »

Sweet, I've always wanted to figure out gVim, now it works with RenPy, it's a prefect opportunity. Going through the tutor file now :)

Thanks for this option.
Like what we're doing? Support us at:
Image

pwisaguacate
Veteran
Posts: 356
Joined: Mon Mar 11, 2013 11:03 pm
Contact:

Re: Ren'Py Integration: gVim Portable

#3 Post by pwisaguacate »

30 May 2013 Update

Current .zip:
gVimLW-7.3.zip
Much more ready; still needs gVim.edit.py to be written
(3.21 MiB) Downloaded 100 times
I changed the folder name to gVim. (You don't see 'em called EditraPortable / jEditPortable, do you?) I also renamed splash.jpg in /App/AppInfo/Launcher/ to splash-old.jpg and swapped in the SourceForge version (edited it to read 7.3.0 instead of 7.1.0). To disable the splash screen, rename or remove the image.
splash.jpg
Changes to gVim/Data/settings/_vimrc:

Code: Select all

- colorscheme murphy
+ colorscheme jedit_default
  set guifont=Consolas:h11:cANSI
+ set number
+ foldmethod=indent
+ set foldlevelstart=99
+ au BufWinLeave * mkview
+ au BufWinEnter * silent! loadview
+ let &viewdir=expand("$VIM")
+ set viewoptions=folds " default is folds,options,cursor
The folding method is set to indent. Let's say you want to fold an entire label. Set the cursor right under the label (not on it) and type za to toggle on/off. gVim will remember your folds, storing the data in /App/vim/. If you want your cursor location to be remembered, then remove or comment out the last line with a double quotation mark (").

Imported the entire jEdit syntax file into /Data/settings/vimfiles/syntax/renpy.vim, with the following additions:

Code: Select all

# jEdit KEYWORD2 highlight:
    # screens.rpy related
    build
    config
    theme
	
    # properties (incl. prefixes e.g. idle_ and selected_)
    box_reverse      # Box style
    order_reverse
    caret            # Text style
    line_overlap_split
    vertical
    transform_anchor # Transform

# Kept, but I noticed they're not in current documentation anymore:
    clipping
    text_y_fudge
Added /Data/settings/vimfiles/indent/renpy.vim. It is set to automatically use python's auto-indentation system, and this works real great.

Added /Data/settings/vimfiles/colosr/jedit_default.vim. This one isn't really needed, and the updated syntax file now looks fine with other color schemes that you could find online. This one is simple; you can modify the main highlight terms Normal (basic text), Visual (selected text), Comment, Function (KEYWORD2), Statement (KEYWORD1), and String (stuff in quotation marks).
Attachments
vim_folds_screenshot.png

User avatar
existentia
Newbie
Posts: 6
Joined: Fri Nov 09, 2012 5:53 am
Contact:

Re: Ren'Py Integration: gVim Portable

#4 Post by existentia »

Thank you so much for this. I imported your .vim files into my usual install folder, and it works quite the treat. Now I have even less excuse to procrastinate.

picobyte
Newbie
Posts: 15
Joined: Mon Mar 14, 2016 2:15 pm
Contact:

Re: Ren'Py Integration: gVim Portable

#5 Post by picobyte »

The new config.editor guidelines can be used to implement gvim support; store as gvim.edit.py

Code: Select all

import renpy
import subprocess


class Editor(renpy.editor.Editor):

    def begin(self, new_window=False, **kwargs):
        self.arguments = ["/usr/bin/gvim", "--servername", "RenPy", "--remote-tab"]

    def open(self, filename, line=None, **kwargs):
        if filename.endswith("traceback.txt"):
            self.arguments.extend(["-c", "set", "autoread"])
        if line:
            self.arguments.append("+%d" % line)
        filename = renpy.exports.fsencode(filename)
        self.arguments.append(filename)

    def end(self, **kwargs):
        subprocess.Popen(self.arguments)
the `-c set autoread' for traceback prevents the reload question after errors

the `--servername RenPy --remote-tab' options ensure that when the editor is called with new_window=False, a tab will be opened to a gvim window previously opened by Ren'Py. The +<linenr> causes the file to jump to the linenumber if specified.

Added a line to ~/.vimrc to get python syntax highlighting for .rpy files which is about right.

Code: Select all

au BufRead,BufNewFile *.rpy set filetype=python
Added a file ~/.vim/ftplugin/python.vim containing rules for indentation, etc:
(If the file already exists, you may want to add only the browsefilter lines)

Code: Select all

set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
set fileformat=unix

let b:browsefilter = "(Ren')Py file (*.rpy *.py)\t*.rpy;*.py\n" .
  \ "Python Files (*.py)\t*.py\n" .
  \ "Ren'Py Files (*.rpy)\t*.rpy\n" .
  \ "All Files (*.*)\t*.*\n"
The browsefilter will show renpy files by default if you open a file. There is also this file with some more suggestions, I have not tried.
https://github.com/tarmack/vim-python-f ... python.vim

To get rudimentary ctags support I also added these lines to ~/.ctags:

Code: Select all

--langdef=renpy
--langmap=renpy:.rpy
--regex-renpy=/^label[ \t]*([a-zA-Z0-9_]+):/\1/l,label/
--regex-renpy=/^define[ \t]*([a-zA-Z0-9_.]+)/\1/d,definition/
--regex-renpy=/^[ \t]*\$?[ \t]*([a-zA-Z0-9_]+)[ \t]*=/\1/v,variable/
--regex-renpy=/^screen[ \t]*([a-zA-Z0-9_]+)/\1/s,screen/
--regex-renpy=/^style[ \t]*([a-zA-Z0-9_]+)/\1/S,style/
After running ctags -R on the commandline (which builds/refreshes the ctags file) you can open e.g. a file in gvim at label start with `gvim -t start' or in gvim hit `:' to get the command editor and `ta config.window' to jump there. Ctrl+T to jump back where you came from. You don't even need to write it entirely, use tab completion.

Post Reply

Who is online

Users browsing this forum: No registered users