Page 3 of 4

Re: How to setup VIM

Posted: Wed Mar 29, 2017 5:50 am
by yetneverdone
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

Re: How to setup VIM

Posted: Wed Mar 29, 2017 1:52 pm
by kikito
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.

Re: How to setup VIM

Posted: Wed Mar 29, 2017 3:44 pm
by Inny
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)

Re: How to setup VIM

Posted: Wed Mar 29, 2017 4:14 pm
by yetneverdone
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

Re: How to setup VIM

Posted: Wed Mar 29, 2017 8:18 pm
by davisdude
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.

Re: How to setup VIM

Posted: Sat Apr 01, 2017 4:56 am
by yetneverdone
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?

Re: How to setup VIM

Posted: Sun Apr 16, 2017 2:00 pm
by yetneverdone
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?

Re: How to setup VIM

Posted: Mon Apr 17, 2017 10:16 am
by bartbes
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!

Re: How to setup VIM

Posted: Mon Apr 17, 2017 1:03 pm
by yetneverdone
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.

Re: How to setup VIM

Posted: Wed Apr 19, 2017 4:51 am
by yetneverdone
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 :)