|
1 | 1 | local config = require("java-deps.config") |
2 | | -local data_node = require("java-deps.views.data_node") |
| 2 | +local icons = require("java-deps.views.icons") |
3 | 3 | local M = {} |
4 | 4 |
|
5 | 5 | local function str_to_table(str) |
@@ -38,83 +38,51 @@ function M.get_lines(flattened_outline_items) |
38 | 38 | local marker_space = config.options.fold_markers and 1 or 0 |
39 | 39 |
|
40 | 40 | local line = str_to_table(string.rep(" ", depth + marker_space)) |
41 | | - local running_length = 1 |
42 | | - |
43 | | - local function add_guide_hl(from, to) |
44 | | - table.insert(hl_info, { |
45 | | - node_line, |
46 | | - from, |
47 | | - to, |
48 | | - "JavaDepsLineGuide", |
49 | | - }) |
50 | | - end |
51 | 41 |
|
| 42 | + local folded = node:is_foldable() |
52 | 43 | for index, _ in ipairs(line) do |
53 | 44 | -- all items start with a space (or two) |
54 | 45 | if config.options.show_guides then |
55 | 46 | if index == #line then |
56 | 47 | -- add fold markers |
57 | | - local folded = data_node.is_folded(node) |
58 | 48 | if config.options.fold_markers and folded then |
59 | | - if data_node.is_expanded(node) then |
| 49 | + if node:is_expanded() then |
60 | 50 | line[index] = config.options.fold_markers[2] |
61 | 51 | else |
62 | 52 | line[index] = config.options.fold_markers[1] |
63 | 53 | end |
64 | | - |
65 | | - add_guide_hl(running_length, running_length + vim.fn.strlen(line[index]) - 1) |
66 | | - |
67 | | - -- the root level has no vertical markers |
68 | 54 | elseif depth > 1 then |
69 | 55 | if node.isLast then |
70 | 56 | line[index] = guides.markers.bottom |
71 | | - add_guide_hl(running_length, running_length + vim.fn.strlen(guides.markers.bottom) - 1) |
72 | 57 | else |
73 | 58 | line[index] = guides.markers.middle |
74 | | - add_guide_hl(running_length, running_length + vim.fn.strlen(guides.markers.middle) - 1) |
75 | 59 | end |
76 | 60 | end |
77 | | - -- else if the parent was not the last in its group, add a |
78 | | - -- vertical marker because there are items under us and we need |
79 | | - -- to point to those |
80 | 61 | elseif not node.hierarchy[index] and depth > 1 then |
81 | 62 | line[index + marker_space] = guides.markers.vertical |
82 | | - add_guide_hl( |
83 | | - running_length - 1 + 2 * marker_space, |
84 | | - running_length + vim.fn.strlen(guides.markers.vertical) - 1 + 2 * marker_space |
85 | | - ) |
86 | 63 | end |
87 | 64 | end |
88 | 65 |
|
89 | 66 | line[index] = line[index] .. " " |
90 | | - |
91 | | - running_length = running_length + vim.fn.strlen(line[index]) |
92 | 67 | end |
93 | 68 |
|
94 | | - local final_prefix = line |
| 69 | + local string_prefix = "" |
95 | 70 |
|
96 | | - local string_prefix = table_to_str(final_prefix) |
| 71 | + for _, value in ipairs(line) do |
| 72 | + string_prefix = string_prefix .. tostring(value) |
| 73 | + end |
97 | 74 |
|
98 | | - table.insert(lines, string_prefix .. node.icon .. " " .. node.label) |
| 75 | + local hl_icon = icons.get_icon(node.data) |
| 76 | + local icon = hl_icon.icon |
| 77 | + table.insert(lines, string_prefix .. icon .. " " .. node.label) |
99 | 78 |
|
100 | 79 | local hl_start = #string_prefix |
101 | | - local hl_end = #string_prefix + #node.icon |
102 | | - local hl = config.options.symbols[node.kind] |
103 | | - local hl_type = hl and hl.hl or "@lsp.type.class" |
| 80 | + local hl_end = #string_prefix + #icon |
| 81 | + local hl_type = hl_icon.hl or "Type" |
104 | 82 | table.insert(hl_info, { node_line, hl_start, hl_end, hl_type }) |
105 | | - |
106 | | - node.prefix_length = #string_prefix + #node.icon + 1 |
| 83 | + node.prefix_length = #string_prefix + #icon + 1 |
107 | 84 | end |
108 | 85 | return lines, hl_info |
109 | 86 | end |
110 | 87 |
|
111 | | -function M.get_details(flattened_outline_items) |
112 | | - local lines = {} |
113 | | - for _, value in ipairs(flattened_outline_items) do |
114 | | - local detail |
115 | | - -- TODO |
116 | | - table.insert(lines, detail or "") |
117 | | - end |
118 | | - return lines |
119 | | -end |
120 | 88 | return M |
0 commit comments