call plug#begin('~/.local/share/nvim/plugged')
"Plug 'williamboman/mason.nvim'
"Plug 'williamboman/mason-lspconfig.nvim'
call plug#end()
Godot + Neovim on Linux
2024-07-14
After watching Brackeys' video on how to make a game in Godot, I too decided to make a small game using the engine. While brackeys was using GDScript, it was still quite helpful with understanding how Godot handles scenes. I used Godot some years back and created I small game in it (I think), I was still not very comfortable with Godot and since its C# support was still in beta[1], I kind of forgot about it after a while. Fortunately Unity’s sluggishness kept pushing me towards Godot as viable engine for 2D games.
Void Linux
I’ve been running Void Linux for a long time now on my
"low" end lappy[2]. Void has been very stable, minus some minor quirks. It’s runit
init
system is quite simple and pretty easy to configure.
Setting up
Godot
I decided to compile Godot since they only have the AppImage based download and compiling Godot didn’t take more than 20mins for me and it was straightforward without the compiler complaining about any missing dependecy.
Godot has an option to set custom text editor, in Editor > Editor Settings >
Dotnet > Editor, setting External Editor
to Custom
, Custom Exec Path
to
nvim
and Custom Exec Path Args
to --server "\\.\pipe\godot.pipe"
--remote-send "<C-\><C-N>:n {file}<CR>:call cursor({line},{col})<CR>"
Neovim + Dotnet LSP
The difficult part. And the difficulty was kind of because of Omnisharp missing the MSBuild since Omnisharp don’t package it with their SDK. Well there was many more problems to come, one by one. I was using dotnet + omnisharp lsp in Neovim long time back and while I had stopped using it on my linux installation, I assumed copy pasting the older configs in my nvim setting will be enough. WRONG. Things have changed. Recreating the omnisharp config from my dotfiles git history didn’t work. Btw here’s my updated working nvim configs.
So initially let alone Godot LSP, even the C# autocomplete/LSP was not working with neovim. Scorging the depths of internet (aka Godot’s forum and reddit) I came across a new LSP manager, Mason and some people posted on Neovim subreddit about how easy it is to setup Godot LSP using Mason. :|
Setting up omnisharp & godot (using gdtoolkit) using Mason worked. Until it didn’t. It became kind of lottery that sometimes godot LSP would work, sometimes won’t. Also there seems to problem with Omnisharp which when working would only show C# autocomplete (using the dropdown) but won’t show inline compilation errors.
and then inside lua << EOF/EOF
block
lua << EOF
require("mason").setup()
require("mason-lspconfig").setup()
require'lspconfig'.omnisharp.setup {}
EOF
Though when working, mason was handling the gdtoolkit
setup by itself used for
Godot LSP.
I wanted to gave up, thinking its the dotnet/C# with Omnisharp being incaptible with maybe Void Linux. Luckily zed the text editor got released on Linux, though not quite a fan of heavy GUI editors if I can avoid, I decided to gave a try, and voila, after some basic setup with LSP, both C# & godot autocomplete was working in Zed, and I didn’t even configure godot’s LSP, only C#'s.
Because the whole project worked in zed with some minimal configs, it turned out to be an issue with omnisharp and missing case of MSBuild. There’re some configs omnisharp-vim, the omnisharp plugin for vim, supports if you can’t use MSBuild
let g:OmniSharp_server_stdio = 1
let g:OmniSharp_server_use_mono = 1
let g:OmniSharp_server_use_net6 = 1
but enabling these still gave one error or another.
setting let g:Omnisharp_loglevel = 'DEBUG'
did give some better logs with what
exactly the problem was with Omnisharp not properly working, which turns out to
be issue with Workload Resolver
which doesn’t work with Omnisharp. Adding
export MSBuildEnableWorkloadResolver=false
to envirnoment variables finally
fix the issue with C# autocomplete.
Next was setting up Godot autocomplete/LSP, which was fairly easy using Mason to
install gdtoolkit
package.
TL;DR
This all turns out to be lot of trial & error to fix the C# LSP on Linux, maybe
because of Microsoft’s tools on Linux are still not the best supported, after
all "Microsoft <3 Linux", but after jumping all the hoops, both C# & Godot LSP
seems to be working fine, albeit high memory usage by omnisharp & mono while LSP
is running and dotnet’s process not killing itself after running the command or
when omisharp is using it inside nvim. I manually kill both dotnet & mono
whenever I exit using pkill
and au VimLeave *
. Though the RAM usage has
maxxed out till ~1.2G with nvim + lsp and ~2.4G with godot running as well.