Closed urandom closed 4 years ago
Hi! I'm sorry to hear you've found getting set up difficult.
I've added a complete example (which is basically just putting the existing usage example sections together in one) to the README; let me know if that doesn't work for you.
I will note that if you want to customize the statusline segment, you are going to need to write some Lua yourself - I'd suggest looking at https://github.com/wbthomason/lsp-status.nvim/blob/master/lua/lsp-status/statusline.lua for an example.
Finally, I definitely admit that more docs would help - PRs for this are welcome!
Let me know if you're still confused or having issues - I'll leave it to you to close this.
Thanks, that looks looks a lot more comprehensive and understandable. fyi. i also managed to set it up myself when i found a random reddit comment about the plugin. I ended up with the following config:
lua <<EOF
local nvim_lsp = require('nvim_lsp')
local compl = require('completion')
local lsp_status = require('lsp-status')
lsp_status.config({
kind_labels = vim.g.completion_customize_lsp_label
})
lsp_status.register_progress()
local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
compl.on_attach(client, bufnr)
lsp_status.on_attach(client)
end
-- vimls,
local servers = {'gopls', 'rust_analyzer', 'pyls_ms', 'tsserver', 'jsonls', 'ccls', 'bashls', 'texlab', 'sumneko_lua'}
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = on_attach,
}
end
EOF
function! StatuslineLsp() abort
if exists("b:lsp_current_function") == 1
return b:lsp_current_function
end
return ""
endfunction
I went with lsp_current_function instead of the status function, as that one appeared to generate a lot more than the function "stuff" with it. And it included a non-configurable prefix with a glyph that wasn't working for me.
but what exactly does:
lsp_status.config({
kind_labels = vim.g.completion_customize_lsp_label
})
do?
The status
function is meant as an example; it builds off of the other features to create a more comprehensive statusline component.
And it included a non-configurable prefix with a glyph that wasn't working for me.
I should probably make status
more configurable, true.
but what exactly does:
lsp_status.config({ kind_labels = vim.g.completion_customize_lsp_label })
do?
The config
function lets you change settings for the module, per https://github.com/wbthomason/lsp-status.nvim#configuration
That snippet in particular is changing the kind_labels
setting, which configures a map from LSP symbol kind names to whatever label you'd like to use to represent that kind name in the current_function
value, e.g. to use an icon or glyph.
@urandom I have also now added Vim help file docs in docs/
with more detailed API documentation.
Thanks. That should hopefully make things clearer for anyone else as well.
For someone who's new to Vim I had no idea how to integrate it into my status line after all that :-D.
The missing link for me personally was:
set statusline=
set statusline+=%{LspStatus()} " or w/e your function is called.
It's not clear to me how the provided statusline lua file (https://github.com/wbthomason/lsp-status.nvim/blob/master/lua/lsp-status/statusline.lua) is getting called. Could you elaborate? I usually have to do this in my init.vim
file by luafile path/to/file.lua
but I see no such call in your dotfiles.
Sure. It's in two places in my dotfiles. https://github.com/wbthomason/dotfiles/blob/linux/neovim/.config/nvim/plugin/statusline.vim#L76 adds the segment to the statusline, and https://github.com/wbthomason/dotfiles/blob/linux/neovim/.config/nvim/autoload/statusline.vim#L154 actually calls the Lua function.
Got your setup working, just need to fix the "ghosting" in this case edit: was due to my activeactive
after the warning symbol. :-)vista vim
plugin config, good old grep -R 'statusline' .
. :smile:
@urandom @nymann I'm going to go ahead and close this, given the documentation improvements in 9157ae5 through d6ad842. Feel free to reopen/make a new issue if you're still running into difficulty!
Hi,
I'm trying to set up this plugin to show the current function in the status line. Unfortunately, I don't even know how to start with that. The readme appears to be the only documentation, and its example use shows 4 snippets of code. However, only the first one seems complete, as the others use variables that haven't been defined in them. I'd like to see an example end-to-end usage for setting up the status line, and maybe for everything else, that people people can just drop in a lua heredoc and start using it.
Thanks