Godot engine has rock solid built-in editor but I still feel more comfortable within my (g)(n)vim environment.
This plugin provides:
-
GDScript and GSL syntax highlighing
-
Folding
-
Run commands:
-
Run current scene:
:GodotRunCurrent -
Run last scene:
:GodotRunLast -
Select and run a scene with standard vim tab completion (default is a main scene):
:GodotRun -
Select and run a scene with a FZF (if installed):
:GodotRunFZF
-
All commands are local to buffer — available only in gdscript or gsl buffers.
For IDE-like completion I suggest to try YouCompleteMe or coc.nvim plugin. (Both do a really great job providing gdscript completion for me).
No default mappings are provided.
Good practice is to put your personal filetype specific settings into after directory:
~/.vim/after/ftplugin/gdscript.vim (or ~/vimfiles/after/ftplugin/gdscript.vim if you’re on windows).
" to use folding provided by plugin
setlocal foldmethod=expr
setlocal tabstop=4
nnoremap <buffer> <F4> :GodotRunLast<CR>
nnoremap <buffer> <F5> :GodotRun<CR>
nnoremap <buffer> <F6> :GodotRunCurrent<CR>
nnoremap <buffer> <F7> :GodotRunFZF<CR>Or you can use autocommand in your .vimrc (example):
func! GodotSettings() abort
setlocal foldmethod=expr
setlocal tabstop=4
nnoremap <buffer> <F4> :GodotRunLast<CR>
nnoremap <buffer> <F5> :GodotRun<CR>
nnoremap <buffer> <F6> :GodotRunCurrent<CR>
nnoremap <buffer> <F7> :GodotRunFZF<CR>
endfunc
augroup godot | au!
au FileType gdscript call GodotSettings()
augroup end- Using plugin manager
-
Follow your plugin manager documentation, for example, vim-plug does it this way:
" Specify a directory for plugins call plug#begin('~/.vim/plugged') Plug 'habamax/vim-godot' " ... other plugins ... " Initialize plugin system call plug#end()
- Manual with git
-
Clone this repo to your vim/nvim packages directory:
Vim on Linux or OSXgit clone https://github.com/habamax/vim-godot ~/.vim/pack/plugins/start/vim-godotNeovim on Linux or OSXgit clone https://github.com/habamax/vim-godot ~/.config/nvim/pack/plugins/start/vim-godotVim on Windowsgit clone https://github.com/habamax/vim-godot C:/Users/USERNAME/vimfiles/pack/plugins/start/vim-godot (1)
Neovim on Windowsgit clone https://github.com/habamax/vim-godot C:/Users/USERNAME/AppData/Local/nvim/pack/plugins/start/vim-godot (1)
-
Change
USERNAMEto your user name
-
- Manual
-
-
Download zip archive (available in Code › Download ZIP)
-
Unpack it to appropriate folder defined in
Manual with git -
Make sure that contents of the archive is in
…/start/vim-godotdirectory:-
autoload -
ftdetect -
ftplugin -
… etc
-
-
-
Install and set up YCM according to it’s documentation. (i.e. install with package manager then run
./install.py). -
Make sure general completion works for you.
-
Follow instructions for enabling godot.
Or you can just add this to your vimrc:
if !has_key( g:, 'ycm_language_server' )
let g:ycm_language_server = []
endif
let g:ycm_language_server += [
\ {
\ 'name': 'godot',
\ 'filetypes': [ 'gdscript' ],
\ 'project_root_files': [ 'project.godot' ],
\ 'port': 6008
\ }
\ ]|
Note
|
This is not a comprehensive YouCompleteMe setup guide. It just works
for me and hopefully would work for you.
|
-
Install coc.nvim, make sure it does general completion for you.
-
Open
:CocConfigand add following lines:{ "languageserver": { "godot": { "host": "127.0.0.1", "filetypes": ["gdscript"], "port": 6008 } } } -
Save and restart
|
Note
|
This is not a comprehensive coc.nvim setup guide. It just works for me
and hopefully would work for you.
|
