This repository has been archived by the owner on Jul 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
outline.lua
64 lines (59 loc) · 2.44 KB
/
outline.lua
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
-- First, register the callback with your LSP config. This minimal config shows
-- what that looks like.
local nvim_lsp = require('nvim_lsp')
nvim_lsp.dartls.setup{
init_options = {
outline = true,
},
callbacks = {
-- get_callback can be called with or without arguments
['dart/textDocument/publishOutline'] = require('lsp_extensions.dart.outline').get_callback(),
},
}
-- Next, when you want to actually show the outline, you will need to call one
-- of the display methods.
require('lsp_extensions.dart.outline').loclist({})
-- If you want to handle the display yourself you can use the `custom()` function.
require('lsp_extensions.dart.outline').custom({}, function(items) print(items) end)
-- The outline categorizes the entries by `kind`s. By default, the outline will
-- Prefix each entry with it's kind. However, if you prefer to define your own
-- prefixes you can do that by passing `kind_prefixes` into the opts. If you
-- pair this with a patched [Nerdfont](https://www.nerdfonts.com/) you can
-- define a very custom experience. You can define a function that looks like:
DART_KIND_PREFIXES = {
CLASS = "",
CLASS_TYPE_ALIAS = "",
COMPILATION_UNIT = "ﴒ",
CONSTRUCTOR = "",
CONSTRUCTOR_INVOCATION = "",
ENUM = "טּ",
ENUM_CONSTANT = "יּ",
EXTENSION = "",
FIELD = "ﬧ",
FILE = "",
FUNCTION = "",
FUNCTION_INVOCATION = "",
FUNCTION_TYPE_ALIAS = "",
GETTER = "",
LABEL = "",
LIBRARY = "",
LOCAL_VARIABLE = "",
METHOD = "",
MIXIN = "ﭚ",
PARAMETER = "",
PREFIX = "並",
SETTER = "",
TOP_LEVEL_VARIABLE = "ﬢ",
TYPE_PARAMETER = "",
UNIT_TEST_GROUP = "",
UNIT_TEST_TEST = "",
UNKNOWN = "",
}
DART_SHOW_OUTLINE = function()
require('lsp_extensions.dart.outline').loclist({kind_prefixes=DART_KIND_PREFIXES})
end
-- And then call it from neovim with :lua DART_SHOW_OUTLINE()
-- The outline also has built in handlers for fzf and telescope.nvim
require('lsp_extensions.dart.outline').fzf({kind_prefixes=DART_KIND_PREFIXES, fzf_opts={'--height', '40%', '--reverse', '--border', '--inline-info'}})
-- OR
require('lsp_extensions.dart.outline').telescope({kind_prefixes=DART_KIND_PREFIXES, telescope_opts={borderchars={'▃', '▐', '▀', '▍', '▃', '▃', '▀', '▀'}}})