nvimdev / lspsaga.nvim Goto Github PK
View Code? Open in Web Editor NEWimprove neovim lsp experience
License: MIT License
improve neovim lsp experience
License: MIT License
The following line fails with String cannot contain newlines
when trying to cycle through rust warnings.
Warning
It also seems like the coloring is wrong when displaying the error:
For some language servers with very slow performance, such as pyls, lspfinder uses buf_request_sync, which awaits the response and renders the window. This is a blocking behavior. If the language server responds very slowly, it means waiting for it, which is very bad.
vim.loop.new_async
buf_request
need rewrite render window.I mapped C-U to scroll up...
nnoremap <silent> <C-u> <cmd>lua require('lspsaga.hover').smart_scroll_hover(1)<CR>
But it broke my scroll when the hover wasn't enabled, to my surprise it seems to be fixed to <C-f>
is this intended?
When I open the document without lsp clients, It always shows
[lspsaga] No lsp client available
And if I fail to find signature
No signature help available
It would be great If we can have options that can silence these kinds of messages.
Hi,
I tried to use range code action for refactoring, but it doesn't work. Here's the gif:
This is the action that is being processed (I printed it out from do_code_action
function):
{
command = {
arguments = { {
action = "function_scope_1",
endLine = 43,
endOffset = 8,
file = "/home/kristijan/github/coc-explorer/src/diagnostic/binder.ts",
refactor = "Extract Symbol",
startLine = 40,
startOffset = 1
} },
command = "_typescript.applyRefactoring",
title = "Extract to method in class 'DiagnosticBinder'"
},
kind = "refactor",
title = "Extract to method in class 'DiagnosticBinder'"
}
Language server: typescript-language-server
I also tried extracting to function in go, but same thing.
All the code seems to be just for implement function, so the code quality is very low. Need some refactoring and rewrite.
Currently it is not possible to customize the colors of all highlight groups in a colorscheme.
The problem is that lspsaga.nvim
defines and overwrites all groups after calling init_lsp_saga(opts)
with a call to https://github.com/glepnir/lspsaga.nvim/blob/main/lua/lspsaga/syntax.lua.
My current workaround is to copy the function found in syntax.lua
and call my custom function after the call to init_lsp_saga(opts)
require("lspsaga").init_lsp_saga({
use_saga_diagnostic_sign = false,
rename_prompt_prefix = '>',
max_diag_msg_width = 80,
})
-- color scheme can not be used as the lspsaga plugin would overwrite the colors again
-- this function gets called after the lspsaga plugin was loaded and defines the final colors
require("settings.lspsaga").overwrite_highlight()
It would be nice if all the highlight groups used by the plugin can be overwritten in a colorscheme instead of calling a custom function after the plugin was loaded.
This relates to:
Give the following init file:
local cmd = vim.cmd
cmd [[packadd packer.nvim]]
require('packer').startup(function(use)
use {'wbthomason/packer.nvim', opt = true}
use {'glepnir/lspsaga.nvim'}
use 'scalameta/nvim-metals'
end)
local saga = require 'lspsaga'
saga.init_lsp_saga()
vim.o.shortmess = string.gsub(vim.o.shortmess, 'F', '') .. 'c'
local function map(mode, lhs, rhs, opts)
local options = {noremap = true, silent = true}
if opts then
options = vim.tbl_extend('force', options, opts)
end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end
map('n', 'gr', '<cmd>lua require"lspsaga.provider".lsp_finder()<CR>')
cmd [[augroup lsp]]
cmd [[autocmd!]]
cmd [[autocmd FileType scala,sbt lua require("metals").initialize_or_attach({})]]
cmd [[augroup end]]
When I attempt to use lsp_finder()
I get the following error message:
Error executing vim.schedule lua callback: ...site/pack/packer/start/lspsaga.nvim/lua/lspsaga/libs.lua:21: bad argument #1 to 'pairs' (table
expected, got nil)
I'm still digging into finding out what the issue is, and I can give you detailed instructions on how to use nvim-metals
if you want, but I'm curious if it has to do with the fact that I don't use nvim-lspconfig
at all to manage the connect with metals, but rather my own plugin handles that all. Could that potentially be the issue here?
While looking at the readme and looking at the hover example, they look great. In my situation however without any custom settings I'm seeing the hovers as extremely long and tall. Is there anything that I could check or edit to keep this from happening. As you can see in the screenshot, there is a lot of space available, so I'm confused why it's so tall and narrow.
Hey, ๐
Sorry for opening that many issues. You plugin is really appealing, so I would love to use it and not just quit because I'm not 100% happy with it. I hope that is fine and you understand it as constructive critics. This is actually the "weakest" of all the issues I opened.
While starting to setup and use your plugin I was a bit confused about the hover functionality. It kinda stands out to all the rest. In first place because everything else has a custom function, but here you fall back to use NeoVims default and only customize the handler. This makes sense, as for other functions like vim.lsp.diagnostic.goto_next()
can't be overwritten. So you must provide new functions for them.
But as this kinda stands out, why not letting the user decide? So maybe he agrees with you that this is the most comfortable approach and wants to customize the handler. Or he disagrees and prefers a custom function by this plugin.
For the first case it would be simple enough to provide the user with the simple docs hint how to set the handler to a function fo your plugin. Its basically a one-liner. You could even make use of vim.lsp.with()
and make it configurable (although that might be bad with configurations at two different places).
The advantage of a separate command would be for example lazy loading. Many plugin/package manager provide the feature to lazy load a plugin when necessary. With the LSP handler this is hardly possible. It would be great if it could make use of the FuncUndefined
event like lazy loads. But as this is a Lua function and not VimScript, this won't work. Therefore the only option I see would be to have a separate command. There might be even more advantages/opinions why having a separate command available if necessary might be of interest.
I'm curious what you thoughts are in regards of this.. I like the idea to empower the user who he would like to use the cool features your plugin provide. Thanks for reading!
Ehy man,
so, I use this plugin for some features, like hover, finder, references, etc, couple of days ago was working perfectly.
Now, since yesterday afternoon, all of these actions are giving me this error.
E5108: Error executing lua vim/shared.lua:199: Expected table, got nil
You can use this as repro repo
I just hit on this while using nvim-metals
and Scala. As far as I know in textDocument/references
requests the context is necessary and the reference requests lspsaga sends, there is no ReferenceContext
sent. In my case, this causes nothing to be returned from the server since it's an invalid request.
You can see the difference when you look at built-in nvim request vs the lspsaga request.
[Trace - 04:56:00 PM] Received request 'textDocument/references - (7)'
Params: {
"context": {
"includeDeclaration": true
},
"textDocument": {
"uri": "file:///Users/ckipp/Documents/scala-workspace/tester/src/main/scala/example/Main.scala"
},
"position": {
"line": 6,
"character": 6
}
}
[Trace - 04:56:36 PM] Received request 'textDocument/references - (18)'
Params: {
"textDocument": {
"uri": "file:///Users/ckipp/Documents/scala-workspace/tester/src/main/scala/example/Main.scala"
},
"position": {
"line": 6,
"character": 6
}
}
Notice the missing "context"
. You can read more about his here: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references
This may be related to what's going on in #5
Hey,
I adopted the style of the borders in the init function. But while starting to use the plugin, I realized that the border style does not always get applied. Then I looked into the code and saw that the users configuration gets most likely never respected. Instead it is chosen random like all other the place, individual for each use case.
Why is that? Did I got this configuration option wrong?
when using tsserver
running lua require 'lspsaga.codeaction'.code_action()
will show the proper actions popup but selecting any action doesn't do anything. While the native LSP code action lua vim.lsp.buf.code_action()
works fine.
Hey,
thanks for this great looking plugin. It is really an eye catcher.
I was just about to configure this plugin for my own setup. Unfortunately I must recognize that this is overwriting the diagnostics signs. I do set them somewhere else and I would prefer to not redefine them here via copy-paste or rely on this plugin for setting the signs.
I was already about to come up with my own implementation and open a PR. But I recognized it might be not that easy. So my initial idea was to check if the sign is already defined before setting it here. But as there are default diagnostic sign definitions by NeoVim itself, this does not help.
So the next obvious approach would be to make these configuration options to lspsaga.nvim optional and only set signs if the user explicitly asks the plugin to do so? You don't have optional options yet, that's why I haven't yet just implemented it and open a PR. I would like to ask you first for your opinion to this whole topic and what you think would be the best solution for the problem.
Thanks!
Consider changing background color and text color. Would it be possible to use the terminal emulator colors, where neovim was started with?
Hey,
so great to see your plugin becoming better and better! ๐
I recognized that in the window with all the references etc using the lsp_finder
function, all paths are relative to the users home directory. At least for me this is the case. And for me this sometimes end up with really long paths. Which make the window huge and "bad" to read. What would you think about making them relative to the projects root? I'm not sure if it is possible to get the root as detected by the LSP server. But probably it would be fine to set them relative to NeoVims current directory as well. Not that powerful, but better then relative to $HOME
. Wouldn't it? ๐ค
Thanks for the great work on this plugin ๐
Ive noticed whilst trying it out that when I hover over something with a lot of information the windows don't seem to have safe default limits and in the case of the vertical size, the height isnt truncated if there is too much content like in the example below, it overlaps with my tabline and statusline in this case
Hi there! Is it possible to make the first row on the hover doc to be multiple lines? eg.
I expect the first separator line to get placed at the line where that is marked with a red line. This is causing some issue when it doesn't have enough space until the {
symbol so the highlight got messed up. Here's an example
Thanks in advance!
I've noticed when trying to use the code action commands in a lua
file with sumneko_lua
lsp if there aren't any available at the current postion.
require('lspsaga.codeaction').code_action()
require('lspsaga.codeaction').range_code_action()
I get Error executing lua ...ack/packer/start/lspsaga.nvim/lua/lspsaga/codeaction.lua:27: bad argument #1 to 'pairs' (table expected, got nil)
, it works fine if I happen to use the mapping in a position where there is a valid code action.
I think it would be better if this function did not error and was able to gracefully handle being called where there aren't any code actions
Hello!
First of all - plugin is AWESOME, thank you for doing that!
Now to the problem - after installing i noticed that only thing that was kinda working was hover
function, all the others did nothing.
I dig in and noticed places like
https://github.com/glepnir/lspsaga.nvim/blob/main/lua/lspsaga/codeaction.lua#L62
where you hardcode number 1
, so I print my response and it was like:
{
[2] = {
result = { {
command = {
arguments = { {
action = "add",
key = "Lua.diagnostics.globals",
uri = "file:///Users/alexanderpopov/.local/share/nvim/site/pack/packer/start/lspsaga.nvim/lua/lspsaga/codeaction.lua",
value = "printt"
} },
command = "lua.config",
title = "Mark defined global"
},
kind = "quickfix",
title = "Mark `printt` as defined global."
}, {
command = {
arguments = { {
action = "add",
key = "Lua.diagnostics.disable",
uri = "file:///Users/alexanderpopov/.local/share/nvim/site/pack/packer/start/lspsaga.nvim/lua/lspsaga/codeaction.lua",
value = "undefined-global"
} },
command = "lua.config",
title = "Disable diagnostics"
},
kind = "quickfix",
title = "Disable diagnostics (undefined-global)."
}, {
command = {
arguments = { {
action = "add",
key = "Lua.diagnostics.globals",
uri = "file:///Users/alexanderpopov/.local/share/nvim/site/pack/packer/start/lspsaga.nvim/lua/lspsaga/codeaction.lua",
value = "printt"
} },
command = "lua.config",
title = "Mark defined global"
},
kind = "quickfix",
title = "Mark `printt` as defined global."
}, {
command = {
arguments = { {
action = "add",
key = "Lua.diagnostics.disable",
...
so, as you can see there is [2]
index, and since you was expecting [1]
it don't work...
there are other places like
https://github.com/glepnir/lspsaga.nvim/blob/main/lua/lspsaga/provider.lua#L4
where you expect [1]
and for me it looks like
{
[3] = {
_on_attach = <function 1>,
callbacks = <1>{},
cancel_request = <function 2>,
config = {
capabilities = {
callHierarchy = {
dynamicRegistration = false,
<metatable> = <2>{
__tostring = <function 3>
}
},
textDocument = {
codeAction = {
codeActionLiteralSupport = {
codeActionKind = {
valueSet = { "", "Empty", "QuickFix", "Refactor", "RefactorExtract", "RefactorInline", "RefactorRewrite", "Source", "SourceOrganizeImports", "quickfix", "refa
ctor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" },
<metatable> = <table 2>
},
<metatable> = <table 2>
},
dynamicRegistration = false,
<metatable> = <table 2>
},
completion = {
completionItem = {
commitCharactersSupport = false,
deprecatedSupport = false,
documentationFormat = { "markdown", "plaintext" },
preselectSupport = false,
snippetSupport = false,
<metatable> = <table 2>
},
completionItemKind = {
valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 },
<metatable> = <table 2>
},
contextSupport = false,
dynamicRegistration = false,
<metatable> = <table 2>
},
declaration = {
...
I'm not sure why is that, any ideas?
I can try to help with PR if needed.
๐
Typical workflow (at least for me): go to the next diagnostics -> open available code actions
The "problem" is that the first action opens a floating window for the diagnostics (which is intended and nice), but it does not close when the window opens to select a code action.
For other combinations this already works. E.g. having the diagnostics open and then use the hover function. This closes the diagnostics first and then open the hover window.
I'm not sure what's the most helpful information to give you to chase this down, but please let me know what I can provide to help. My workflow involves often splitting my terminal with tmux so that nvim is only on half my screen. When this is done often any bigger floats get slammed up against the side. The border actually looks fine, but it's like the text shifts over a bit too far. Here is an example of what I mean while in Lua.
Here is another example in Scala using Metals when I have full screen:
However, if I then split my screen and do the hover on the same symbol it looks like this:
Hello,
Thanks a lot for this life-changing plugin for neovimers. It is amazing!
I observed the lsp_finder()
function is not listing the definitions/references. I tried it in a Python repository.
lua require'lspsaga.provider'.lsp_finder()
Although vim.lsp.buf.references()
is able to find the references.
I am using neovim version:
NVIM v0.5.0-dev+69103ff0c
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20210125-92101-1jnyczu/build/config -I/tmp/neovim-20210125-92101-1jnyczu/src -I/usr/local/include -I/tmp/neovim-20210125-92101-1jnyczu/deps-build/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20210125-92101-1jnyczu/build/src/nvim/auto -I/tmp/neovim-20210125-92101-1jnyczu/build/include
Compiled by [email protected]
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-69103ff/share/nvim"
Run :checkhealth for more info
Also updated my nvim-lspconfig
to the latest version using PluginUpdate
.
Thanks for your help in advance
Hi, I would like to know how this plugin interacts with something like fzf-lsp. Can I use your plugin along side with this? I like the style of your plugin, but I would like keep the functionality of fzf.
Thanks!
You recently added the ability to change colors to highlight the current active entry in the finder. This is configured by two color values. I think it would be cool if you would add a new custom highlight group and then link the cursor line to this group. This still allows the user to easily change the highlight. But instead of defining raw color values you could also create a highlight link. So for example would I link it to the Search
highlight group of my theme. But now I need to copy paste the colors. And I can't even apply "effects" like bold text. And now if I change my theme, I must also change the colors here again...
Would be a cool addition.
Btw: your recent improvements on the finder window are great! ๐ช
nnoremap [e :Lspsaga lsp_jump_diagnostic_next
nnoremap ]e :Lspsaga lsp_jump_diagnostic_prev
instead of
nnoremap [e :Lspsaga diagnostic_jump_next
nnoremap ]e :Lspsaga diagnostic_jump_prev
nnoremap :Lspsaga open_float_terminal
tnoremap <C->:Lspsaga close_float_terminal
instead of
nnoremap :Lspsaga open_floaterm
tnoremap <C->:Lspsaga close_floaterm
Hi there! It's a bit hard to explain, I'll just show the current one vs the one that I want.
So, some hover result doesn't have an extra detail like this one, I think it would be better if we don't show the extra line at the bottom (like the second image) but still show it on a longer result / if it has more than 1 line (last image).
The code for the second image was taken from your old config before releasing lspsaga btw.
The highlights seems to be broken because I have a variable filled with "\\"
and it tries to treat that as a literal \
unescaped.
I'm on literally the latest master commits of neovim/lspsaga at the time of writing. In rust source files, if that matters.
<cmd>lua require"lspsaga.provider".lsp_finder()<CR>
Yields: lspsaga/libs.lua:21: bad argument #1 to 'pairs' (table expected, got nil)
<cmd>lua require'lspsaga.provider'.preview_definition()<CR>
Yields: Error executing lua vim/shared.lua:199: Expected table, got nil
To reproduce:
lua require('lspsaga.hover').render_hover_doc()
require('lua lspsaga.hover').smart_scroll_hover(-1)
E5108: Error executing lua .../.config/nvim/plugged/lspsaga.nvim/lua/lspsaga/hover.lua:55: Cursor position outside buffer
In visual mode when some range is selected vnoremap <silent><leader>ca <cmd>'<,'>lua require('lspsaga.codeaction').code_action()<CR>
fails with the following error:
E5108: Error executing lua ...hare/vim-plugins/lspsaga-nvim/lua/lspsaga/codeaction.lua:20: attempt to index local 'response' (a nil value)
Is code_action()
supposed to work with range?
Just installed it yesterday, but I'm already enjoying this plugin so much. ๐
One thing I realized which is a problem while working is that previews (especially the definition preview) is not open folds. I assume this is just opening the file into a regular buffer and scroll to the specific line. So this automatically applies my usual fold settings (which I use from Treesitter). While I still like my folds and think they are useful when opening a file, for a preview they are more obstructive. Do you think it is possible to open them? Maybe set the foldlevel
option for the preview window to a very high value or just "run" zR
in the window. What ever fits better the code I would say.
Another idea: If I remember the LSP specification correctly, the Location
object includes a range. This would allow to trim the preview to just the range of the definition. So there is nothing shown below. Trimming the buffer seems to cumbersome, but adopting the window height to the range height should be perfectly fine.
Maybe you are doing this already and I just don't see this as I have the folds. Just came into my mind and I haven't checked the code.
I would like to do project-wide editing with opening all usages of a variable for potential modification.
Coc offers split windows for project-wide editing on :CocSearch
.
Is this in scope of this project?
Hi ๐
Its me again ๐
I saw that you overwrite the lsp handler for the diagnostics. I guess you do so to provide the user with some in your opinion good defaults. And also I personally would argue that this shouldn't be in the scope of this plugin. But besides that, the big downside is that it overwrites what the user maybe already personalized. So do I for example prefer to get diagnostics live while I'm typing. You disable this.
As I can tell from the code, on a first glance it does not look like customizing the handler as you do it (with vim.lsp.with()
) this is not required to make the rest of your plugin working. Right? So if you insist (and that might make sense, plus it is your plugin) to keep the handler, would it be possible to make this optional? I would rather stick with my handler, but still take profit from your plugins nice visual additions in the floating window.
Thanks for the feedback in advanced!
Once the rename popup showing, it seems like there's no way to cancel it unless you actually choose a name and hit enter.
Ideally (or if you want to keep normal mode as an option for editing the rename's text) and/or would cancel the rename and hide the floating window.
Hi,
today I was renaming some longer method name, and noticed that cursor stays at middle of screen while i type. I noticed that my default scrolloff
and sidescrolloff
is being used.
Steps to reproduce:
-- init.lua
vim.o.scrolloff = 8
vim.o.sidescrolloff = 15
vim.o.sidescroll = 5
:Lspsaga rename
on somethingHi,
what do you think about adding current line diagnostic and signature help? Currently we have these in neovim:
Diagnostic:
vim.lsp.diagnostic.show_line_diagnostics()
Signature:
vim.lsp.buf.signature_help()
And I'm using it like this:
vim.cmd [[autocmd CursorHold * lua vim.lsp.diagnostic.show_line_diagnostics()]]
vim.cmd [[autocmd CursorHoldI * silent! lua vim.lsp.buf.signature_help()]]
But it would be nice to have this nice styling to it.
Thanks!
I would be nice to have a configuration similar to finder_action_keys
for the code actions menu. I use <ESC>
to close instead of q
and would like to keep it consistent
For example here's what I have in my config:
finder_action_keys = {
open = '<CR>', vsplit = 'v', split = 's', quit = '<ESC>'
},
When I attempt to run this mapping:
nnoremap <silent> gd <cmd>lua require'lspsaga.provider'.preview_definition()<CR>
Have you any idea?
I've noticed that in floats when there are multiple new lines there is an odd highlight for a couple of characters.
Here is another minimal one with what the markdown looks like:
[Trace - 07:21:24 PM] Sending response 'textDocument/hover - (26)'. Processing request took 5ms
Result: {
"contents": {
"kind": "markdown",
"value": "```scala\nval partitions: scala.collection.immutable.Iterable[SetBreakpointsArguments]\n```\n\n**With synthetics added**:\n```scala\nval currentClassNames \u003d partitions.map(_.getSource().getPath())(scala.collection.immutable.Iterable.canBuildFrom[java.lang.String]).toSet\n```"
}
}
Hi, I'm trying to test lspsaga with nvim. When 2 function is activated at the same time, popups are overlapped with each other. Can we have a workaround or able to set the priority of each popup?
Config:
nnoremap <silent> K :Lspsaga hover_doc<CR>
autocmd CursorHold * :Lspsaga show_line_diagnostics
Demo
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.