How to setup VIM

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
yetneverdone
Party member
Posts: 351
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: How to setup VIM

Post by yetneverdone » Wed Mar 29, 2017 5:50 am

davisdude wrote:
Wed Mar 29, 2017 3:15 am
Messing around with this today I figured something out.

If the " &" solution doesn't do the trick, this may help: the Vim "!start" command (which is different from "! start", the command which is Windows only), does NOT work the same way as the command line. In other words, if you use a shell file to run LOVE, it may not be finding it by using !start. To call from the command-line non-blocking, this is what I did (example is to run Python scripts):

Code: Select all

:!start cmd /c python %
Where "cmd /c" runs a command shell. It may be different in Linux, but that is gist of what you may end up having to do if you can't get LOVE to work. Hopefully one of these solutions works for you :)
Thanks for the input :) The

Code: Select all

:!love . &
did the trick :)

Thanks alot dude.
btw, do you have any new module on development? Your libraries are very helpful

User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: How to setup VIM

Post by kikito » Wed Mar 29, 2017 1:52 pm

Just my two cents regarding this: when I do LÖVE with vim I don't have any specific command for "launching love"; instead, I use another tab in the terminal to launch it. The first time I have to type "love .", but the rest it's just "change-terminal-tab up enter" - three keystrokes (I guess you could reduce it to 2 in Vim by making an alias to `:!love . &`). The extra terminal is a text log, which I like - I sometimes debug stuff by printing stuff there (with print), and LÖVE reproduces the error logs in the console, so they are copy-pasteable.
When I write def I mean function.

User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: How to setup VIM

Post by Inny » Wed Mar 29, 2017 3:44 pm

Still talking about vim, are we? Here's how Inny does his vimrc these days:

First up, Autocomplete. I do all this on windows, but I try to make sure it runs on linux as well. I use Ctrl-n as my autocompleter, which I also map to ctrl-space (cuz visual studio). I used to use the plugin supertab for that, but there are too many times when I want tab for spacing and vim can lock up for a second or two when autocompleting a right parenthesis into the entire dictionary.

Code: Select all

set wildmenu
set wildmode=list,full
set complete-=k complete+=k
set completefunc=syntaxcomplete#Complete
set omnifunc=syntaxcomplete#Complete
set tags=tags;/

" ctrl-space for autocomplete
inoremap <C-Space> <C-n>
if has("gui_running") == 0
  if has("unix")
    inoremap <Nul> <C-n>
  endif
endif
I complement this with the linux words dictionary, so that my laziness is enhanced.

Code: Select all

if has("win32") || has("win64")
    set dictionary-=~/vimfiles/linux_words.dict dictionary+=~/vimfiles/linux_words.dict
else
    set dictionary-=/usr/share/dict/words dictionary+=/usr/share/dict/words
endif
Next, I add the love dictionary to the autocomplete. I forget where I got this from, but it's almost certainly here on the love2d forums. Go find it. It's a function, because I don't want love autocomplete in other file types.

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
    end
endfunction
Here's where I do the autocmds that set my preferences when editing lua files. The iskeyword thing is a bane and a boon, be careful with it.

Code: Select all

    autocmd FileType lua setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd FileType lua call SetLovePrefs()
    autocmd FileType lua setlocal iskeyword+=:
    autocmd FileType lua setlocal iskeyword+=.
And the last bit, enabling love commands so I can do it right in gvim. This isn't necessarily a great idea as the editor is locked up while Love is running, but it works for my needs. Like kikito said, also have a term open, because there are times when you want to browse the code while having the editor be responsive. If you use these, you need to fill in where you have love and lua installed. On linux, you shouldn't need these, as /usr/bin is in your $PATH.

Code: Select all

if has("win32") || has("win64")
  command -nargs=* Love10 :!"C:\Program Files\LOVE-0.10.2\lovec.exe" . <args>
  command -nargs=* Lua51  :!"C:\Program Files (x86)\Lua\5.1\lua.exe" <args>
end
Please please please use :help on all of things you see here. Don't just blindly use them unless you understand them.

Edit: Oh hey, that start cmd /c might be useful here. I guess I'll be doing that from now on. (This is the life of being a vim user, you're always learning a new tip)

User avatar
yetneverdone
Party member
Posts: 351
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: How to setup VIM

Post by yetneverdone » Wed Mar 29, 2017 4:14 pm

Inny wrote:
Wed Mar 29, 2017 3:44 pm
Still talking about vim, are we? Here's how Inny does his vimrc these days:

First up, Autocomplete. I do all this on windows, but I try to make sure it runs on linux as well. I use Ctrl-n as my autocompleter, which I also map to ctrl-space (cuz visual studio). I used to use the plugin supertab for that, but there are too many times when I want tab for spacing and vim can lock up for a second or two when autocompleting a right parenthesis into the entire dictionary.

Code: Select all

set wildmenu
set wildmode=list,full
set complete-=k complete+=k
set completefunc=syntaxcomplete#Complete
set omnifunc=syntaxcomplete#Complete
set tags=tags;/

" ctrl-space for autocomplete
inoremap <C-Space> <C-n>
if has("gui_running") == 0
  if has("unix")
    inoremap <Nul> <C-n>
  endif
endif
I complement this with the linux words dictionary, so that my laziness is enhanced.

Code: Select all

if has("win32") || has("win64")
    set dictionary-=~/vimfiles/linux_words.dict dictionary+=~/vimfiles/linux_words.dict
else
    set dictionary-=/usr/share/dict/words dictionary+=/usr/share/dict/words
endif
Next, I add the love dictionary to the autocomplete. I forget where I got this from, but it's almost certainly here on the love2d forums. Go find it. It's a function, because I don't want love autocomplete in other file types.

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
    end
endfunction
Here's where I do the autocmds that set my preferences when editing lua files. The iskeyword thing is a bane and a boon, be careful with it.

Code: Select all

    autocmd FileType lua setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd FileType lua call SetLovePrefs()
    autocmd FileType lua setlocal iskeyword+=:
    autocmd FileType lua setlocal iskeyword+=.
And the last bit, enabling love commands so I can do it right in gvim. This isn't necessarily a great idea as the editor is locked up while Love is running, but it works for my needs. Like kikito said, also have a term open, because there are times when you want to browse the code while having the editor be responsive. If you use these, you need to fill in where you have love and lua installed. On linux, you shouldn't need these, as /usr/bin is in your $PATH.

Code: Select all

if has("win32") || has("win64")
  command -nargs=* Love10 :!"C:\Program Files\LOVE-0.10.2\lovec.exe" . <args>
  command -nargs=* Lua51  :!"C:\Program Files (x86)\Lua\5.1\lua.exe" <args>
end
Please please please use :help on all of things you see here. Don't just blindly use them unless you understand them.

Edit: Oh hey, that start cmd /c might be useful here. I guess I'll be doing that from now on. (This is the life of being a vim user, you're always learning a new tip)
Thanks dude! Thanks alot. that's a lot of additions to my existing vim setup

davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: How to setup VIM

Post by davisdude » Wed Mar 29, 2017 8:18 pm

Inny wrote:
Wed Mar 29, 2017 3:44 pm
Edit: Oh hey, that start cmd /c might be useful here. I guess I'll be doing that from now on. (This is the life of being a vim user, you're always learning a new tip)
Yeah, it took me a while to figure out something that really worked for my needs. For running single files, I actually use "!start cmd /c python % && pause" that way I can see the output of the console before it closes. I'm not completely sure if it works on Linux or not, though. I definitely second this, as well as the "Don't just blindly use them unless you understand them" bit.
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
yetneverdone
Party member
Posts: 351
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: How to setup VIM

Post by yetneverdone » Sat Apr 01, 2017 4:56 am

Inny wrote:
Wed Mar 29, 2017 3:44 pm
Still talking about vim, are we? Here's how Inny does his vimrc these days:

First up, Autocomplete. I do all this on windows, but I try to make sure it runs on linux as well. I use Ctrl-n as my autocompleter, which I also map to ctrl-space (cuz visual studio). I used to use the plugin supertab for that, but there are too many times when I want tab for spacing and vim can lock up for a second or two when autocompleting a right parenthesis into the entire dictionary.

Code: Select all

set wildmenu
set wildmode=list,full
set complete-=k complete+=k
set completefunc=syntaxcomplete#Complete
set omnifunc=syntaxcomplete#Complete
set tags=tags;/

" ctrl-space for autocomplete
inoremap <C-Space> <C-n>
if has("gui_running") == 0
  if has("unix")
    inoremap <Nul> <C-n>
  endif
endif
I complement this with the linux words dictionary, so that my laziness is enhanced.

Code: Select all

if has("win32") || has("win64")
    set dictionary-=~/vimfiles/linux_words.dict dictionary+=~/vimfiles/linux_words.dict
else
    set dictionary-=/usr/share/dict/words dictionary+=/usr/share/dict/words
endif
Next, I add the love dictionary to the autocomplete. I forget where I got this from, but it's almost certainly here on the love2d forums. Go find it. It's a function, because I don't want love autocomplete in other file types.

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
    end
endfunction
Here's where I do the autocmds that set my preferences when editing lua files. The iskeyword thing is a bane and a boon, be careful with it.

Code: Select all

    autocmd FileType lua setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd FileType lua call SetLovePrefs()
    autocmd FileType lua setlocal iskeyword+=:
    autocmd FileType lua setlocal iskeyword+=.
And the last bit, enabling love commands so I can do it right in gvim. This isn't necessarily a great idea as the editor is locked up while Love is running, but it works for my needs. Like kikito said, also have a term open, because there are times when you want to browse the code while having the editor be responsive. If you use these, you need to fill in where you have love and lua installed. On linux, you shouldn't need these, as /usr/bin is in your $PATH.

Code: Select all

if has("win32") || has("win64")
  command -nargs=* Love10 :!"C:\Program Files\LOVE-0.10.2\lovec.exe" . <args>
  command -nargs=* Lua51  :!"C:\Program Files (x86)\Lua\5.1\lua.exe" <args>
end
Please please please use :help on all of things you see here. Don't just blindly use them unless you understand them.

Edit: Oh hey, that start cmd /c might be useful here. I guess I'll be doing that from now on. (This is the life of being a vim user, you're always learning a new tip)

Am I supposed to use "win32" and "win64" if im on linux?

User avatar
yetneverdone
Party member
Posts: 351
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: How to setup VIM

Post by yetneverdone » Sun Apr 16, 2017 2:00 pm

Hey, Im using GVim, everytime i run love with the command

Code: Select all

:!love . &
it does work the way i asked earlier (be able to return to the editor while the game is running for hotswapping features)

But the problem is, i dont get any "output" from print functions. The conf.lua has the

Code: Select all

io.stdout:setvbuf("no")
A workaround ive tried is going to my project directory in a terminal, then launch love there with

Code: Select all

love .
It does give me the output i want. But is there any other way or method on how to achieve that in gvim?

User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: How to setup VIM

Post by bartbes » Mon Apr 17, 2017 10:16 am

If you set up love as your makeprg, the output gets sent to the quickfix list when you use :make to run your game.

Code: Select all

:set makeprg=love\ .
:make
If there's an error, it actually takes you to the location of the error too!

User avatar
yetneverdone
Party member
Posts: 351
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: How to setup VIM

Post by yetneverdone » Mon Apr 17, 2017 1:03 pm

bartbes wrote:
Mon Apr 17, 2017 10:16 am
If you set up love as your makeprg, the output gets sent to the quickfix list when you use :make to run your game.

Code: Select all

:set makeprg=love\ .
:make
If there's errors, it actually takes you to the location of the error too!
Awesome, it works.

User avatar
yetneverdone
Party member
Posts: 351
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: How to setup VIM

Post by yetneverdone » Wed Apr 19, 2017 4:51 am

Hello again, sorry for asking a lot of questions here regarding vim. Instead of making different thread posts for questions, Ive decided to ask here.

My question is,
How to move/jump between different functions in lua? I googled that using [[ and ]] jump around functions, but in lua (or in my case I guess) it just jumps around the beginning and last line of the file.

Thank you loving community :)

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 60 guests