9090
9191M .enableDiagnostics = function ()
9292 local main_nr = api .nvim_get_current_buf ()
93+ local otter_nrs = otterkeeper ._otters_attached [main_nr ].buffers
94+ local nss = {}
95+ for lang , bufnr in pairs (otter_nrs ) do
96+ local ns = api .nvim_create_namespace (' quarto-lang-' .. lang )
97+ nss [bufnr ] = ns
98+ end
99+
93100 api .nvim_create_autocmd (M .config .lspFeatures .diagnostics .triggers , {
94101 buffer = main_nr ,
95102 group = api .nvim_create_augroup (" quartoLSPDiagnositcs" , { clear = false }),
96103 callback = function (_ , _ )
97- local bufnrs = otterkeeper ._otters_attached [main_nr ].buffers
98104 otterkeeper .sync_raft (main_nr )
99- for lang , bufnr in pairs (bufnrs ) do
105+ for bufnr , ns in pairs (nss ) do
100106 local diag = vim .diagnostic .get (bufnr )
101- local ns = api .nvim_create_namespace (' quarto-lang-' .. lang )
102107 vim .diagnostic .reset (ns , main_nr )
103108 vim .diagnostic .set (ns , main_nr , diag , {})
104109 end
@@ -151,13 +156,16 @@ M.activate = function()
151156 }
152157 end
153158 otter .activate (M .config .lspFeatures .languages , M .config .lspFeatures .completion .enabled , tsqueries )
159+ if M .config .lspFeatures .diagnostics .enabled then
160+ M .enableDiagnostics ()
161+ end
154162end
155163
156164-- setup
157165M .setup = function (opt )
158166 M .config = vim .tbl_deep_extend (' force' , M .defaultConfig , opt or {})
159167
160- api .nvim_create_autocmd ({ " BufReadPost " }, {
168+ api .nvim_create_autocmd ({ " BufEnter " }, {
161169 pattern = { " *.qmd" },
162170 group = vim .api .nvim_create_augroup (' QuartoSetup' , {}),
163171 desc = ' set up quarto' ,
@@ -192,7 +200,7 @@ M.quartoSendAbove = function()
192200 local lines = otterkeeper .get_language_lines_to_cursor ()
193201 if lines == nil then
194202 print (
195- ' No code chunks found for the current language, which is detected based on the current code block. Is your cursor in a code block?' )
203+ ' No code chunks found for the current language, which is detected based on the current code block. Is your cursor in a code block?' )
196204 return
197205 end
198206 lines = concat (lines )
@@ -204,7 +212,7 @@ M.quartoSendAll = function()
204212 local lines = otterkeeper .get_language_lines ()
205213 if lines == nil then
206214 print (
207- ' No code chunks found for the current language, which is detected based on the current code block. Is your cursor in a code block?' )
215+ ' No code chunks found for the current language, which is detected based on the current code block. Is your cursor in a code block?' )
208216 return
209217 end
210218 lines = concat (lines )
0 commit comments