summaryrefslogblamecommitdiffstats
path: root/.config/nvim/after/ftplugin/markdown.lua
blob: 3c7e0095e277efa8ac1599e054da0687c74a5586 (plain) (tree)
1
2
3
4
5
6
7
8







                                





























                                                                              
require('ftplugin.common-space')

bo.tabstop = 2
bo.shiftwidth = 2
-- bo.formatoptions = 'watqc'
bo.formatoptions = 'qc'
bo.textwidth = 80
o.colorcolumn = '80'

if require("zk.util").notebook_root(vim.fn.expand('%:p')) ~= nil then
  local function map(...) vim.api.nvim_buf_set_keymap(0, ...) end
  local opts = { noremap=true, silent=false }

  map("n", "<CR>", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
  map("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)

  vim.api.nvim_exec([[
    syn region markdownWikiLink matchgroup=markdownLinkDelimiter
    \ start="\[\[" end="\]\]" contains=markdownUrl keepend oneline concealends
    syn region markdownLink matchgroup=markdownLinkDelimiter
    \ start="\[" end="\]" contains=markdownUrl keepend oneline concealends
    syn region markdownLink matchgroup=markdownLinkDelimiter
    \ start="(" end=")" contains=markdownUrl keepend contained conceal
    syn region markdownLinkText matchgroup=markdownLinkTextDelimiter
    \ start="!\=\[\%(\%(\_[^][]\|\[\_[^][]*\]\)*]\%( \=[[(]\)\)\@="
    \ end="\]\%( \=[[(]\)\@=" nextgroup=markdownLink,markdownId
    \ skipwhite contains=@markdownInline,markdownLineStart concealends

    " unlet b:current_syntax
    syntax include @Yaml syntax/yaml.vim
    syntax include @Toml syntax/toml.vim
    syntax region yamlFrontmatter start=/\%^---$/ end=/^---$/
    \ keepend contains=@Yaml
    syntax region tomlFrontmatter start=/\%^+++$/ end=/^+++$/
    \ keepend contains=@Toml

  ]], true)
end
remember that computers suck.