From f2fef63db99d72b20c0c8b99b8a90bf48103469f Mon Sep 17 00:00:00 2001 From: QQ <1770362456@qq.com> Date: Sat, 28 Jan 2023 15:59:16 +0800 Subject: [PATCH] update --- lua/Filetype/markdown.lua | 8 +++++--- lua/G.lua | 4 ++++ lua/core/options.lua | 15 +++++---------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lua/Filetype/markdown.lua b/lua/Filetype/markdown.lua index 2b8d825..8431359 100644 --- a/lua/Filetype/markdown.lua +++ b/lua/Filetype/markdown.lua @@ -1,9 +1,10 @@ -local G = require("core.G") -local TogglePreview = "MarkdownPreviewToggle" +local G = require("G") + +G.cmd("au VimEnter * :MarkdownPreview") --set to 1, nvim will open the preview window after entering the markdown buffer --default: 0 -G.g.mkdp_auto_start = 1 +G.g.mkdp_auto_start = 0 --set to 1, the nvim will auto close current preview window when change --from markdown buffer to another buffer @@ -81,6 +82,7 @@ G.g.mkdp_browserfunc = '' -- ]]) --use a custom markdown style must be absolute path --like '/Users/username/markdown.css' or expand('~/markdown.css') + G.g.mkdp_markdown_css = '' --use a custom highlight style must absolute path diff --git a/lua/G.lua b/lua/G.lua index 68c2fbe..1944861 100644 --- a/lua/G.lua +++ b/lua/G.lua @@ -34,6 +34,10 @@ function G.eval(c) return G.api.nvim_eval(c) end +function G.au(c) + return G.api.nvim_create_autocmd(c) +end + G.g.mapleader = ' ' return G diff --git a/lua/core/options.lua b/lua/core/options.lua index 85acd0f..44077fd 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -52,17 +52,12 @@ G.api.nvim_create_autocmd({ "BufEnter" }, { end, }) -local require_markdown = {} - -function require_markdown() - require('Filetype.markdown') - G.cmd('MarkdownPreviewToggle') -end - -G.api.nvim_create_autocmd( - {"FileType"}, { +G.api.nvim_create_autocmd( {"FileType"}, { pattern = "markdown", - callback = require_markdown + callback = function() + require('Filetype.markdown') + --G.cmd('MarkdownPreview') + end } )