withered-magic / starpls

An LSP implementation for Starlark, the configuration language used by Bazel and Buck2.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected indentation for blank lines between statements

hauserx opened this issue · comments

Simple example:

def x():
    y = 4

    z = 2

Result:

image

Hmm, do you know what your indentation settings are for your editor, of if the indentation in the example is mixed (e.g. tabs for one line and spaces for another)? I'm not able to reproduce this running on VSCode with tabs converted to four spaces, which is how starpls treats tabs.

Alternatively, if you upload an example repro .bzl file, I can try looking to see if something unexpected is happening with indentation.

I am using fresh install of neovim in WSL2 and looks by default it was using windows CRLF endlines... The issue is fixed by using unix endlines. So seems this issue maybe by under windows/when using CRLF endlines.

Attaching small script to reproduce the issue:
test_starpls_crlf.txt

Output:

Diagnostics: {
  "jsonrpc": "2.0",
  "method": "textDocument/publishDiagnostics",
  "params": {
    "diagnostics": [
      {
        "message": "Unexpected indentation",
        "range": {
          "end": {
            "character": 0,
            "line": 3
          },
          "start": {
            "character": 0,
            "line": 3
          }
        },
        "severity": 1,
        "source": "starpls"
      }
    ],
    "uri": "file:///fakepath/sample.bzl",
    "version": 1
  }
}

Thank you! I use WSL2 but not with CRLF line endings so admittedly haven't actually tested this too much 😅 I'll try to have a fix out soon, should be straightforward