File tree Expand file tree Collapse file tree 3 files changed +21
-12
lines changed
Expand file tree Collapse file tree 3 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,7 @@ local utils = require("cppman.utils")
55local CACHE_HOME = os.getenv (" XDG_CACHE_HOME" ) or vim .fs .joinpath (os.getenv (" HOME" ), " .cache" )
66local CACHE_DIR = vim .fs .joinpath (CACHE_HOME , " cppman" )
77
8- local index_db_path = vim .fs .joinpath (CACHE_DIR , " index.db" )
9- index_db_path = vim .fn .filereadable (index_db_path ) == 1 and index_db_path
10- or require (" cppman.config" ).get ().index_db_path
8+ local index_db_path
119
1210--- @type vim.SystemObj
1311local job = nil
@@ -16,6 +14,10 @@ local job = nil
1614M .entries = {}
1715
1816M .setup = function ()
17+ index_db_path = vim .fs .joinpath (CACHE_DIR , " index.db" )
18+ index_db_path = vim .fn .filereadable (index_db_path ) == 1 and index_db_path
19+ or require (" cppman.config" ).get ().index_db_path
20+
1921 if vim .fn .filereadable (index_db_path ) == 0 then
2022 M .fetch ()
2123 else
Original file line number Diff line number Diff line change @@ -8,9 +8,17 @@ local function pick(entries)
88 require (" cppman.picker." .. config .get ().picker )(entries )
99end
1010
11- --- @param opts Cppman.Config
11+ --- @param opts ? Cppman.Config
1212M .setup = function (opts )
13- config .setup (opts )
13+ if vim .g .loaded_cppman then
14+ return
15+ end
16+
17+ config .setup (opts or {})
18+
19+ require (" cppman.index" ).setup ()
20+
21+ vim .g .loaded_cppman = true
1422end
1523
1624M .fetch_index = function ()
Original file line number Diff line number Diff line change 1- local os = vim .uv .os_uname ().sysname
2- if os ~= " Linux" then
3- require (" cppman.utils" ).error (os .. " is not supported" )
4- return
5- end
6-
7- require (" cppman.index" ).setup ()
1+ -- TODO: A rough fix for setup sequence, refactor it later
2+ vim .defer_fn (function ()
3+ if not vim .g .loaed_cppman then
4+ require (" cppman" ).setup ()
5+ end
6+ end , 0 )
87
98vim .api .nvim_create_user_command (" Cppman" , function (args )
109 if args .args == " " then
You can’t perform that action at this time.
0 commit comments