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

feat(lspsaga & lualine): Show symbols in lualine. #402

Merged
merged 2 commits into from
Jan 4, 2023

Conversation

Jint-lzxy
Copy link
Collaborator

#398 (comment). This can solve rendering problems such as displaying 'cursorcolumn'. Symbol_in_winbar will cause the space between bufferline and the file to be inaccessible by built-in features.

This is a rough setup and should require additional testing 👍

@Jint-lzxy Jint-lzxy requested a review from ayamir January 4, 2023 06:04
@CharlesChiuGit
Copy link
Collaborator

I think a better way to do this is to include the filename in the winbar too, so it will always has a place holder for winbar.
Like this:
圖片

@Jint-lzxy
Copy link
Collaborator Author

I think a better way to do this is to include the filename in the winbar

IMO this is similar to the function of bufferline (and their location is very close). Besides, the problem of built-in rendering has not been resolved.

@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented Jan 4, 2023

I agree with your view point.
But I don't think lualine supports click to jump at this moment?
If u place breadcrumbs in winbar, lspsaga has built-in support for click to jump.

@Jint-lzxy
Copy link
Collaborator Author

I have made adjustments to support click to jump 👍

click_support = function(node, clicks, button, modifiers)
local st = node.range.start
local en = node.range["end"]
if button == "l" then
if clicks == 2 then
-- double left click to do nothing
else -- jump to node's starting line+char
vim.fn.cursor(st.line + 1, st.character + 1)
end
elseif button == "r" then
if modifiers == "s" then
print("symbol_winbar")
end
vim.fn.cursor(en.line + 1, en.character + 1)
elseif button == "m" then
-- middle click to visual select node
vim.fn.cursor(st.line + 1, st.character + 1)
vim.api.nvim_command([[normal v]])
vim.fn.cursor(en.line + 1, en.character + 1)
end
end,
},

This setting is position independent because lspsaga has already processed the formatted string when returning.

@CharlesChiuGit
Copy link
Collaborator

Also, IMO, the center section of lualine is more suitable for git-blames.

圖片

With this setup, we won't see git-blames floating around all the time which is very distracting.

@CharlesChiuGit
Copy link
Collaborator

I have made adjustments to support click to jump 👍

click_support = function(node, clicks, button, modifiers)
local st = node.range.start
local en = node.range["end"]
if button == "l" then
if clicks == 2 then
-- double left click to do nothing
else -- jump to node's starting line+char
vim.fn.cursor(st.line + 1, st.character + 1)
end
elseif button == "r" then
if modifiers == "s" then
print("symbol_winbar")
end
vim.fn.cursor(en.line + 1, en.character + 1)
elseif button == "m" then
-- middle click to visual select node
vim.fn.cursor(st.line + 1, st.character + 1)
vim.api.nvim_command([[normal v]])
vim.fn.cursor(en.line + 1, en.character + 1)
end
end,
},

This setting is position independent because lspsaga has already processed the formatted string when returning.

Ok, that's pretty cool! Nice!

@Jint-lzxy
Copy link
Collaborator Author

Jint-lzxy commented Jan 4, 2023

With this setup, we won't see git-blames floating around all the time which is very distracting.

It is rendered as virtual text when you hover over a line :) Like so:
git-blame-info

@CharlesChiuGit
Copy link
Collaborator

Yeah, it is virtual text. But it still makes me feel distracting, never mind, it's just my opinion. I'll keep it for myself.

@Jint-lzxy
Copy link
Collaborator Author

Yeah, it is virtual text. But it still makes me feel distracting, never mind, it's just my opinion. I'll keep it for myself.

Another reason for putting symbols here is there are no elements in the center of lualine now. Of course, rendering git blame is also a great idea 👍 Let's wait for @ayamir to review these changes :)

@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented Jan 4, 2023

Besides, the problem of built-in rendering has not been resolved.

I don't think it's lspsaga's fault to blame. It's an upstream issue. In neovim nightly(0.9.0), the filename placeholder in winbar will always persist, but in 0.8.2, the rendering issue mentioned in #398 (comment) does exist.

In 0.9.0(nightly):
圖片

In 0.8.2(stable):
圖片

@Jint-lzxy
Copy link
Collaborator Author

I don't think it's lspsaga's fault to blame.

This occurs only when show_file = false is set.

The main issue is that currently lspsaga will occupy a space between bufferline and the file, and this space is independent of file rendering. This means that any built-in full-screen rendering feature (For example, rendering vertical bars that occupy the entire screen) will not touch bufferline (i.e., there will always be a gap between bufferline and the file if lspsaga doesn't render here)

@Jint-lzxy Jint-lzxy marked this pull request as ready for review January 4, 2023 08:26
@ayamir
Copy link
Owner

ayamir commented Jan 4, 2023

Nice feature! Always showing filename in winbar indeed duplicates with bufferline. Tested for click support and it works normally. I prefer to put getcwd to the right with this feature like this:
image

@CharlesChiuGit CharlesChiuGit merged commit 789ba37 into main Jan 4, 2023
@CharlesChiuGit CharlesChiuGit deleted the lualine-symbols branch January 4, 2023 10:56
vkingw pushed a commit to vkingw/nvimdots that referenced this pull request Feb 7, 2023
YanTree pushed a commit to YanTree/nvim that referenced this pull request Apr 9, 2023
@Jint-lzxy Jint-lzxy mentioned this pull request Apr 27, 2023
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants