Skip to content

Commit 9157ae5

Browse files
committed
Improve usage example, per #4
1 parent 7a9a2a7 commit 9157ae5

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

README.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This is a Neovim plugin/library for generating statusline components from the bu
1414
1. [Protocol Extensions](#protocol-extensions)
1515
2. [Configuration](#configuration)
1616
4. [Example Use](#example-use)
17+
1. [All together, now](#all-together-now)
1718
5. [Status](#status)
1819
6. [Contributing](#contributing)
1920

@@ -117,7 +118,8 @@ showing how `lsp-status` can be integrated into one's statusline and other LSP c
117118
```lua
118119
local lsp_status = require('lsp-status')
119120
-- completion_customize_lsp_label as used in completion-nvim
120-
lsp_status.config { kind_labels = vim.g.completion_customize_lsp_label }
121+
-- Optional: customize the kind labels used in identifying the current function
122+
-- lsp_status.config { kind_labels = vim.g.completion_customize_lsp_label }
121123

122124
-- Register the progress callback
123125
lsp_status.register_progress()
@@ -154,6 +156,47 @@ and develop your own statusline segment, but if you'd like something reasonable
154156
can call `lsp_status.status()` somewhere in your statusline definition (make sure you have
155157
`require`'d the `lsp-status` module too!)
156158

159+
### All together, now
160+
161+
Here's a complete example:
162+
163+
```vim
164+
lua << END
165+
local lsp_status = require('lsp-status')
166+
lsp_status.register_progress()
167+
168+
local nvim_lsp = require('nvim-lsp')
169+
170+
-- Some arbitrary servers
171+
nvim_lsp.clangd.setup({
172+
callbacks = lsp_status.extensions.clangd.setup(),
173+
init_options = {
174+
clangdFileStatus = true
175+
},
176+
on_attach = lsp_status.on_attach
177+
})
178+
179+
nvim_lsp.pyls_ms.setup({
180+
callbacks = lsp_status.extensions.pyls_ms.setup(),
181+
settings = { python = { workspaceSymbols = { enabled = true }}},
182+
on_attach = lsp_status.on_attach
183+
})
184+
185+
nvim_lsp.ghcide.setup({ on_attach = lsp_status.on_attach })
186+
nvim_lsp.rust_analyzer.setup({ on_attach = lsp_status.on_attach })
187+
END
188+
189+
" Statusline
190+
function! LspStatus() abort
191+
if luaeval('#vim.lsp.buf_get_clients() > 0')
192+
return luaeval("require('lsp-status').status()")
193+
endif
194+
195+
return ''
196+
endfunction
197+
198+
```
199+
157200
## Status
158201

159202
This plugin is "complete" - it works in all the ways it was originally intended to, and it doesn't

0 commit comments

Comments
 (0)