File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,20 +69,6 @@ function M.setup_user_commands()
6969end
7070
7171function M .enable_tree_cbs ()
72- local rev = M .get_parser_version ()
73-
74- if rev ~= nil and rev ~= TESTED_PARSER_REV then
75- log (
76- " AutoFixReturn: Current Go treesitter parser version '"
77- .. rev
78- .. " ' is not tested with this plugin.\n "
79- .. " If you encounter issues please upgrade your Go Treesitter parser to the tested version '"
80- .. TESTED_PARSER_REV
81- .. " '" ,
82- vim .log .levels .WARN
83- )
84- end
85-
8672 for bufnr , _ in pairs (registered_ts_cbs_bufs ) do
8773 registered_ts_cbs_bufs [bufnr ] = true
8874 end
@@ -116,6 +102,21 @@ function M.register_buf_cbs(bufnr)
116102 return
117103 end
118104
105+ -- We should warn the users if they are using a parser version we do not know about
106+ -- but only once on the initial go buffer attach otherwise it is annoying
107+ local rev = M .get_parser_version ()
108+ if rev ~= nil and rev ~= TESTED_PARSER_REV then
109+ log_once (
110+ " AutoFixReturn: Current Go treesitter parser version '"
111+ .. rev
112+ .. " ' is not tested with this plugin.\n "
113+ .. " If you encounter issues please upgrade your Go Treesitter parser to the tested version '"
114+ .. TESTED_PARSER_REV
115+ .. " '" ,
116+ vim .log .levels .WARN
117+ )
118+ end
119+
119120 local tree = vim .treesitter .get_parser (bufnr )
120121
121122 if tree == nil then
Original file line number Diff line number Diff line change @@ -13,3 +13,11 @@ function log(message, level)
1313 vim .notify (message , level )
1414 end
1515end
16+
17+ --- @param message string
18+ --- @param level integer
19+ function log_once (message , level )
20+ if level >= _log_level then
21+ vim .notify_once (message , level )
22+ end
23+ end
You can’t perform that action at this time.
0 commit comments