Coder Social home page Coder Social logo

nvim-markdown's People

Contributors

alexconst avatar artumi-richard avatar aseom avatar beala avatar bjpbakker avatar blueyed avatar boack avatar bwilliamsgryphon avatar cdelledonne avatar cirosantilli avatar citizenmatt avatar codybuell avatar colinsullivan avatar farmckon avatar fmoralesc avatar haya14busa avatar ilikepi avatar jhoepken avatar jrwrigh avatar memeplex avatar michaelpotter avatar plasticboy avatar rhdunn avatar sersorrel avatar shirosaki avatar tobinjt avatar todesking avatar xiaket avatar y0t4 avatar yous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nvim-markdown's Issues

Unindent with Shift+Tab would be useful

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!

foldlevel support

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

Make newline(key) work with keys other than o, O for non-qwerty keyboards

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.

Option to disable all concealing

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?

Readd `:TableFormat`

Would it be possible to readd the :TableFormat command to auto format tables? The old vim-markdown had it, but here it is missing.

`BufWinLeave` bug on LSP floating view

Problem

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:

Arc_VuKiqKF11r.mp4

Solution

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! ๐Ÿป

Add more functionality to `<CR>` for lists in insert mode.

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.

Disabling insert mode mappings

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.