Fix: indentation errors: add .editorconfig, health check, docs

This commit is contained in:
mathijs-bakker
2025-08-23 14:55:25 +02:00
committed by Mathijs Bakker
parent e1893bc5b7
commit bc46e06d31
5 changed files with 85 additions and 9 deletions

View File

@@ -1,3 +1,25 @@
[*.lua]
indent_size = 2
indent_style = space
# Consistent indentation for Godot projects.
# Copy and paste this in your own.
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
# GDScript
[*.gd]
indent_style = space
indent_size = 4
# C#
[*.cs]
indent_style = space
indent_size = 4

View File

@@ -17,11 +17,11 @@ Neovim plugin for Godot game development, using Neovim as an external editor. Pr
## Requirements
- Neovim 0.9+
- Godot 4.x+ with TCP LSP enabled
- `nvim-lspconfig`
- `nvim-dap` and `nvim-dap-ui` for debugging
- `nvim-treesitter`
- Neovim 0.9+
- Godot 4.x+ with TCP LSP enabled
- `nvim-lspconfig`
- `nvim-dap` and `nvim-dap-ui` for debugging
- `nvim-treesitter`
- Windows users must have [`ncat`](https://nmap.org/ncat/) in PATH
- Optional C# support requires:
- .NET SDK (dotnet)
@@ -64,7 +64,7 @@ require("godotdev").setup({
Below are the recommended settings for configuring the Godot editor for optimal integration with Neovim as your external editor. To access these settings, make sure that the **Advanced Settings switch is enabled** at the top of the **Editor Settings dialog**.
- `Editor Settings > Text Editor > Behavior > Auto Reload Scripts on External Change`
<details><summary>Show Screenshot -> Godot Editor Settings</summary><img src="assets/godot-editor-auto-reload-script.png"></details>
- `Editor Settings > Interface > Editor > Save on Focus Loss`
@@ -95,7 +95,7 @@ A workaround is to to create a small script which launches the file in Neovim.
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
```
1. Configure Godot: `Editor > Editor Settings > Text Editor > External` with full path and `{file} {line} {col}`.
<details><summary>Show Screenshot -> Godot Editor Settings</summary><img src="assets/godot-editor-settings-for-neovim.png"></details>
1. To make this work you always need to start Neovim like this:
@@ -162,7 +162,7 @@ A workaround is to to create a small script which launches the file in Neovim.
- `<leader>dB` -> Conditional breakpoint
### DAP UI
- `<leader>du` -> , Toggle UI
- `<leader>du` -> , Toggle UI
- `<leader>dr` -> , Open REPL
## C# Installation Support
@@ -172,3 +172,15 @@ A workaround is to to create a small script which launches the file in Neovim.
- .NET SDK (`dotnet`)
- C# LSP server (`csharp-ls` or `omnisharp`)
- Debugger (`netcoredbg`)
## Indentation
Godot expects **spaces, 4 per indent** (for both GDScript and C#).
If you see diagnostics like:
```
Used tab character for indentation instead of space as used before in the file. [-1] [-1]
```
You should configure indentation properly.
It's recommend adding an [`.editorconfig`](./.editorconfig) to your project.
For more info: `:help godotdev-indent`

View File

@@ -129,6 +129,29 @@ Optional C# support:
- C# LSP server (csharp-ls or OmniSharp)
- netcoredbg debugger
==============================================================================
INDENTATION *godotdev-indent*
Godot (both GDScript and C#) expects **spaces, 4 per indent**.
If you use tabs, the LSP often reports this diagnostic:
Used tab character for indentation instead of space as used before in the file. [-1] [-1]
To fix this, you should use an `.editorconfig` file. Godot, Neovim
(via editorconfig plugins), VSCode, and Rider all respect this.
Example `.editorconfig`:
[*.gd]
indent_style = space
indent_size = 4
[*.cs]
indent_style = space
indent_size = 4
See also: `:checkhealth godotdev`
==============================================================================
License *godotdev-license*

View File

@@ -2,6 +2,7 @@ godotdev godotdev.txt /*godotdev*
godotdev-checkhealth godotdev.txt /*godotdev-checkhealth*
godotdev-configuration godotdev.txt /*godotdev-configuration*
godotdev-external godotdev.txt /*godotdev-external*
godotdev-indent godotdev.txt /*godotdev-indent*
godotdev-intro godotdev.txt /*godotdev-intro*
godotdev-keymaps godotdev.txt /*godotdev-keymaps*
godotdev-license godotdev.txt /*godotdev-license*

View File

@@ -46,6 +46,23 @@ local function has_exe(name)
return vim.fn.executable(name) == 1
end
local function check_indent()
health.start("Indentation")
local handle = io.popen("grep -P '\t' -R --include='*.gd' --include='*.cs' . 2>/dev/null | head -n 1")
if handle then
local result = handle:read("*a")
handle:close()
if result ~= "" then
health.warn(
"Mixed indentation detected (tabs found in .gd or .cs files). Godot expects spaces, 4 per indent. See :help godotdev-indent"
)
else
health.ok("Indentation style looks consistent (no tabs in .gd or .cs files).")
end
end
end
function M.check()
health.start("Godotdev.nvim")
@@ -132,6 +149,7 @@ Make sure the Godot editor is running with LSP server enabled.
else
health.info(" C# checks skipped (csharp=false)")
end
end
check_indent()
end
return M