From edf227aee86255467a031c71fed1d2ac13c893b7 Mon Sep 17 00:00:00 2001 From: berkenar1 <73941606+berkenar1@users.noreply.github.com> Date: Sat, 11 Jul 2026 07:10:05 +0300 Subject: [PATCH] feat: add markdown editing, preview, and math-aware writing support --- README.md | 9 ++++++++- init.lua | 22 ++++++++++++++++++++++ install-freebsd.sh | 4 ++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2409f3ae..174a0e19 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Or manually install dependencies: ```sh sudo pkg update -f -sudo pkg install -y git gmake unzip llvm ripgrep fd-find tree-sitter stylua base64-by-elvis +sudo pkg install -y git gmake unzip llvm ripgrep fd-find tree-sitter stylua base64-by-elvis node npm ``` **Note:** `lua-language-server` is not available in FreeBSD pkg repositories, so LSP support for Lua is disabled in this config. @@ -58,6 +58,7 @@ sudo pkg install -y git gmake unzip llvm ripgrep fd-find tree-sitter stylua base - Language Setup: - If you want to write Typescript, you need `npm` - If you want to write Golang, you will need `go` + - If you want markdown live preview, you need `node` and `npm` - etc. ### Install Kickstart.nvim-FreeBSD @@ -104,6 +105,12 @@ Wait for plugins to finish installing, then restart Neovim. Read through the `init.lua` file in your configuration folder for more information about extending and exploring Neovim. +#### Markdown Writing + +This config includes built-in support for editing and previewing technical articles: +- **Syntax & Math Highlighting**: `vim-markdown` handles syntax highlighting, frontmatter, and math support. Single `$...$` and double `$$...$$` math syntax is fully supported for highlight and structure awareness. Note that the actual math rendering happens in the browser preview. +- **Live Preview**: Toggle a live browser preview with `mp` (runs `:MarkdownPreviewToggle`). This relies on `markdown-preview.nvim` which requires `node` and `npm` installed. + ### FAQ * What should I do if I already have a pre-existing Neovim configuration? diff --git a/init.lua b/init.lua index 83fccd9e..9e350c17 100644 --- a/init.lua +++ b/init.lua @@ -213,6 +213,8 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the upper win -- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) -- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) +vim.keymap.set('n', 'mp', ':MarkdownPreviewToggle', { desc = '[M]arkdown [P]review toggle' }) + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -912,6 +914,26 @@ require('lazy').setup({ -- Highlight todo, notes, etc in comments { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, + -- Markdown editing + live preview + math-aware writing + { + 'preservim/vim-markdown', + ft = { 'markdown' }, + init = function() + vim.g.vim_markdown_math = 1 + vim.g.vim_markdown_frontmatter = 1 + vim.g.vim_markdown_folding_disabled = 1 + end, + }, + + { + 'iamcco/markdown-preview.nvim', + cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' }, + ft = { 'markdown' }, + build = function() + vim.fn['mkdp#util#install']() + end, + }, + { -- Collection of various small independent plugins/modules 'echasnovski/mini.nvim', config = function() diff --git a/install-freebsd.sh b/install-freebsd.sh index d4bfcab3..e697c8f1 100755 --- a/install-freebsd.sh +++ b/install-freebsd.sh @@ -22,8 +22,8 @@ echo "[2/5] Installing core dependencies (git, make, unzip, clang)..." pkg install -y base64 git gmake unzip llvm # Development tools -echo "[3/5] Installing development tools (ripgrep, fd)..." -pkg install -y ripgrep fd-find +echo "[3/5] Installing development tools (ripgrep, fd, node, npm)..." +pkg install -y ripgrep fd-find node npm # Tree-sitter for syntax highlighting echo "[4/5] Installing tree-sitter..."