VidocqH / lsp-lens.nvim

Neovim plugin for displaying references and difinition infos upon functions like JB's IDEA.
MIT License
252 stars 15 forks source link

Bug: Lua `local function` indentation #14

Closed olimorris closed 1 year ago

olimorris commented 1 year ago

I have the following Lua code:

local function get_commands(filename_prefix)
  return M.split_string(M.read_file(string.format("%s.commands", filename_prefix)), "\n")
end

and I noticed that there is a weird indentation which I perceive to be due to local:

Screen Shot 2023-03-18 at 13 04 43@2x

For anything without local it works just fine:

Screen Shot 2023-03-18 at 13 05 50@2x
barrett-ruth commented 1 year ago

Bump for this - having the same issue

VidocqH commented 1 year ago

I am trying to figure out how to solve it. This is because the Language Server Protocol (LSP) indicates that these functions are starting at this position, and it seems that this only occurs in Lua code.

barrett-ruth commented 1 year ago

I see. However, why is the actual column position of the function relevant? Couldn't you just ignore it end set it to 0 (nobody wants a codelens line not starting at the beginning of the line)

VidocqH commented 1 year ago

I see. However, why is the actual column position of the function relevant? Couldn't you just ignore it end set it to 0 (nobody wants a codelens line not starting at the beginning of the line)

It's because of indentations, for example:

class A {
    // lens starts from this column
    int add(int a, int b) {
        return a + b;
    }
}

Maybe I can set it to 0 with Lua file? Not sure if there is an impact. :)

barrett-ruth commented 1 year ago

Here's a thought - if the server is lua_ls and the line begins with "local," then set the indentation to 0. What do you think about this solution?

I'd actually like to write a PR for this to code more experience with OSS if that is ok.

VidocqH commented 1 year ago

Here's a thought - if the server is lua_ls and the line begins with "local," then set the indentation to 0. What do you think about this solution?

I'd actually like to write a PR for this to code more experience with OSS if that is ok.

Great! Thank you in advance. I am currently a bit occupied. :)