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

Space before Definitions #20

Open
mortymacs opened this issue May 17, 2023 · 11 comments
Open

Space before Definitions #20

mortymacs opened this issue May 17, 2023 · 11 comments
Labels
bug Something isn't working

Comments

@mortymacs
Copy link

Hi,

In Go, it shows space before interfaces definitions:
image

As the screenshot shows, functions and methods display correctly, but only the interface has spaces.

Cheers,
Mort

@VidocqH VidocqH added the bug Something isn't working label May 17, 2023
@mortymacs
Copy link
Author

I also saw it when I defined a type:
image

@mcauley-penney
Copy link

I can reproduce the problem. Looking at the content of the document symbols (which are returned by the LSP itself), the start character for the range, which lsp-lens uses to figure out where to place the extmark lines, is actually 5. Notice in the image below that the range start value for the Hello function is 0.

So, this appears to be a problem with Gopls, or lsp-lens has to figure out its own way to determine the indent for each extmark line it places.

image

@mortymacs
Copy link
Author

Hey @mcauley-penney, thanks for looking into this issue and providing the details. I'm on board with supporting this feature in the lsp-lens itself since it might be useful for other languages too.

@VidocqH
Copy link
Owner

VidocqH commented Oct 22, 2023

Hey @mcauley-penney, thanks for looking into this issue and providing the details. I'm on board with supporting this feature in the lsp-lens itself since it might be useful for other languages too.

Sorry for replay late. I think it can be solved with vim.fn.indent(lnum), always placed lsp-info at the start point of the given line, but I am not sure if this will broke with some languages.

@mortymacs
Copy link
Author

Hey @mcauley-penney, thanks for looking into this issue and providing the details. I'm on board with supporting this feature in the lsp-lens itself since it might be useful for other languages too.

Sorry for replay late. I think it can be solved with vim.fn.indent(lnum), always placed lsp-info at the start point of the given line, but I am not sure if this will broke with some languages.

Is it testable by something like this? :lua vim.fn.indent(5)

@VidocqH
Copy link
Owner

VidocqH commented Oct 23, 2023

Hey @mcauley-penney, thanks for looking into this issue and providing the details. I'm on board with supporting this feature in the lsp-lens itself since it might be useful for other languages too.

Sorry for replay late. I think it can be solved with vim.fn.indent(lnum), always placed lsp-info at the start point of the given line, but I am not sure if this will broke with some languages.

Is it testable by something like this? :lua vim.fn.indent(5)

Yes, this func returns how many indents the given line have. Namely the starting point of the given line.

Official docs: :h indent()

@mortymacs
Copy link
Author

I tried it, but still, I'm not sure what should I do in my LSP config. Would you please elaborate a little?

@VidocqH
Copy link
Owner

VidocqH commented Oct 26, 2023

I tried it, but still, I'm not sure what should I do in my LSP config. Would you please elaborate a little?

Sorry for the ambiguity, this func is to get the indent of the given line which is the starting point of the line, I mean maybe we can use this func to get the indent and always display lens info at that point rather than the point provided by LSP, this will eliminate all leading spaces but I am not sure if this will broke with some language. 🤔

Something like this:
截屏2023-10-27 上午1 54 41

@mortymacs
Copy link
Author

I tried it, but still, I'm not sure what should I do in my LSP config. Would you please elaborate a little?

Sorry for the ambiguity, this func is to get the indent of the given line which is the starting point of the line, I mean maybe we can use this func to get the indent and always display lens info at that point rather than the point provided by LSP, this will eliminate all leading spaces but I am not sure if this will broke with some language. 🤔

Something like this: 截屏2023-10-27 上午1 54 41

No problem at all! ;)
That's a good idea! It's also good to make it configurable (e.g. by_lsp or static) something like:

....
require'lsp-lens'.setup({
  ...
  advanced = {
    indent = "by_lsp",
  },
})

Also, one unrelated question, how did you enable the third section (icon Vidocq + 1) in your info? That's very interesting :)

@VidocqH
Copy link
Owner

VidocqH commented Oct 29, 2023

I tried it, but still, I'm not sure what should I do in my LSP config. Would you please elaborate a little?

Sorry for the ambiguity, this func is to get the indent of the given line which is the starting point of the line, I mean maybe we can use this func to get the indent and always display lens info at that point rather than the point provided by LSP, this will eliminate all leading spaces but I am not sure if this will broke with some language. 🤔
Something like this: 截屏2023-10-27 上午1 54 41

No problem at all! ;) That's a good idea! It's also good to make it configurable (e.g. by_lsp or static) something like:

....
require'lsp-lens'.setup({
  ...
  advanced = {
    indent = "by_lsp",
  },
})

Also, one unrelated question, how did you enable the third section (icon Vidocq + 1) in your info? That's very interesting :)

Okay, let it configurable is good LOL.

that section is git_author, I finished it two days ago and testing it for myself to see if there's a bug. Plan to publish it in next few days. 😂

@mortymacs
Copy link
Author

I just found another situation when the indentation needs to be adjusted
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants