Skip to content

Commit 0444418

Browse files
committed
Add and document current_function option
1 parent d9def2c commit 0444418

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ lsp_status.config {
111111
end
112112
}
113113
```
114+
- `current_function`: Boolean, `true` if the current function should be updated and displayed in the
115+
default statusline component.
114116

115117
## Example Use
116118

doc/lsp-status.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ config({config}) *lsp-status.config()*
9797
`function(cursor_pos, document_symbol)` that should return
9898
`true` if `document_symbol` (a `DocumentSymbol` ) should be
9999
accepted as the symbol currently containing the cursor.•
100+
`current_function`: Boolean, `true` if the current function
101+
should be updated and displayed in the default statusline
102+
component.
100103
`indicator_errors` : Symbol to place next to the error count
101104
in `status` . Default: '',•
102105
`indicator_warnings` : Symbol to place next to the warning

lua/lsp-status.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local _config = {}
22
local default_config = {
33
kind_labels = {},
4+
current_function = true,
45
indicator_errors = '',
56
indicator_warnings = '',
67
indicator_info = '🛈',
@@ -62,7 +63,7 @@ local function config(user_config)
6263
pyls_ms._init(messages, _config)
6364
clangd._init(messages, _config)
6465
messaging._init(messages, _config)
65-
current_function._init(messages, _config)
66+
if _config.current_function then current_function._init(messages, _config) end
6667
statusline._init(messages, _config)
6768
end
6869

@@ -86,7 +87,7 @@ local function on_attach(client)
8687

8788
-- If the client is a documentSymbolProvider, set up an autocommand
8889
-- to update the containing symbol
89-
if client.resolved_capabilities.document_symbol then
90+
if _config.current_function and client.resolved_capabilities.document_symbol then
9091
vim.api.nvim_command('augroup lsp_aucmds')
9192
vim.api.nvim_command(
9293
'au CursorHold <buffer> lua require("lsp-status").update_current_function()'

lua/lsp-status/statusline.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ local function statusline_lsp()
8282

8383
local base_status = vim.trim(table.concat(status_parts, ' ') .. ' ' .. table.concat(msgs, ' '))
8484
local symbol = config.status_symbol .. ((some_diagnostics and only_hint) and '' or ' ')
85-
local current_function = vim.b.lsp_current_function
86-
if current_function and current_function ~= '' then
87-
symbol = symbol .. '(' .. current_function .. ') '
85+
if config.current_function then
86+
local current_function = vim.b.lsp_current_function
87+
if current_function and current_function ~= '' then
88+
symbol = symbol .. '(' .. current_function .. ') '
89+
end
8890
end
8991

9092
if base_status ~= '' then

0 commit comments

Comments
 (0)