Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim.lsp.buf.format with range has strange behaviour? #20776

Open
ccbiozhaw opened this issue Oct 22, 2022 · 0 comments
Open

vim.lsp.buf.format with range has strange behaviour? #20776

ccbiozhaw opened this issue Oct 22, 2022 · 0 comments
Labels
bug issues reporting wrong behavior lsp

Comments

@ccbiozhaw
Copy link

ccbiozhaw commented Oct 22, 2022

Neovim version (nvim -v)

0.8

Language server name/version

latest

Operating system/version

macOS

Steps to reproduce using "nvim -u minimal_init.lua"

Python:

def fn(abc  ):
    print('HELLO'  )
    return abc   + 1

lua:

function fn(abc )
  print("hello" )
  return abc  + 1
end

ts:

function fn(abc  ) {
  console.log("hello" );
  return abc   + 1
}

command used:

:lua vim.lsp.buf.format({
range={
["start"] = {1,0},
["end"] = {2,-1}
}
})

Expected behavior

correct range formatting

Actual behavior

Python:
---- nothing happens ----

def fn(abc  ):
    print('HELLO'  )
    return abc   + 1

lua:
--- keeps adding newline after format range ---

function fn(abc)
  print("hello")
  return abc + 1

end

ts:
--- formats one line too little ---

function fn(abc  ) {
  console.log("hello" );
  return abc   + 1
}

I want to point out, that if I format the entire buffer with

lua vim.lsp.buf.format()

everything is formatted correctly. Python for example does not format no matter the range if I specify one

Log file

No response

@ccbiozhaw ccbiozhaw added bug issues reporting wrong behavior lsp labels Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior lsp
Projects
None yet
Development

No branches or pull requests

1 participant