Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/habamax/vim-godot
Use vim and godot engine to make games
https://github.com/habamax/vim-godot
Last synced: 30 days ago
JSON representation
Use vim and godot engine to make games
- Host: GitHub
- URL: https://github.com/habamax/vim-godot
- Owner: habamax
- License: mit
- Created: 2020-04-26T13:29:29.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-11-12T21:59:07.000Z (about 1 month ago)
- Last Synced: 2024-11-12T22:32:35.789Z (about 1 month ago)
- Language: Vim Script
- Homepage:
- Size: 840 KB
- Stars: 498
- Watchers: 9
- Forks: 24
- Open Issues: 7
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
- awesome-godot - Vim - Syntax highlighting, autocompletion and linting using the LSP server provided by the Godot editor. Also supports the Godot shader language. (GDScript/C# editor support / 3D)
- awesome-godot-3 - Vim - Syntax highlighting, autocompletion and linting using the LSP server provided by the Godot editor. Also supports the Godot shader language. (GDScript/C# editor support / 3D)
- awesome-godot-3 - Vim - Syntax highlighting, autocompletion and linting using the LSP server provided by the Godot editor. Also supports the Godot shader language. (GDScript/C# editor support / 3D)
README
= Godot + Vim
:experimental:
:icons: font
:autofit-option:
:!source-linenums-option:
:imagesdir: images== Intro
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 https://github.com/ycm-core/YouCompleteMe[YouCompleteMe] or https://github.com/neoclide/coc.nvim[coc.nvim] plugin.
(Both do a really great job providing gdscript completion for me).https://www.youtube.com/watch?v=ALXN4HJ5bsg
== Select And Run Scene
* Use `:GodotRun ` to select a scene and run it. `:GodotRun` will run main scene.
* Use `:GodotRunFZF` to select a scene using FZF (if installed) and run it.Note that commands assume godot executable is on your `PATH`, i.e. you can run `godot` from your terminal.
If this is not the case, specify it in your settings:.For windows
[source,vim]
------------------------------------------------------------------------------
" windows example
let g:godot_executable = 'C:/Path/To/Godot/godot.exe'
------------------------------------------------------------------------------.For OSX
[source,vim]
------------------------------------------------------------------------------
" OSX example
let g:godot_executable = '/Applications/Godot.app/Contents/MacOS/Godot'
------------------------------------------------------------------------------image::https://user-images.githubusercontent.com/234774/80359547-a5fc6c00-8886-11ea-9cdd-bc027d46db4c.gif[]
NOTE: To run game or a scene in "async way" install either https://github.com/tpope/vim-dispatch[vim-dispatch] or https://github.com/skywind3000/asyncrun.vim[asyncrun.vim].
== Settings
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).[source,vim]
------------------------------------------------------------------------------
" to use folding provided by plugin
setlocal foldmethod=expr
setlocal shiftwidth=4
setlocal tabstop=4
nnoremap :GodotRunLast
nnoremap :GodotRun
nnoremap :GodotRunCurrent
nnoremap :GodotRunFZF
------------------------------------------------------------------------------Or you can use autocommand in your `.vimrc` (example):
[source,vim]
------------------------------------------------------------------------------
func! GodotSettings() abort
setlocal foldmethod=expr
setlocal tabstop=4
nnoremap :GodotRunLast
nnoremap :GodotRun
nnoremap :GodotRunCurrent
nnoremap :GodotRunFZF
endfunc
augroup godot | au!
au FileType gdscript call GodotSettings()
augroup end
------------------------------------------------------------------------------== Installation
Using plugin manager::
Follow your plugin manager documentation, for example, link:https://github.com/junegunn/vim-plug[vim-plug] does it this way:
+
[source,vim]
------------------------------------------------------------------------------
" 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 OSX
[source,sh]
------------------------------------------------------------------------------
git clone https://github.com/habamax/vim-godot ~/.vim/pack/plugins/start/vim-godot
------------------------------------------------------------------------------
+
.Neovim on Linux or OSX
[source,sh]
------------------------------------------------------------------------------
git clone https://github.com/habamax/vim-godot ~/.config/nvim/pack/plugins/start/vim-godot
------------------------------------------------------------------------------
+
.Vim on Windows
[source,sh]
------------------------------------------------------------------------------
git clone https://github.com/habamax/vim-godot C:/Users/USERNAME/vimfiles/pack/plugins/start/vim-godot <.>
------------------------------------------------------------------------------
+
.Neovim on Windows
[source,sh]
------------------------------------------------------------------------------
git clone https://github.com/habamax/vim-godot C:/Users/USERNAME/AppData/Local/nvim/pack/plugins/start/vim-godot <.>
------------------------------------------------------------------------------
<.> Change `USERNAME` to your user nameManual::
* Download zip archive (available in menu:Code[Download ZIP])
* Unpack it to appropriate folder defined in `Manual with git`
* Make sure that contents of the archive is in `.../start/vim-godot` directory:
** `autoload`
** `ftdetect`
** `ftplugin`
** ... etc== Setting up YouCompleteMe for Godot 3.2.2+
. Install and set up YCM according to https://github.com/ycm-core/YouCompleteMe#installation[it's documentation].
(i.e. install with package manager then run `./install.py`).. Make sure general completion works for you.
. Follow https://github.com/ycm-core/lsp-examples[instructions for enabling godot].
Or you can just add this to your vimrc:
[source, vim]
------------------------------------------------------------------------------
if !has_key( g:, 'ycm_language_server' )
let g:ycm_language_server = []
endiflet g:ycm_language_server += [
\ {
\ 'name': 'godot',
\ 'filetypes': [ 'gdscript' ],
\ 'project_root_files': [ 'project.godot' ],
\ 'port': 6005
\ }
\ ]
------------------------------------------------------------------------------NOTE: This is not a comprehensive `YouCompleteMe` setup guide. It just works
for me and hopefully would work for you.== Setting up coc.nvim for Godot 3.2.2+
. Install https://github.com/neoclide/coc.nvim[coc.nvim], make sure it does general completion for you.
. Open `:CocConfig` and add following lines:
+
[source,json]
------------------------------------------------------------------------------
{
"languageserver": {
"godot": {
"host": "127.0.0.1",
"filetypes": ["gdscript"],
"port": 6005
}
}
}
------------------------------------------------------------------------------
. Save and restartNOTE: This is not a comprehensive `coc.nvim` setup guide. It just works for me
and hopefully would work for you.* To find which port is correct for your version of the Godot Engine, go to
`Editor > Editor Settings > Network > Language Server`== Setting up ale for Godot 3.2.2+
. Install https://github.com/dense-analysis/ale[ale], make sure it does general
completion for you and register the Godot LSP server as follows in your vimrc:
+
[source,vim]
------------------------------------------------------------------------------
" Enable ALE auto completion globally
let g:ale_completion_enabled = 1" Allow ALE to autoimport completion entries from LSP servers
let g:ale_completion_autoimport = 1" Register LSP server for Godot:
call ale#linter#Define('gdscript', {
\ 'name': 'godot',
\ 'lsp': 'socket',
\ 'address': '127.0.0.1:6008',
\ 'project_root': 'project.godot',
\})
------------------------------------------------------------------------------
. Save and restartNOTE: This is not a comprehensive ALE setup guide. Make sure to adjust it to your needs.
== Setting up ctags
Put the following contents:
[source]
------------------------------------------------------------------------------
--langdef=GDScript
--langmap=GDScript:.gd
--regex-GDScript=/^func[ \t]+([a-zA-Z0-9_]+)/\1/f,function,function definitions/
--regex-GDScript=/^(onready[ \t]+)?var[ \t]+([a-zA-Z0-9_]+)/\2/v,variable,variable definitions/
--regex-GDScript=/^(export[ \t]*(.*)?[ \t]+)?var[ \t]+([a-zA-Z0-9_]+)/\3/v,variable,variable definitions/
------------------------------------------------------------------------------* `~/.ctags.d/gdscript.ctags` if you use https://ctags.io/[universal ctags] or
* `~/.ctags` if you use http://ctags.sourceforge.net/[exuberant ctags]To use it together with tagbar, put following into your vimrc or init.vim:
[source]
------------------------------------------------------------------------------
let g:tagbar_type_gdscript = {
\'ctagstype' :'gdscript',
\'kinds':[
\'v:variables',
\'f:functions',
\]
\}
------------------------------------------------------------------------------== Setting up Neovim native lsp with nvim-cmp
Install the following plugins[source,vim]
------------------------------------------------------------------------------
Plug 'neovim/nvim-lspconfig'
"A good completion plugin
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/nvim-cmp'
------------------------------------------------------------------------------put this in your init.vim to set up the gdscript server and connecting cmp to it (the mappings are the official cmp mappings you can remove or change them)
[source,vim]
------------------------------------------------------------------------------
set completeopt=menu,menuone,noselectlua << EOF
require'lspconfig'.gdscript.setup{capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())}local cmp = require'cmp'
cmp.setup({
mapping = {
[''] = cmp.mapping.scroll_docs(-4),
[''] = cmp.mapping.scroll_docs(4),
[''] = cmp.mapping.complete(),
[''] = cmp.mapping.close(),
[''] = cmp.mapping.confirm({ select = true }),
},sources = {
{ name = 'nvim_lsp' },
{ name = 'buffer' },
}
})
EOF
------------------------------------------------------------------------------== Setup vim as an external editor for Godot
Note I didn't try it myself, but @macmv https://github.com/habamax/vim-godot/issues/29[had provided] some info about it.
Open menu `Editor/Editor Settings/` then navigate to `General/External/`:
* Tick `Use external editor`
* Add `vim` to `Exec Path`
* Add `--servername godot --remote-send ":n {file}{line}G{col}|"` to `Exec Flags`== Setup Neovim as an external editor for Godot
Navigate to the root of your godot project (where the project.godot is residing) and start a new Neovim like this:
[source]
------------------------------------------------------------------------------
nvim --listen ./godothost
------------------------------------------------------------------------------(on Windows you might have to specify a IP:port combination instead, like "127.0.0.1:9696")
Open menu `Editor/Editor Settings/` then navigate to `General/External/`:
* Tick `Use external editor`
* Add `nvim` to `Exec Path`
* Add `--server ./godothost --remote-send ":n {file}{line}G{col}|"` to `Exec Flags`now when you click on a script in godot it will open it in a new buffer in Neovim.