File tree Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -241,20 +241,22 @@ M.setup = function(opts)
241
241
end
242
242
end
243
243
244
- vim .filetype .add ({
245
- extension = {
246
- md = function (path , buf )
247
- M .logger .debug (" filetype markdown: " .. path .. " buf: " .. buf )
248
- if not M .not_chat (buf , path ) then
249
- return " markdown.gpchat"
244
+ vim .api .nvim_create_autocmd (" BufEnter" , {
245
+ pattern = " *.md" ,
246
+ callback = function (ev )
247
+ vim .defer_fn (function ()
248
+ M .logger .debug (" Markdown BufEnter: " .. ev .file )
249
+ local path = ev .file
250
+ local buf = ev .buf
251
+ local current_ft = vim .bo [buf ].filetype
252
+ if not M .not_chat (buf , path ) and current_ft ~= " markdown.gpchat" then
253
+ vim .bo [buf ].filetype = " markdown.gpchat"
254
+ elseif M .helpers .ends_with (path , " .gp.md" ) and current_ft ~= " markdown.gpmd" then
255
+ vim .bo [buf ].filetype = " markdown.gpmd"
250
256
end
251
-
252
- if M .helpers .ends_with (path , " .gp.md" ) then
253
- return " markdown.gpmd"
254
- end
255
- return " markdown"
256
- end ,
257
- },
257
+ vim .cmd (" doautocmd User GpRefresh" )
258
+ end , 100 )
259
+ end ,
258
260
})
259
261
260
262
if vim .fn .executable (" curl" ) == 0 then
You can’t perform that action at this time.
0 commit comments