@@ -4,7 +4,6 @@ local M = {}
44M .config = {
55 layout = " left" ,
66 layout_size = 30 ,
7- auto_open = false ,
87 jump_mode = " invoking" ,
98 icons = " none" ,
109 no_hls = false ,
@@ -13,6 +12,7 @@ M.config = {
1312 hls = {},
1413 resolve_symbols = true ,
1514 unified_panel = false ,
15+ auto_open_panel = false ,
1616 auto_highlight = true
1717}
1818
@@ -74,6 +74,33 @@ function _setup_default_highlights()
7474 end
7575end
7676
77+ local function sanatize_config ()
78+ -- sanatize the config
79+ if (M .config .layout ~= " left" )
80+ and (M .config .layout ~= " right" )
81+ and (M .config .layout ~= " top" )
82+ and (M .config .layout ~= " bottom" )
83+ then
84+ M .config .layout = " left"
85+ end
86+ if M .config .layout_size < 10 then
87+ M .config .layout_size = 10
88+ end
89+ if M .config .jump_mode ~= " invoking" and M .config .jump_mode ~= " neighbor" then
90+ M .config .jump_mode = " neighbor"
91+ end
92+ if M .config .icons ~= " codicons" and M .config .icons ~= " nerd" then
93+ M .config .icons = " none"
94+ else
95+ if M .config .icons == " codicons" then
96+ M .active_icon_set = M .codicons
97+ end
98+ if M .config .icons == " nerd" then
99+ M .active_icon_set = M .nerd
100+ end
101+ end
102+ end
103+
77104function M .setup (user_config )
78105 -- hijack the normal lsp handlers
79106 vim .lsp .handlers [' callHierarchy/incomingCalls' ] = vim .lsp .with (
@@ -108,30 +135,7 @@ function M.setup(user_config)
108135 end
109136 end
110137
111- -- sanatize the config
112- if (M .config .layout ~= " left" )
113- and (M .config .layout ~= " right" )
114- and (M .config .layout ~= " top" )
115- and (M .config .layout ~= " bottom" )
116- then
117- M .config .layout = " left"
118- end
119- if M .config .layout_size < 10 then
120- M .config .layout_size = 10
121- end
122- if M .config .jump_mode ~= " invoking" and M .config .jump_mode ~= " neighbor" then
123- M .config .jump_mode = " neighbor"
124- end
125- if M .config .icons ~= " codicons" and M .config .icons ~= " nerd" then
126- M .config .icons = " none"
127- else
128- if M .config .icons == " codicons" then
129- M .active_icon_set = M .codicons
130- end
131- if M .config .icons == " nerd" then
132- M .active_icon_set = M .nerd
133- end
134- end
138+ sanatize_config ()
135139
136140 -- setup default highlights
137141 if not M .config .no_hls then
@@ -140,32 +144,31 @@ function M.setup(user_config)
140144
141145 -- automatically open the ui elements on buf enters.
142146 if M .config .auto_open then
143- vim .cmd ([[ au BufEnter * lua require('calltree.ui').open_calltree()]] )
144- vim .cmd ([[ au BufEnter * lua require('calltree.ui').open_symboltree()]] )
147+ vim .cmd ([[ au VimEnter * lua require('calltree.ui').toggle_panel()]] )
145148 end
146149
147150 -- will keep the outline view up to date when moving around buffers.
148- vim .cmd ([[ au TextChanged,BufEnter,BufWritePost * lua require('calltree.ui').refresh_symbol_tree()]] )
151+ vim .cmd ([[ au TextChanged,BufEnter,BufWritePost,WinEnter * lua require('calltree.ui').refresh_symbol_tree()]] )
149152
150153 -- will enable symboltree ui tracking with source code lines.
151154 vim .cmd ([[ au CursorHold * lua require('calltree.ui').source_tracking()]] )
152155
153- -- setup commands
154- vim .cmd (" command! CTOpen lua require('calltree.ui').open_to('calltree')" )
155- vim .cmd (" command! STOpen lua require('calltree.ui').open_to('symboltree')" )
156- vim .cmd (" command! CTToggle lua require('calltree.ui').toggle_panel()" )
157- vim .cmd (" command! CTClose lua require('calltree.ui').close_calltree()" )
158- vim .cmd (" command! STClose lua require('calltree.ui').close_symboltree()" )
159- vim .cmd (" command! CTExpand lua require('calltree.ui').expand()" )
160- vim .cmd (" command! CTCollapse lua require('calltree.ui').collapse()" )
161- vim .cmd (" command! CTSwitch lua require('calltree.ui').switch_direction()" )
162- vim .cmd (" command! CTFocus lua require('calltree.ui').focus()" )
163- vim .cmd (" command! CTJump lua require('calltree.ui').jump()" )
164- vim .cmd (" command! CTHover lua require('calltree.ui').hover()" )
165- vim .cmd (" command! CTDetails lua require('calltree.ui').details()" )
166- vim .cmd (" command! CTClearHL lua require('calltree.ui.jumps').set_jump_hl(false)" )
167- vim .cmd (" command! CTDumpTree lua require('calltree.ui').dump_tree()" )
168- vim .cmd (" command! CTDumpNode lua require('calltree.ui').dump_node()" )
156+ -- setup commands
157+ vim .cmd (" command! CTOpen lua require('calltree.ui').open_to('calltree')" )
158+ vim .cmd (" command! STOpen lua require('calltree.ui').open_to('symboltree')" )
159+ vim .cmd (" command! CTPanel lua require('calltree.ui').toggle_panel()" )
160+ vim .cmd (" command! CTClose lua require('calltree.ui').close_calltree()" )
161+ vim .cmd (" command! STClose lua require('calltree.ui').close_symboltree()" )
162+ vim .cmd (" command! CTExpand lua require('calltree.ui').expand()" )
163+ vim .cmd (" command! CTCollapse lua require('calltree.ui').collapse()" )
164+ vim .cmd (" command! CTSwitch lua require('calltree.ui').switch_direction()" )
165+ vim .cmd (" command! CTFocus lua require('calltree.ui').focus()" )
166+ vim .cmd (" command! CTJump lua require('calltree.ui').jump()" )
167+ vim .cmd (" command! CTHover lua require('calltree.ui').hover()" )
168+ vim .cmd (" command! CTDetails lua require('calltree.ui').details()" )
169+ vim .cmd (" command! CTClearHL lua require('calltree.ui.jumps').set_jump_hl(false)" )
170+ vim .cmd (" command! CTDumpTree lua require('calltree.ui').dump_tree()" )
171+ vim .cmd (" command! CTDumpNode lua require('calltree.ui').dump_node()" )
169172end
170173
171174-- the configured icon set after setup() is ran.
0 commit comments