[NVIM] Add markdown table and checklist support
render-markdown (tables/checkboxes only), vim-table-mode, prettier via conform, cell jumps and checkbox toggle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6c2b24c71c
commit
925c71cbaa
2 files changed
+112
No files matched your search
@@ -92,6 +92,12 @@ Plug 'pangloss/vim-javascript'
|
||||
" Tex
|
||||
Plug 'lervag/vimtex'
|
||||
|
||||
" Markdown
|
||||
Plug 'nvim-tree/nvim-web-devicons'
|
||||
Plug 'MeanderingProgrammer/render-markdown.nvim'
|
||||
Plug 'dhruvasagar/vim-table-mode'
|
||||
Plug 'stevearc/conform.nvim'
|
||||
|
||||
"Go
|
||||
Plug 'fatih/vim-go'
|
||||
|
||||
@@ -498,5 +504,45 @@ try
|
||||
catch
|
||||
" Ignore non existing file
|
||||
endtry
|
||||
" Markdown
|
||||
if !exists('g:vscode')
|
||||
" Table mode under <Leader>T (<Leader>t is TextWrapToggle)
|
||||
let g:table_mode_corner = '|' " GFM-valid delimiter row
|
||||
let g:table_mode_map_prefix = '<Leader>T'
|
||||
let g:table_mode_tableize_d_map = '<Leader>Td'
|
||||
|
||||
lua << EOF
|
||||
-- Only tables and checkboxes; everything else stays plain markdown
|
||||
local off = { enabled = false }
|
||||
require('render-markdown').setup({
|
||||
-- gutter signs open the signcolumn after wrapped tables are sized -> overflow
|
||||
sign = off,
|
||||
heading = off, code = off, dash = off, bullet = off, quote = off, link = off,
|
||||
html = off, latex = off, yaml = off, inline_highlight = off,
|
||||
checkbox = { unchecked = { icon = ' ' }, checked = { icon = ' ' } },
|
||||
})
|
||||
vim.keymap.set('n', '<Leader>mr', '<cmd>RenderMarkdown toggle<CR>', { desc = 'Toggle render markdown' })
|
||||
|
||||
-- Prettier aligns tables on save; :FormatToggle disables it per buffer
|
||||
require('conform').setup({
|
||||
formatters_by_ft = { markdown = { 'prettier' } },
|
||||
formatters = {
|
||||
prettier = { prepend_args = { '--prose-wrap', 'preserve', '--print-width', '120' } },
|
||||
},
|
||||
-- async: Node startup can be slow, don't block :w
|
||||
format_after_save = function(bufnr)
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then return end
|
||||
return {}
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_user_command('FormatToggle', function()
|
||||
vim.b.disable_autoformat = not vim.b.disable_autoformat
|
||||
print('Format on save ' .. (vim.b.disable_autoformat and 'off' or 'on'))
|
||||
end, {})
|
||||
vim.keymap.set('n', '<Leader>F', function() require('conform').format({ async = true }) end,
|
||||
{ desc = 'Format document' })
|
||||
EOF
|
||||
endif
|
||||
|
||||
let g:tex_flavor = "latex"
|
||||
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
|
||||
Reference in new issue
Block a user