Skip to content

Commit b2c0fa8

Browse files
authored
feat(configs): configure which LSP document symbols to show (#203)
* feat(configs): configure which LSP document symbols to show * docs: include new setting
1 parent b63fe2e commit b2c0fa8

4 files changed

Lines changed: 132 additions & 4 deletions

File tree

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,34 @@ vim.ui.select = require('dropbar.utils.menu').select
10261026
},
10271027
},
10281028
lsp = {
1029+
valid_symbols = {
1030+
'File',
1031+
'Module',
1032+
'Namespace',
1033+
'Package',
1034+
'Class',
1035+
'Method',
1036+
'Property',
1037+
'Field',
1038+
'Constructor',
1039+
'Enum',
1040+
'Interface',
1041+
'Function',
1042+
'Variable',
1043+
'Constant',
1044+
'String',
1045+
'Number',
1046+
'Boolean',
1047+
'Array',
1048+
'Object',
1049+
'Keyword',
1050+
'Null',
1051+
'EnumMember',
1052+
'Struct',
1053+
'Event',
1054+
'Operator',
1055+
'TypeParameter',
1056+
},
10291057
request = {
10301058
-- Times to retry a request before giving up
10311059
ttl_init = 60,
@@ -1958,6 +1986,39 @@ each sources.
19581986

19591987
##### LSP
19601988

1989+
- `opts.sources.lsp.valid_symbols:` `string[]`
1990+
- A list of LSP document symbols to include in the results
1991+
- Default:
1992+
```lua
1993+
{
1994+
'File',
1995+
'Module',
1996+
'Namespace',
1997+
'Package',
1998+
'Class',
1999+
'Method',
2000+
'Property',
2001+
'Field',
2002+
'Constructor',
2003+
'Enum',
2004+
'Interface',
2005+
'Function',
2006+
'Variable',
2007+
'Constant',
2008+
'String',
2009+
'Number',
2010+
'Boolean',
2011+
'Array',
2012+
'Object',
2013+
'Keyword',
2014+
'Null',
2015+
'EnumMember',
2016+
'Struct',
2017+
'Event',
2018+
'Operator',
2019+
'TypeParameter',
2020+
}
2021+
```
19612022
- `opts.sources.lsp.request.ttl_init`: `number`
19622023
- Number of times to retry a request before giving up
19632024
- Default: `60`

doc/dropbar.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,38 @@ TREESITTER *dropbar-configuration-options-sources-treesitter*
10821082

10831083
LSP *dropbar-configuration-options-sources-lsp*
10841084

1085+
- `opts.sources.lsp.valid_symbols:` `string[]`
1086+
- A list of LSP document symbols to include in the results
1087+
- Default: >lua
1088+
{
1089+
'File',
1090+
'Module',
1091+
'Namespace',
1092+
'Package',
1093+
'Class',
1094+
'Method',
1095+
'Property',
1096+
'Field',
1097+
'Constructor',
1098+
'Enum',
1099+
'Interface',
1100+
'Function',
1101+
'Variable',
1102+
'Constant',
1103+
'String',
1104+
'Number',
1105+
'Boolean',
1106+
'Array',
1107+
'Object',
1108+
'Keyword',
1109+
'Null',
1110+
'EnumMember',
1111+
'Struct',
1112+
'Event',
1113+
'Operator',
1114+
'TypeParameter',
1115+
}
1116+
<
10851117
- `opts.sources.lsp.request.ttl_init`: `number`
10861118
- Number of times to retry a request before giving up
10871119
- Default: `60`

lua/dropbar/configs.lua

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,34 @@ M.opts = {
767767
},
768768
},
769769
lsp = {
770+
valid_symbols = {
771+
'File',
772+
'Module',
773+
'Namespace',
774+
'Package',
775+
'Class',
776+
'Method',
777+
'Property',
778+
'Field',
779+
'Constructor',
780+
'Enum',
781+
'Interface',
782+
'Function',
783+
'Variable',
784+
'Constant',
785+
'String',
786+
'Number',
787+
'Boolean',
788+
'Array',
789+
'Object',
790+
'Keyword',
791+
'Null',
792+
'EnumMember',
793+
'Struct',
794+
'Event',
795+
'Operator',
796+
'TypeParameter',
797+
},
770798
request = {
771799
-- Times to retry a request before giving up
772800
ttl_init = 60,

lua/dropbar/sources/lsp.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,17 @@ local function convert_document_symbol_list(
210210
-- is preferred
211211
for idx, symbol in vim.iter(lsp_symbols):enumerate():rev() do
212212
if cursor_in_range(cursor, symbol.range) then
213-
table.insert(
214-
dropbar_symbols,
215-
convert_document_symbol(symbol, buf, win, lsp_symbols, idx)
216-
)
213+
if
214+
vim.tbl_contains(
215+
configs.opts.sources.lsp.valid_symbols,
216+
symbol_kind_names[symbol.kind]
217+
)
218+
then
219+
table.insert(
220+
dropbar_symbols,
221+
convert_document_symbol(symbol, buf, win, lsp_symbols, idx)
222+
)
223+
end
217224
if symbol.children then
218225
convert_document_symbol_list(
219226
symbol.children,

0 commit comments

Comments
 (0)