Vim Users Super Thread

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Vim Users Super Thread

Post by Inny »

I probably need to update my blog post and explain how I got -sorta- tab completion. I didn't use those plugins (the xolox ones) specifically, I think I parted them out.

What I did was add the attached dictionary file as a dictionary for Vim (rename it to love.dict if you use it). Then I use this config in my vimrc:

Code: Select all

function SetLovePrefs()
    if has("win32") || has("win64")
        setlocal dictionary-=~/vimfiles/love-dictionary/love.dict dictionary+=~/vimfiles/love-dictionary/love.dict
        setlocal dictionary-=~/vimfiles/lua.dict dictionary+=~/vimfiles/lua.dict
        setlocal iskeyword+=.
    end
endfunction
if has("autocmd")
  augroup prog
    au!
    autocmd FileType lua setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd FileType lua call SetLovePrefs()
  augroup END
end
if has("win32") || has("win64")
  command -nargs=* Love  :!"C:\Program Files\LOVE\love.exe" . <args>
  command -nargs=* Lua51 :!"C:\Program Files (x86)\Lua\5.1\lua.exe" <args>
end
It's no intellisense, but it gets the job done.
Attachments
love.dict.txt
love dictionary
(6.19 KiB) Downloaded 148 times
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Vim Users Super Thread

Post by davisdude »

Ladies and gentlemen, I have exciting news! There is now a LOVE syntax highlighting file available!
I probably did this very inefficiently, so somebody with more experience with Vim syntax please yell at me.
Anyway, here it is. Put in your .vim/after/syntax/ folder (for Windows users that's vimfiles/after/syntax). If you already have a Lua syntax extension you have to make a folder in there called Lua and then put that one in there (as LOVE.vim, I guess). Anyway, at the end of the file you can customize the colors for each group. By default they're a pink color that goes well with the background color I have.
(For some reason vim extensions aren't allowed, so here's a link).
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
spill
Prole
Posts: 27
Joined: Thu May 07, 2015 1:53 am
Contact:

Re: Vim Users Super Thread

Post by spill »

Here's a trick I use for quickly launching and packaging my game from within vim. In my ~/.vimrc file, I have the lines:

Code: Select all

"change vim's directory to opened file
set autochdir
"change vim's directory when switching files
autocmd BufRead
"if it exists, run .vimrc from the current folder
set exrc
"restrict the privileges to minimize the damage that could arise from opening a downloaded file with a malicious .vimrc in the same directory
set secure
Which allows me to have a custom .vimrc file in each directory. And in the game's directory, I have a file called .vimrc with the following contents:

Code: Select all

"Run the game with ctrl+k
inoremap <C-K> <C-O>:!/Applications/love.app/Contents/MacOS/love .<CR>
map <C-K> :!/Applications/love.app/Contents/MacOS/love .<CR>
"Package the game into a .love file with ctrl+\
inoremap <C-\> <C-O>:!zip -FSr $(basename $(pwd)).love * -x .* *.love *.sh<CR>
map <C-\> :!zip -FSr $(basename $(pwd)).love * -x .* *.love *.sh<CR>
This lets me launch the game by hitting ctrl+k or package the game with ctrl+\ in insert or normal mode. Since it's per-directory, it's also nice to be able to set up different versions of the same .vimrc file depending on the game (e.g. changing the name from "game.love"). Also, if I'm working on a game with multiple directories, I'll put a .vimrc in each of the directories, with the paths adjusted accordingly.
(This is for a mac, obviously, you can adjust the path to the löve executable as needed for your OS)

Also, another tip: if you put the following line in your .vimrc, you can edit a .love file with vim directly by just using "vim foo.love". It's great.

Code: Select all

autocmd BufReadCmd *.love call zip#Browse(expand("<amatch>"))
Last edited by spill on Sat Jul 18, 2015 9:16 am, edited 1 time in total.
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Vim Users Super Thread

Post by davisdude »

That's a cool tip; I hadn't ever thought of doing it that way. I'll have to look into it. :cool:
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Vim Users Super Thread

Post by bartbes »

spill wrote:

Code: Select all

set excrc
That should be exrc.
spill wrote: Which allows me to have a custom .vimrc file in each directory. And in the game's directory, I have a file called .vimrc with the following contents:
[...]
This lets me launch the game by hitting ctrl+k or package the game with ctrl+\ in insert or normal mode. Since it's per-directory, it's also nice to be able to set up different versions of the same .vimrc file depending on the game (e.g. changing the name from "game.love"). Also, if I'm working on a game with multiple directories, I'll put a .vimrc in each of the directories, with the paths adjusted accordingly.
I'm not sure why you can't do this globally, and the automatic dir switching makes it much more annoying to do this.
User avatar
spill
Prole
Posts: 27
Joined: Thu May 07, 2015 1:53 am
Contact:

Re: Vim Users Super Thread

Post by spill »

bartbes wrote:
spill wrote:

Code: Select all

set excrc
That should be exrc.
Yes, that's a copy+paste error. Good catch. I'll edit my post.
bartbes wrote:I'm not sure why you can't do this globally, and the automatic dir switching makes it much more annoying to do this.
You definitely can do it globally, but I'd rather have ctrl+k map to "run the thing" in every directory, regardless of whether it's löve or not, instead of having ctrl+k globally mapped to "run löve" and having to find another keybinding for "run make" or whatever. It's also useful to be able to locally edit the directory's .vimrc file for when I want to build into different .love files (e.g. switch git branches, and have the .love build change filenames so I can easily compare different versions). As for the automatic directory switching, that's helpful for switching between multiple löve projects without exiting vim.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Vim Users Super Thread

Post by bartbes »

You don't need automatic switching for that.
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Vim Users Super Thread

Post by Inny »

My needs for running love are a bit more simple:

Code: Select all

if has("win32") || has("win64")
  command -nargs=* Love  :!"C:\Program Files\LOVE\love.exe" . <args>
  command -nargs=* Lua51 :!"C:\Program Files (x86)\Lua\5.1\lua.exe" <args>
end
And I just make sure I launch vim from that folder.
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Vim Users Super Thread

Post by davisdude »

I'm reviving this thread show off the new syntax highlighting I created (and I totally didn't rip the idea from josefnpat...)

Anyway, you can view it here.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Vim Users Super Thread

Post by Inny »

davisdude wrote:new syntax highlighting
Sweet!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 5 guests