ixru / nvim-markdown Goto Github PK
View Code? Open in Web Editor NEWThis project forked from preservim/vim-markdown
Markdown Vim Mode
Home Page: http://plasticboy.com/markdown-vim-mode/
This project forked from preservim/vim-markdown
Markdown Vim Mode
Home Page: http://plasticboy.com/markdown-vim-mode/
It's great to indent a bullet by pressing tab.
From what I know from other editors, it's common to re-indent by pressing shift+tab.
I think that would be nice behaviour to have.
Thanks for this great plugin!
Hi
Is there a way to use regular nvim folding mechanism with this extension? So that z* commands work, and, most importantly, foldlevel
is respected?
Thanks
It would be great to also have this feature.
In the original: vim-markdown when you have a word under cursor and press 'ge' vim will create a new file under that name.
I use Colemak keyboard layout, so I mapped o
to <DOWN>
and l
& L
for opening a line abobe and below cursor. But newline(key)
function in markdown.lua
has o
and O
keys hardcoded as a result navigation is really difficult for me for markdown documents.
The following code changes remove the hard-coding, as a result it will work for any keyboard layout.
-- markdown.lua
-- Responsible for auto-inserting new bullet points when pressing
local function newline(key, insert_line, folded)
-- First find which line will be above and below the newly inserted line
local bullet_above, bullet_below
if folded then
bullet_above = parse_bullet(vim.fn.foldclosed(insert_line))
bullet_below = parse_bullet(insert_line + 1)
else
bullet_above = parse_bullet(insert_line)
bullet_below = parse_bullet(insert_line + 1)
end
if bullet_above then
-- remove bullet and insert new line if the bullet is empty
if #bullet_above.text == 0 then
-- the bullet is empty, remove it and start a new line below it
vim.cmd("startinsert")
vim.api.nvim_buf_set_lines(0, insert_line-1, insert_line, true, {"",""})
vim.api.nvim_win_set_cursor(0,{insert_line+1, 0})
return
end
-- Use the properties of the bullet below if its indent is higher than the one above.
local bullet
if bullet_below and bullet_below.indent > bullet_above.indent then
bullet = bullet_below
else
bullet = bullet_above
end
local indent = string.rep(" ", bullet.indent)
local marker = bullet.marker
local delimiter = bullet.delimiter
local trailing_indent = string.rep(" ", bullet.trailing_indent)
-- Use checkbox of the above bullet if they are equally indented
local checkbox
if bullet_above and bullet_below and bullet_above.indent == bullet_below.indent then
checkbox = bullet_above.checkbox and "[ ] " or ""
else
checkbox = bullet.checkbox and "[ ] " or ""
end
if tonumber(marker) then
marker = marker + 1
-- TODO: reoder list if there are other bullets below
--other_bullets = parse_list(bullet.start)
--for _, bullet_line in pairs(other_bullets) do
-- local incremented = vim.fn.getline(bullet_line):sub
end
local new_line = indent .. marker .. delimiter .. trailing_indent .. checkbox
vim.cmd("startinsert")
vim.fn.append(insert_line, new_line)
vim.api.nvim_win_set_cursor(0,{insert_line+1, 1000000})
should_run_callback = true
elseif folded then
-- is a folded header
vim.cmd("startinsert")
vim.fn.append(insert_line, "")
vim.api.nvim_win_set_cursor(0,{insert_line+1, 0})
else
-- Normal key
-- key = vim.api.nvim_replace_termcodes(key, true, false, true)
-- vim.api.nvim_feedkeys(key, "n", true)
vim.fn.append(insert_line, "")
vim.api.nvim_win_set_cursor(0,{insert_line+1, 1000000})
end
end
function M.newlineBefore(key)
local insert_line
local folded
local line = vim.fn.line(".")
if vim.fn.foldclosed(line - 1) > 0 then
insert_line = vim.fn.foldclosedend(line - 1)
folded = true
else
insert_line = line - 1
end
newline(key, insert_line, folded)
end
function M.newlineAfter(key)
local insert_line
local folded
local crline = vim.fn.line(".")
if key == "<CR>" or key == "return" then
key = "<CR>"
-- if not at EOL, normal Return
local column = vim.api.nvim_win_get_cursor(0)[2] + 1
local line = vim.api.nvim_get_current_line()
if column < #line then
key = vim.api.nvim_replace_termcodes(key, true, false, true)
vim.api.nvim_feedkeys(key, "n", true)
return
else
insert_line = crline
end
else
if vim.fn.foldclosed(".") > 0 then
insert_line = vim.fn.foldclosedend(".")
folded = true
else
insert_line = crline
end
end
newline(key, insert_line, folded)
end
" markdown.vim
imap <buffer> <CR> <cmd>lua require("markdown").newlineAfter("return")<CR>
" for standard qwerty keyboard
nmap <buffer> o <cmd>lua require("markdown").newlineAfter("o")<CR>
nmap <buffer> O <cmd>lua require("markdown").newlineBefore("O")<CR>
" for colemak
" nmap <buffer> l <cmd>lua require("markdown").newlineAfter("l")<CR>
" nmap <buffer> L <cmd>lua require("markdown").newlineBefore("L")<CR>
Please note that lua and vimscript are quite new to me, so I may have made some mistakes, although I have not encountered any errors.
Thanks for a great plugin.
It appears that regardless of g:vim_markdown_conceal
, the single-backtick and triple-backtick syntax is still concealed. The triple-backticks is particularly problematic for me, as it appears to be a redundant empty line.
Can we have an option to disable all concealing?
I tried to disable concealing but it didn't work. My suspicion is that this line butchers the conceal configuration:
nvim-markdown/ftplugin/markdown.vim
Line 755 in 7563972
Hi.
I am get to use C-c to use like Esc key. How could I change this shortcut key ?
I love your Plugin :D
Could we please have an option to apply a colour from the selected colour scheme to htmlItalic
?
I am using Nord as my theme.
Hi
I am wondering if it is possible to to the previous md-file after following a md-link?
Thanks
How do I disable syntax highlighting and use my own theme? I found how to redefine groups, but I don't want to just disable it.
Would it be possible to readd the :TableFormat
command to auto format tables? The old vim-markdown had it, but here it is missing.
In nvim >0.10 (at least that's when I started noticing it), this autocommand is throwing a non-silent E32
when you try to jump inside the LSP info floating view.
The error happens because the plugin recognizes these floating windows as valid markdown buffers and, when leaving the buffer, it tries to save it without success because there's no name on that buffer.
Here's a quick demo:
I don't have much time for a PR right now but because the bug was pissing me off I forked the repo and made a quick and nasty band-aid. It might not be of great value for a PR since it will probably conflict with a few edge cases and it's crappy vim script with 0 documentation aswell. But what it does is simple in principle; checks if the window is floating and only applies the autocommand if it is not a floating window.
Hopefully this inspires someone to fix the problem in a serious manner.
Cheers and thank you for your time! ๐ป
First of all I want to thank you for the amazing plugin, it is a lot better than any of the other Markdown plugins I have found/used and I love almost everything about it.
The only issue I have is in lists when a child list item is indented but empty hitting <CR>
just deletes the list item and creates a new line. If possible I would love to see a feature added when pressing <CR>
on an empty indented list item will demote it (unindent it one level) unit it no longer can and then pressing <CR>
again will then remove the list item entirely.
In case my above explanation was unclear I included a visual description bellow.
- Parent List Item
- Child List Item
- (Empty Child List Item)
When <CR>
is pressed on the (Empty List Item)
I want the list to look like this:
- Parent List Item
- Child List Item
- New Parent List Item
I believe someone else made a request to add <Shift-Tab>
to have the same functionality, but I believe more editors use <CR>
to unindent an empty list item so adding this (as well) would make transitioning to and from NeoVim easier.
First off, thanks for making this plugin, I've been enjoying using it so far!
I use UltiSnips
as a snippet engine and I have <tab>
as my insert mode mapping for expanding snippets which conflicts with the default Markdown_Jump
mapping in nvim-markdown
. The README.md
here states:
To disable a map use:
map <Plug> <Plug>Markdown_MoveToParentHeader`
For the insert mode mappings, this actually doesn't work because map
only sets mapping for mapmode-nvo
. So, to resolve the conflict and disable the Markdown_Jump
mapping, I had to do:
imap <Plug> <Plug>Markdown_Jump
Not a big deal but it took me a few minutes to figure out and I imagine this conflict won't be that uncommon since <tab>
is a common mapping for snippet and completion plugins. I can try to put up a PR to add a note about this in the README.md
but I'm at work at the moment so can't get to that until later.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.