Skip to content

Instantly share code, notes, and snippets.

@Guilospanck
Last active June 20, 2025 18:35
Show Gist options
  • Save Guilospanck/a62e864fa9f4527ae0d966e3849c49c2 to your computer and use it in GitHub Desktop.
Save Guilospanck/a62e864fa9f4527ae0d966e3849c49c2 to your computer and use it in GitHub Desktop.
Godot (C# and GDScript) with nvim

Run Godot with nvim

It uses Roslyn instead of omnisharp.

After you have all the below done, before developing your game you will have to initialise nvim with:

gnvim

Instead of nvim, for example. By the way, this gnvim is whatever alias you set in the Create an alias section.

Create an alias

  • Create an alias in your *rc (.bashrc, .zshrc) file:
alias gnvim='nvim --listen /tmp/godot.pipe'

You can name it whatever you want, obviously.

Godot editor changes

GDScript

  • In Godot editor, go to "Editor Settings" (CMD ,), search for "External" (under "Text Editor") and set:

    • Exec path: to your nvim path (which nvim). Example: /opt/homebrew/bin/nvim
    • Exec flags: --server /tmp/godot.pipe --remote-send "<esc>:n {file}<CR>:call cursor({line},{col})<CR>"
    • Use external editor: checked ✅

C#

Note

Also be sure to have the .NET installed. Check the Godot Docs for more info.

  • In Godot editor, go to "Editor Settings" (CMD ,), search for "External" (under "Dotnet") and set:

    • External editor: Custom
    • Custom Exec path: to your nvim path (which nvim). Example: /opt/homebrew/bin/nvim
    • Custom Exec path arguments: --server /tmp/godot.pipe --remote-send "<esc>:n {file}<CR>:call cursor({line},{col})<CR>"
  • Add this to your config file (.bashrc, .zshrc, others):

export DOTNET_ROOT=/usr/local/share/dotnet
export PATH=$PATH:$DOTNET_ROOT

Setting lsp

GDScript

In your lspconfig.lua config:

-- GDScript
require('lspconfig')['gdscript'].setup {
  name = 'godot',
  -- This info exists in the Editor Settings > Network > Language server
  cmd = vim.lsp.rpc.connect('127.0.0.1', 6005),
}

C#

lspconfig.lua file.

First, add a new registry to Mason:

{
  'mason-org/mason.nvim',
  opts = {
    registries = {
      'github:mason-org/mason-registry',
      'github:Crashdummyy/mason-registry', -- <- This
    },
  },
}

Then, access the Mason with the command :Mason and install roslyn.

After that, add also this:

-- C#
{
  'seblyng/roslyn.nvim',
  ft = 'cs',
  ---@module 'roslyn.config'
  ---@type RoslynNvimConfig
  opts = { },
},

Setting debug

Add this snippet to your dap (mfussenegger/nvim-dap) plugin

    -- This info exists in the Editor Settings > Network > Debug adapter
    dap.adapters.godot = {
      type = 'server',
      host = '127.0.0.1',
      port = 6006,
    }

GDScript

Additionally:

    dap.configurations.gdscript = {
      {
        type = 'godot',
        request = 'launch',
        name = 'Launch scene',
        project = '${workspaceFolder}',
        launch_scene = true,
      },
    }

C#

Additionally:

-- C#
dap.configurations.cs = {
  {
    type = 'godot',
    request = 'launch',
    name = 'Launch scene',
    project = '${workspaceFolder}',
    launch_scene = true,
  },
}

Treesitter

Ensure installed:

ensure_installed = { 
  -- others,
  'gdscript', 'godot_resource', 'gdshader', 'c_sharp'
}

Telescope

Optional, but useful. Ignore some godot files. Here's my config:

      require('telescope').setup {
        pickers = {
          live_grep = {
            additional_args = function()
              return {
                '--hidden',
                '--no-ignore',
                -- others,
                '-g',
                '!.godot', -- <- Godot related
                '-g',
                '!.uid',  -- <- Godot related
              }
            end,
          },
        },
        extensions = {
          ['ui-select'] = {
            require('telescope.themes').get_dropdown(),
          },
        },
        defaults = {
          file_ignore_patterns = {
            -- others,
            '.godot', 'server.pipe', '.uid'
          },
        },
      }

Conform

Optional.

formatters_by_ft = {
  cs = { 'csharpier' },
},
formatters = {
  csharpier = {
    command = 'dotnet-csharpier',
    args = { '--write-stdout' },
  },
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment