1
0
Fork 0

update `nvim` config

urosm 2024-01-14 12:28:07 +01:00
parent 7e707bf880
commit 979e548ac9
9 changed files with 379 additions and 172 deletions

View File

@ -0,0 +1,2 @@
-- treesitter ------------------------------------------------------------------
vim.treesitter.start()

View File

@ -0,0 +1,2 @@
-- treesitter ------------------------------------------------------------------
vim.treesitter.start()

View File

@ -0,0 +1,4 @@
-- options ---------------------------------------------------------------------
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true

View File

@ -4,4 +4,4 @@ vim.opt.shiftwidth = 2
vim.opt.expandtab = true vim.opt.expandtab = true
-- treesitter ------------------------------------------------------------------ -- treesitter ------------------------------------------------------------------
-- vim.treesitter.start() vim.treesitter.start()

View File

@ -0,0 +1,4 @@
-- options ---------------------------------------------------------------------
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true

View File

@ -0,0 +1,2 @@
-- treesitter ------------------------------------------------------------------
vim.treesitter.start()

View File

@ -33,11 +33,9 @@ local cyan_c = C[7]
local white_c = C[8] local white_c = C[8]
-- init ------------------------------------------------------------------------ -- init ------------------------------------------------------------------------
-- vim.cmd.highlight("clear") vim.cmd.highlight("clear")
vim.cmd("highlight clear")
if vim.fn.exists("syntax_on") then if vim.fn.exists("syntax_on") then
-- vim.cmd.syntax("reset") vim.cmd.syntax("reset")
vim.cmd("syntax reset")
end end
vim.opt.background = "dark" vim.opt.background = "dark"
vim.g.colors_name = "basic" vim.g.colors_name = "basic"
@ -113,7 +111,7 @@ local tui_normal_h = {}
local tui_accent_h = H:new():fg(accent_c) local tui_accent_h = H:new():fg(accent_c)
local tui_dimmed_h = H:new():fg(dimmed_c) local tui_dimmed_h = H:new():fg(dimmed_c)
set_hl("StatusLine", tui_accent_h) set_hl("StatusLine", tui_dimmed_h)
set_hl("StatusLineNC", tui_dimmed_h) set_hl("StatusLineNC", tui_dimmed_h)
set_hl("TabLine", tui_dimmed_h) set_hl("TabLine", tui_dimmed_h)
set_hl("TabLineFill", tui_dimmed_h) set_hl("TabLineFill", tui_dimmed_h)
@ -121,11 +119,12 @@ set_hl("TabLineSel", tui_accent_h)
set_hl("WinBar", tui_accent_h) set_hl("WinBar", tui_accent_h)
set_hl("WinBarNC", tui_dimmed_h) set_hl("WinBarNC", tui_dimmed_h)
set_hl("WinSeparator", tui_dimmed_h) set_hl("WinSeparator", tui_dimmed_h)
set_hl("LineNr", tui_dimmed_h) set_hl("LineNr", tui_accent_h)
set_hl("LineNrAbove", tui_dimmed_h) set_hl("LineNrAbove", tui_dimmed_h)
set_hl("LineNrBelow", tui_dimmed_h) set_hl("LineNrBelow", tui_dimmed_h)
set_hl("SignColumn", tui_dimmed_h) set_hl("SignColumn", tui_dimmed_h)
set_hl("FoldColumn", tui_dimmed_h) set_hl("FoldColumn", tui_dimmed_h)
set_hl("WildMenu", tui_accent_h)
-- float ----------------------------------------------------------------------- -- float -----------------------------------------------------------------------
local float_normal_h = H:new():fg(bg_c):bg(fg_c) local float_normal_h = H:new():fg(bg_c):bg(fg_c)
@ -148,7 +147,6 @@ set_hl("PmenuExtra", menu_normal_h)
set_hl("PmenuExtraSel", menu_accent_h) set_hl("PmenuExtraSel", menu_accent_h)
set_hl("PmenuSbar", menu_accent_h) set_hl("PmenuSbar", menu_accent_h)
set_hl("PmenuThumb", menu_accent_r_h) set_hl("PmenuThumb", menu_accent_r_h)
set_hl("WildMenu", menu_accent_h)
-- messages -------------------------------------------------------------------- -- messages --------------------------------------------------------------------
local message_normal_h = {} local message_normal_h = {}
@ -194,17 +192,18 @@ set_hl("TermCursor", cursor_normal_h)
set_hl("TermCursorNC", cursor_normal_h) set_hl("TermCursorNC", cursor_normal_h)
-- match ----------------------------------------------------------------------- -- match -----------------------------------------------------------------------
local match_normal_h = H:new():fg(orange_c) local match_normal_h = H:new():fg(black_c):bg(orange_c)
local match_current_h = H:new():fg(orange_c):attr("reverse") local match_cur_h = H:new():fg(black_c):bg(cyan_c)
local match_reverse_h = H:new():fg(black_c):bg(orange_c):attr("reverse")
set_hl("Search", match_normal_h) set_hl("Search", match_normal_h)
set_hl("Substitute", match_normal_h) set_hl("Substitute", match_normal_h)
set_hl("IncSearch", match_current_h) set_hl("IncSearch", match_normal_h)
set_hl("CurSearch", match_current_h) set_hl("CurSearch", match_cur_h)
set_hl("MatchParen", match_normal_h) set_hl("MatchParen", match_reverse_h)
-- selection ------------------------------------------------------------------- -- selection -------------------------------------------------------------------
local selection_normal_h = H:new():fg(magenta_c):attr("reverse") local selection_normal_h = H:new():fg(black_c):bg(magenta_c)
set_hl("visual", selection_normal_h) set_hl("visual", selection_normal_h)
set_hl("visualnos", selection_normal_h) set_hl("visualnos", selection_normal_h)
@ -275,43 +274,72 @@ set_hl("Directory", H:new():fg(blue_c):attr("bold"))
-- syntax ---------------------------------------------------------------------- -- syntax ----------------------------------------------------------------------
local syntax_normal_h = {} local syntax_normal_h = {}
local syntax_comment_h = H:new():fg(blue_c):attr("bold") local syntax_comment_h = H:new():fg(blue_c):attr("bold")
local syntax_ignore_h = H:new():fg(black_c) -- local syntax_constant_h = H:new():fg(magenta_c)
-- local syntax_identifier_h = H:new():fg(white_c)
-- local syntax_statement_h = H:new():fg(magenta_c)
-- local syntax_preproc_h = H:new():fg(magenta_c)
-- local syntax_type_h = H:new():fg(green_c)
-- local syntax_special_h = H:new():fg(cyan_c)
local syntax_constant_h = H:new():fg(red_c)
local syntax_identifier_h = H:new():fg(cyan_c)
local syntax_statement_h = H:new():fg(orange_c)
local syntax_preproc_h = H:new():fg(magenta_c)
local syntax_type_h = H:new():fg(green_c)
local syntax_special_h = H:new():fg(orange_c)
local syntax_underline_h = H:new():attr("underline") local syntax_underline_h = H:new():attr("underline")
local syntax_error_h = H:new():fg(red_c) local syntax_ignore_h = H:new():fg(black_c)
local syntax_warn_h = H:new():fg(orange_c) local syntax_error_h = H:new():fg(black_c):bg(red_c)
local syntax_warn_h = H:new():fg(black_c):bg(orange_c)
local syntax_italic_h = H:new():attr("italic")
local syntax_bold_h = H:new():attr("bold")
local syntax_bolditalic_h = H:new():attr("bold"):attr("italic")
set_hl("Comment", syntax_comment_h) set_hl("Comment", syntax_comment_h)
set_hl("Constant", syntax_normal_h) set_hl("Constant", syntax_constant_h)
set_hl("String", syntax_normal_h) set_hl("String", syntax_constant_h)
set_hl("Character", syntax_normal_h) set_hl("Character", syntax_constant_h)
set_hl("Number", syntax_normal_h) set_hl("Number", syntax_constant_h)
set_hl("Boolean", syntax_normal_h) set_hl("Boolean", syntax_constant_h)
set_hl("Float", syntax_normal_h) set_hl("Float", syntax_constant_h)
set_hl("Identifier", syntax_normal_h) set_hl("Identifier", syntax_identifier_h)
set_hl("Function", syntax_normal_h) set_hl("Function", syntax_identifier_h)
set_hl("Statement", syntax_normal_h) set_hl("Statement", syntax_statement_h)
set_hl("Conditional", syntax_normal_h) set_hl("Conditional", syntax_statement_h)
set_hl("Repeat", syntax_normal_h) set_hl("Repeat", syntax_statement_h)
set_hl("Label", syntax_normal_h) set_hl("Label", syntax_statement_h)
set_hl("Operator", syntax_normal_h) set_hl("Operator", syntax_statement_h)
set_hl("Keyword", syntax_normal_h) set_hl("Keyword", syntax_statement_h)
set_hl("Exception", syntax_normal_h) set_hl("Exception", syntax_statement_h)
set_hl("PreProc", syntax_normal_h) set_hl("PreProc", syntax_preproc_h)
set_hl("Include", syntax_normal_h) set_hl("Include", syntax_preproc_h)
set_hl("Define", syntax_normal_h) set_hl("Define", syntax_preproc_h)
set_hl("Macro", syntax_normal_h) set_hl("Macro", syntax_preproc_h)
set_hl("PreCondit", syntax_normal_h) set_hl("PreCondit", syntax_preproc_h)
set_hl("Type", syntax_normal_h) set_hl("Type", syntax_type_h)
set_hl("StorageClass", syntax_normal_h) set_hl("StorageClass", syntax_type_h)
set_hl("Structure", syntax_normal_h) set_hl("Structure", syntax_type_h)
set_hl("Typedef", syntax_normal_h) set_hl("Typedef", syntax_type_h)
set_hl("Special", syntax_normal_h) set_hl("Special", syntax_special_h)
set_hl("SpecialChar", syntax_normal_h) set_hl("SpecialChar", syntax_special_h)
set_hl("Tag", syntax_normal_h) set_hl("Tag", syntax_special_h)
set_hl("Delimiter", syntax_normal_h) set_hl("Delimiter", syntax_special_h)
set_hl("SpecialComment", syntax_normal_h) set_hl("SpecialComment", syntax_special_h)
set_hl("Debug", syntax_normal_h) set_hl("Debug", syntax_special_h)
set_hl("Underlined", syntax_underline_h) set_hl("Underlined", syntax_underline_h)
set_hl("Ignore", syntax_ignore_h) set_hl("Ignore", syntax_ignore_h)
set_hl("Error", syntax_error_h) set_hl("Error", syntax_error_h)
set_hl("Todo", syntax_warn_h) set_hl("Todo", syntax_warn_h)
set_hl("Italic", syntax_italic_h)
set_hl("Bold", syntax_bold_h)
set_hl("BoldItalic", syntax_bolditalic_h)
-- markdown --------------------------------------------------------------------
local markdown_label_h = H:new():fg(magenta_c)
local markdown_delimiter_h = H:new():fg(blue_c):attr("bold")
local markdown_underline_h = H:new():fg(blue_c):attr("underline"):attr("bold")
set_hl("markdownLabel", markdown_label_h)
set_hl("markdownDelimiter", markdown_delimiter_h)
set_hl("markdownUnderlined", markdown_underline_h)

View File

@ -1,6 +1,6 @@
-- options --------------------------------------------------------------------- -- options ---------------------------------------------------------------------
-- colorscheme -- colorscheme
vim.cmd("colorscheme basic") -- TODO vim.cmd.colorscheme("basic")
-- leader -- leader
vim.g.mapleader = " " vim.g.mapleader = " "
@ -24,19 +24,19 @@ vim.opt.colorcolumn = "+1"
-- tabline, winbar, statusline -- tabline, winbar, statusline
vim.opt.showtabline = 2 vim.opt.showtabline = 2
-- vim.opt.winbar = "%f%( %h%m%r%) %y" vim.opt.winbar = "%f%( %h%m%r%y %)"
vim.opt.laststatus = 3 vim.opt.laststatus = 3
function _G.statusline() function _G.statusline()
local col = vim.api.nvim_win_get_cursor(0)[2] + 1 local col = vim.api.nvim_win_get_cursor(0)[2] + 1
local char = vim.api.nvim_get_current_line():sub(col, col) local char = vim.api.nvim_get_current_line():sub(col, col):gsub("%%", "%%%1")
local wc = vim.fn.wordcount() local wc = vim.fn.wordcount()
return table.concat({ return table.concat({
vim.fn.pathshorten(vim.fn.getcwd()), vim.fn.pathshorten(vim.fn.getcwd()), " %f",
"%( %h%m%r%y%)",
"%=", "%=",
" %12(", "'", char, "' %b%)", "<", char, "> %b ",
" %12(", wc.visual_chars or wc.cursor_chars, "/", wc.chars, "%)", wc.visual_chars or wc.cursor_chars, "/", wc.chars, " ",
" %12(", wc.visual_words or wc.cursor_words, "/", wc.words, "%)", wc.visual_words or wc.cursor_words, "/", wc.words
" %12(%l,%c%V%) %P",
}) })
end end
vim.opt.statusline = "%!v:lua.statusline()" vim.opt.statusline = "%!v:lua.statusline()"
@ -58,31 +58,28 @@ vim.opt.whichwrap = {
["["] = true, ["["] = true,
["]"] = true ["]"] = true
} }
-- vim.opt.wildignorecase = true vim.opt.wildoptions = { "fuzzy" }
-- vim.opt.wildoptions:append("fuzzy") vim.opt.wildignorecase = true
--
vim.cmd("cnoreabbrev W w")
vim.cmd("cnoreabbrev Q q")
-- langmap -- langmap
vim.opt.langmap = { "č\\;", "Č:", "š[", "Š{", "đ]", "Đ}", "ž#", "Ž~" } vim.opt.langmap = { "č\\;", "Č:", "š[", "Š{", "đ]", "Đ}", "ž#", "Ž~" }
-- path -- path
vim.opt.path = ".,,**" vim.opt.path = ".,,**"
-- local root = vim.fs.find({ ".git" }, { upward = true })[1]
-- completion -- completion
vim.opt.completeopt = { vim.opt.completeopt = {
"menuone", "menuone",
"noinsert",
"preview", "preview",
"noinsert",
"noselect" "noselect"
} }
-- keymaps --------------------------------------------------------------------- -- keymaps ---------------------------------------------------------------------
-- clear hlsearch -- clear hlsearch
vim.keymap.set( "n", "<esc>", function() vim.keymap.set( "n", "<esc>", function()
vim.cmd("nohlsearch") vim.cmd.nohlsearch()
end, { desc = "Stop the highlighting for the 'hlsearch' option" }) end, { desc = "Stop the highlighting for the 'hlsearch' option" })
-- move cursor with alt in c-mode -- move cursor with alt in c-mode
@ -156,16 +153,6 @@ vim.keymap.set("n", "cc", "<cmd>cclose<cr>", { desc = "Close quickfix window" })
vim.keymap.set("n", "]q", "<cmd>cnext<cr>zz", { desc = "Next quickfix item" }) vim.keymap.set("n", "]q", "<cmd>cnext<cr>zz", { desc = "Next quickfix item" })
vim.keymap.set("n", "[q", "<cmd>cprev<cr>zz", { desc = "Previous quickfix item" }) vim.keymap.set("n", "[q", "<cmd>cprev<cr>zz", { desc = "Previous quickfix item" })
-- highlight on yank -----------------------------------------------------------
local yankhighlight_group = vim.api.nvim_create_augroup("YankHighlight", {})
vim.api.nvim_create_autocmd("TextYankPost", {
group = yankhighlight_group,
desc = "Highlight on yank",
callback = function()
vim.highlight.on_yank()
end
})
-- netrw ----------------------------------------------------------------------- -- netrw -----------------------------------------------------------------------
vim.g.netrw_use_errorwindow = 0 vim.g.netrw_use_errorwindow = 0
vim.g.netrw_banner = 0 vim.g.netrw_banner = 0
@ -183,102 +170,3 @@ vim.api.nvim_create_autocmd("Filetype", {
vim.keymap.set("n", "<esc>", "<cmd>Rexplore<cr>", { buffer = true }) vim.keymap.set("n", "<esc>", "<cmd>Rexplore<cr>", { buffer = true })
end end
}) })
-- autopairs -------------------------------------------------------------------
local brackets = {
"()",
"[]",
"{}",
"<>",
}
for _,v in pairs(brackets) do
vim.keymap.set({ "i", "c" }, v:sub(1,1), ("%s<left>"):format(v))
end
vim.keymap.set("i", "<bs>", function()
local l = vim.api.nvim_get_current_line()
local c = vim.api.nvim_win_get_cursor(0)[2]
local pair = l:sub(c, c + 1)
for _, bracket in pairs(brackets) do
if bracket == pair then
return "<bs><del>"
end
end
return "<bs>"
end, { expr = true })
vim.keymap.set("c", "<bs>", function()
local l = vim.fn.getcmdline()
local c = vim.fn.getcmdpos()
local pair = l:sub(c - 1, c)
for _, bracket in pairs(brackets) do
if bracket == pair then
return "<bs><del>"
end
end
return "<bs>"
end, { expr = true })
-- comment ---------------------------------------------------------------------
-- function toggle(line_start, line_end)
-- -- make comment parts
-- local buf_cs = vim.bo.commentstring:gsub("%%s", " %%s "):gsub("%s*$", "")
-- local left, right = cs:match("^%s*(.*)%%s(.-)%s*$")
-- -- get lines
-- local lines = vim.api.nvim_buf_get_lines(0, line_start - 1, line_end, false)
-- -- get indent
-- local indent
-- for _, l in pairs(lines) do
-- _, n_indent_cur, indent_cur = l:find("^(%s*)")
-- local is_blank = n_indent_cur == l:len()
--
-- if n_indent_cur < n_indent and not is_blank then
-- n_indent = n_indent_cur
-- indent = indent_cur
-- end
-- end
--
-- -- if is comment, make uncomment
-- --
-- -- else make comment
-- -- set lines
-- end
-- vim.keymap.set("n", "gcc1", function()
-- print("buf_cs", buf_cs)
-- local buf_cs_before, buf_cs_after = buf_cs:match("^(.*)%%s(.*)$")
--
-- local capture = ("^(%%s*)(%s)(.*)(%s)$"):format(buf_cs_before, buf_cs_after)
--
-- print("capture", capture)
--
-- local c_leading_space, c_buf_cs_before, c_line, c_buf_cs_after =
-- vim.api.nvim_get_current_line():match(capture)
--
-- print("|", c_leading_space, "|")
--
-- print("c_leading_space", "|" .. c_leading_space .. "|")
-- print("c_buf_cs_before", "|" .. c_buf_cs_before .. "|")
-- print("c_line", "|" .. c_line .. "|")
-- print("c_buf_cs_after", "|" .. c_buf_cs_after .. "|")
--
-- -- if line:find(("^%%s*(%s).*(%s)$"):format(buf_cs_before, buf_commentstring_after)) then
-- -- print("yes!")
-- -- return
-- -- end
-- --
-- -- local leading_space, line = vim.api.nvim_get_current_line():match("(%s*)(.*)")
-- --
-- -- local new_line = table.concat({
-- -- leading_space,
-- -- buf_cs_before,
-- -- " ",
-- -- line,
-- -- buf_commentstring_after
-- -- })
-- --
-- -- local row = vim.api.nvim_win_get_cursor(0)[1]
-- --
-- -- vim.api.nvim_buf_set_lines(0, row - 1, row, true, { new_line })
-- end)

View File

@ -0,0 +1,277 @@
" Vim syntax file
" Language: Markdown
" Maintainer: urosm <urosm@kompot.si>
" Last Change: 2024 Jan 13
if exists("b:current_syntax")
finish
endif
runtime! syntax/html.vim
unlet! b:current_syntax
syntax spell toplevel
" comment
syn region markdownHTMLComment start=/<!--\s\=/ end=/\s\=-->/ keepend
hi def link markdownHTMLComment markdownComment
" titleblock
syn region markdownTitleBlock start=/\%^%/ end=/\n\n/ contains=markdownTitleBlockDelimiter
hi def link markdownTitleBlock markdownBold
syn match markdownTitleBlockDelimiter /%\ / contained
hi def link markdownTitleBlockDelimiter markdownDelimiter
" blockquote
syn match markdownBlockquote /^\s\{,3}>.*\n\(.*\n\@1<!\n\)*/ contains=@Spell,markdownItalic,markdownBold,markdownPCite,markdownSuperscript,markdownSubscript,markdownStrike,markdownUListItem,markdownNoFormatted,markdownAmpersandEscape,markdownLaTeXInlineMath,markdownEscapedDollar,markdownLaTeXCommand,markdownLaTeXMathBlock,markdownLaTeXRegion,markdownBlockquoteDelimiter skipnl
syn match markdownBlockquoteDelimiter /\_^\(\s\{,3}>\)\+/ contained containedin=markdownItalic,markdownBold,markdownPCite,markdownSuperscript,markdownSubscript,markdownStrike,markdownUListItem,markdownNoFormatted
hi def link markdownBlockquoteDelimiter markdownDelimiter
" link
syn match markdownLink /!\=\[.\{-}\](.\{-})/ contains=markdownLinkLabel,markdownLinkURL
hi def link markdownLink markdownDelimiter
syn match markdownLinkLabel /\[\@1<=[^\]]\+/ contained
hi def link markdownLinkLabel markdownLabel
syn match markdownLinkURL /(\@1<=[^)]\+/ contained
hi def link markdownLinkURL markdownUnderlined
" automatic link
syn match markdownAutomaticLink /<\(https\{0,1}.\{-}\|[A-Za-z0-9!#$%&'*+\-/=?^_`{|}~.]\{-}@[A-Za-z0-9\-]\{-}\.\w\{-}\)>/ contains=NONE
hi def link markdownAutomaticLink markdownUnderlined
" wikilink
syn region markdownWikilink start=/\[\[/ end=/\]\]/ contains=markdownWikilinkLabel,markdownWikilinkURL keepend display
hi def link markdownWikilink markdownDelimiter
syn match markdownWikilinkLabel /\(\[\[\)\@2<=[^\|\[\]]\+/ contained
hi def link markdownWikilinkLabel markdownLabel
syn match markdownWikilinkURL /|\@1<=[^\]]\+/ contained
hi def link markdownWikilinkURL markdownUnderlined
" definition
syn region markdownReferenceDefinition start=/\[.\{-}\]:/ end=/\(\n\s*".*"$\|$\)/ keepend
hi def link markdownReferenceDefinition markdownDelimiter
syn match markdownReferenceDefinitionLabel /\[\zs.\{-}\ze\]:/ contained containedin=markdownReferenceDefinition display
hi def link markdownReferenceDefinitionLabel markdownLabel
syn match markdownReferenceDefinitionURL /:\s*\zs.*/ contained containedin=markdownReferenceDefinition
hi def link markdownReferenceDefinitionURL markdownUnderlined
syn match markdownReferenceDefinitionTitle /\s*".\{-}"/ contained containedin=markdownReferenceDefinition,markdownReferenceDefinitionURL contains=@Spell,markdownAmpersandEscape
hi def link markdownReferenceDefinitionTitle markdownTitle
" citation
syn match markdownPCite "\^\@<!\[[^\[\]]\{-}-\{0,1}@[[:alnum:]_][[:digit:][:lower:][:upper:]_:.#$%&\-+?<>~/]*.\{-}\]" contains=markdownItalic,markdownBold,markdownLatex,markdownCiteKey,@Spell,markdownAmpersandEscape
syn match markdownICite "@[[:alnum:]_][[:digit:][:lower:][:upper:]_:.#$%&\-+?<>~/]*\s\[.\{-1,}\]" contains=markdownCiteKey,@Spell display
syn match markdownCiteKey /\(-\=@[[:alnum:]_][[:digit:][:lower:][:upper:]_:.#$%&\-+?<>~/]*\)/ containedin=markdownPCite,markdownICite contains=@NoSpell display
hi def link markdownCiteKey markdownLabel
syn match markdownCiteLocator /[\[\]]/ contained containedin=markdownPCite,markdownICite
hi def link markdownCiteLocator markdownDelimiter
" italic
syn region markdownItalic matchgroup=markdownDelimiter start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=\*\S\@=/ skip=/\(\*\*\|__\)/ end=/\*\([[:punct:]]\|\s\|\_$\)\@=/ contains=@Spell,markdownNoFormattedInEmphasis,markdownLatexInlineMath,markdownAmpersandEscape
syn region markdownItalic matchgroup=markdownDelimiter start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=_\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@1<=_\([[:punct:]]\|\s\|\_$\)\@=/ contains=@Spell,markdownNoFormattedInEmphasis,markdownLatexInlineMath,markdownAmpersandEscape
hi def link markdownItalic htmlItalic
" bold
syn region markdownBold matchgroup=markdownDelimiter start=/\(\\\@<!\*\)\{2}/ end=/\(\\\@<!\*\)\{2}/ contains=@Spell,markdownNoFormattedInStrong,markdownLatexInlineMath,markdownAmpersandEscape
syn region markdownBold matchgroup=markdownDelimiter start=/__/ end=/__/ contains=@Spell,markdownNoFormattedInStrong,markdownLatexInlineMath,markdownAmpersandEscape
hi def link markdownBold htmlBold
" bold italic
syn region markdownBoldItalic matchgroup=markdownDelimiter start=/\*\{3}\(\S[^*]*\(\*\S\|\n[^*]*\*\S\)\)\@=/ end=/\S\@<=\*\{3}/ contains=@Spell,markdownAmpersandEscape
syn region markdownBoldItalic matchgroup=markdownDelimiter start=/\(___\)\S\@=/ end=/\S\@<=___/ contains=@Spell,markdownAmpersandEscape
hi def link markdownBoldItalic htmlBoldItalic
syn region markdownBoldInItalic matchgroup=markdownDelimiter start=/\*\*/ end=/\*\*/ contained containedin=markdownItalic contains=@Spell,markdownAmpersandEscape
syn region markdownBoldInItalic matchgroup=markdownDelimiter start=/__/ end=/__/ contained containedin=markdownItalic contains=@Spell,markdownAmpersandEscape
syn region markdownItalicInBold matchgroup=markdownDelimiter start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=\*\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@<=\*\([[:punct:]]\|\s\|\_$\)\@=/ contained containedin=markdownBold contains=@Spell,markdownAmpersandEscape
syn region markdownItalicInBold matchgroup=markdownDelimiter start=/\\\@<!\(\_^\|\s\|[[:punct:]]\)\@<=_\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@<=_\([[:punct:]]\|\s\|\_$\)\@=/ contained containedin=markdownBold contains=@Spell,markdownAmpersandEscape
hi def link markdownBoldInItalic markdownBoldItalic
hi def link markdownItalicInBold markdownBoldItalic
" subscript
syn region markdownSubscript start=/\~\(\([[:graph:]]\(\\ \)\=\)\{-}\~\)\@=/ end=/\~/ keepend
syn match markdownSubscriptDelimiter /\~/ contained containedin=markdownSubscript
hi def link markdownSubscriptDelimiter markdownDelimiter
" superscript
syn region markdownSuperscript start=/\^\(\([[:graph:]]\(\\ \)\=\)\{-}\^\)\@=/ skip=/\\ / end=/\^/ keepend
syn match markdownSuperscriptDelimiter /\^/ contained containedin=markdownSuperscript
hi def link markdownSuperscriptDelimiter markdownDelimiter
" strikeout
syn region markdownStrike start=/\~\~/ end=/\~\~/ contains=@Spell,markdownAmpersandEscape keepend
syn match markdownStrikeDelimiter /\~\~/ contained containedin=markdownStrikeout
hi def link markdownStrike htmlStrike
hi def link markdownStrikeDelimiter markdownDelimiter
" heading
syn match markdownAtxHeading /\(\%^\|<.\+>.*\n\|^\s*\n\)\@<=#\{1,6}.*\n/ contains=markdownItalic,markdownBold,markdownNoFormatted,markdownLaTeXInlineMath,markdownEscapedDollar,@Spell,markdownAmpersandEscape,markdownLinkText,markdownLinkURL display
hi def link markdownAtxHeading Title
syn match markdownAtxHeadingDelimiter /\(^#\{1,6}\|\\\@<!#\+\(\s*.*$\)\@=\)/ contained containedin=markdownAtxHeading
hi def link markdownAtxHeadingDelimiter markdownDelimiter
syn match markdownSetexHeading /^.\+\n[=]\+$/ contains=markdownItalic,markdownBold,markdownNoFormatted,markdownLaTeXInlineMath,markdownEscapedDollar,@Spell,markdownAmpersandEscape
syn match markdownSetexHeading /^.\+\n[-]\+$/ contains=markdownItalic,markdownBold,markdownNoFormatted,markdownLaTeXInlineMath,markdownEscapedDollar,@Spell,markdownAmpersandEscape
syn match markdownHeadingAttr /{.*}/ contained containedin=markdownAtxHeader,markdownSetexHeader
syn match markdownHeadingID /#[-_:.[:lower:][:upper:]]*/ contained containedin=markdownHeaderAttr
hi def link markdownSetexHeading markdownTitle
hi def link markdownHeadingAttr markdownComment
hi def link markdownHeadingID markdownIdentifier
" line block
syn region markdownLineBlock start=/^|/ end=/\(^|\(.*\n|\@!\)\@=.*\)\@<=\n/ transparent
syn match markdownLineBlockDelimiter /^|/ contained containedin=markdownLineBlock
hi def link markdownLineBlockDelimiter markdownDelimiter
" simple table
syn region markdownSimpleTable start=/\%#=2\(^.*[[:graph:]].*\n\)\@<!\(^.*[[:graph:]].*\n\)\(-\{2,}\s*\)\+\n\n\@!/ end=/\n\n/ containedin=ALLBUT,markdownDelimitedCodeBlock,markdownDelimitedCodeBlockStart,markdownYAMLHeader keepend
syn match markdownSimpleTableDelims /\-/ contained containedin=markdownSimpleTable
syn match markdownSimpleTableHeader /\%#=2\(^.*[[:graph:]].*\n\)\@<!\(^.*[[:graph:]].*\n\)/ contained containedin=markdownSimpleTable
hi def link markdownSimpleTableDelims markdownDelimiter
hi def link markdownSimpleTableHeader markdownBold
syn region markdownTable start=/\%#=2^\(-\{2,}\s*\)\+\n\n\@!/ end=/\%#=2^\(-\{2,}\s*\)\+\n\n/ containedin=ALLBUT,markdownDelimitedCodeBlock,markdownYAMLHeader keepend
syn match markdownTableDelims /\-/ contained containedin=markdownTable
syn region markdownTableMultilineHeader start=/\%#=2\(^-\{2,}\n\)\@<=./ end=/\%#=2\n-\@=/ contained containedin=markdownTable
hi def link markdownTableMultilineHeader markdownBold
hi def link markdownTableDelims markdownDelimiter
" grid table
syn region markdownGridTable start=/\%#=2\n\@1<=+-/ end=/+\n\n/ containedin=ALLBUT,markdownDelimitedCodeBlock,markdownYAMLHeader keepend
syn match markdownGridTableDelims /[\|=]/ contained containedin=markdownGridTable
syn match markdownGridTableDelims /\%#=2\([\-+][\-+=]\@=\|[\-+=]\@1<=[\-+]\)/ contained containedin=markdownGridTable
syn match markdownGridTableHeader /\%#=2\(^.*\n\)\(+=.*\)\@=/ contained containedin=markdownGridTable
hi def link markdownGridTableDelims markdownDelimiter
hi def link markdownGridTableHeader markdownDelimiter
" pipe table
syn region markdownPipeTable start=/\%#=2\([+|]\n\)\@<!\n\@1<=|\(.*|\)\@=/ end=/|.*\n\(\n\|{\)/ containedin=ALLBUT,markdownDelimitedCodeBlock,markdownYAMLHeader keepend
syn region markdownPipeTable start=/\%#=2^.*\n-.\{-}|/ end=/|.*\n\n/ keepend
syn match markdownPipeTableDelims /[\|\-:+]/ contained containedin=markdownPipeTable
syn match markdownPipeTableHeader /\(^.*\n\)\(|-\)\@=/ contained containedin=markdownPipeTable
syn match markdownPipeTableHeader /\(^.*\n\)\(-\)\@=/ contained containedin=markdownPipeTable
hi def link markdownPipeTableDelims markdownDelimiter
hi def link markdownPipeTableHeader markdownDelimiter
syn match markdownTableHeaderWord /\<.\{-}\>/ contained containedin=markdownGridTableHeader,markdownPipeTableHeader contains=@Spell
hi def link markdownTableHeaderWord markdownBold
" delimited code blocks
syn region markdownDelimitedCodeBlock start=/^\(>\s\)\?\z(\([ ]\+\|\t\)\=\~\{3,}\~*\)/ end=/^\z1\~*/ skipnl contains=markdownDelimitedCodeBlockStart,markdownDelimitedCodeBlockEnd keepend
syn region markdownDelimitedCodeBlock start=/^\(>\s\)\?\z(\([ ]\+\|\t\)\=`\{3,}`*\)/ end=/^\z1`*/ skipnl contains=markdownDelimitedCodeBlockStart,markdownDelimitedCodeBlockEnd keepend
syn match markdownDelimitedCodeBlockStart /\(\(\_^\n\_^\|\%^\)\(>\s\)\?\( \+\|\t\)\=\)\@<=\(\~\{3,}\~*\|`\{3,}`*\)/ contained containedin=markdownDelimitedCodeBlock nextgroup=markdownDelimitedCodeBlockLanguage
syn match markdownDelimitedCodeBlockLanguage /\(\s\?\)\@<=.\+\(\_$\)\@=/ contained
syn match markdownDelimitedCodeBlockEnd /\(`\{3,}`*\|\~\{3,}\~*\)\(\_$\n\(>\s\)\?\_$\)\@=/ contained containedin=markdownDelimitedCodeBlock
syn match markdownBlockquoteinDelimitedCodeBlock '^>' contained containedin=markdownDelimitedCodeBlock
syn match markdownCodePre /<pre>.\{-}<\/pre>/ skipnl
syn match markdownCodePre /<code>.\{-}<\/code>/ skipnl
hi def link markdownDelimitedCodeBlock markdownSpecial
hi def link markdownDelimitedCodeBlockStart markdownDelimiter
hi def link markdownDelimitedCodeBlockEnd markdownDelimiter
hi def link markdownDelimitedCodeBlockLanguage markdownComment
hi def link markdownBlockquoteinDelimitedCodeBlock markdownBlockquote
hi def link markdownCodePre markdownString
" footnote
syn match markdownFootnoteID /\[\^[^\]]\+\]/ nextgroup=markdownFootnoteDef
hi def link markdownFootnoteID markdownLabel
" inline footnote
syn region markdownFootnoteDef start=/\^\[/ skip=/\[.\{-}]/ end=/\]/ contains=markdownLinkText,markdownLinkURL,markdownLatex,markdownPCite,markdownCiteKey,markdownBold,markdownItalic,markdownBoldItalic,markdownNoFormatted,markdownSuperscript,markdownSubscript,markdownStrike,markdownEnDash,markdownEmDash,markdownEllipses,markdownBeginQuote,markdownEndQuote,@Spell,markdownAmpersandEscape skipnl keepend
hi def link markdownFootnoteDef markdownComment
syn match markdownFootnoteDefHead /\^\[/ contained containedin=markdownFootnoteDef
hi def link markdownFootnoteDefHead markdownDelimiter
syn match markdownFootnoteDefTail /\]/ contained containedin=markdownFootnoteDef
hi def link markdownFootnoteDefTail markdownDelimiter
" regular footnotes
syn region markdownFootnoteBlock start=/\[\^.\{-}\]:\s*\n*/ end=/^\n^\s\@!/ contains=markdownLinkText,markdownLinkURL,markdownLatex,markdownPCite,markdownCiteKey,markdownBold,markdownItalic,markdownNoFormatted,markdownSuperscript,markdownSubscript,markdownStrike,markdownEnDash,markdownEmDash,markdownNewLine,markdownBoldItalic,markdownEllipses,markdownBeginQuote,markdownEndQuote,markdownLaTeXInlineMath,markdownEscapedDollar,markdownLaTeXCommand,markdownLaTeXMathBlock,markdownLaTeXRegion,markdownAmpersandEscape,@Spell skipnl
syn match markdownFootnoteBlockSeparator /:/ contained containedin=markdownFootnoteBlock
hi def link markdownFootnoteBlockSeparator markdownDelimiter
syn match markdownFootnoteID /\[\^.\{-}\]/ contained containedin=markdownFootnoteBlock
syn match markdownFootnoteIDHead /\[\^/ contained containedin=markdownFootnoteID
hi def link markdownFootnoteIDHead markdownDelimiter
syn match markdownFootnoteIDTail /\]/ contained containedin=markdownFootnoteID
hi def link markdownFootnoteIDTail markdownDelimiter
" unordered list
syn match markdownUListItem /^>\=\s*[*+-]\s\+-\@!.*$/ nextgroup=markdownUListItem,markdownLaTeXMathBlock,markdownLaTeXInlineMath,markdownEscapedDollar,markdownDelimitedCodeBlock,markdownListItemContinuation contains=@Spell,markdownItalic,markdownBold,markdownNoFormatted,markdownStrike,markdownSubscript,markdownSuperscript,markdownBoldItalic,markdownBoldItalic,markdownPCite,markdownICite,markdownCiteKey,markdownLinkText,markdownLaTeXCommand,markdownLaTeXMathBlock,markdownLaTeXInlineMath,markdownEscapedDollar,markdownLinkURL,markdownAutomaticLink,markdownFootnoteDef,markdownFootnoteBlock,markdownFootnoteID,markdownAmpersandEscape skipempty display
syn match markdownUListItemBullet /^>\=\s*\zs[*+-]/ contained containedin=markdownUListItem
hi def link markdownUListItemBullet markdownOperator
" ordered list
syn match markdownListItem /^\s*(\?\(\d\+\|\l\|\#\|@\)[.)].*$/ nextgroup=markdownListItem,markdownLaTeXMathBlock,markdownLaTeXInlineMath,markdownEscapedDollar,markdownDelimitedCodeBlock,markdownListItemContinuation contains=@Spell,markdownItalic,markdownBold,markdownNoFormatted,markdownStrike,markdownSubscript,markdownSuperscript,markdownBoldItalic,markdownBoldItalic,markdownPCite,markdownICite,markdownCiteKey,markdownLinkText,markdownLaTeXCommand,markdownLaTeXMathBlock,markdownLaTeXInlineMath,markdownEscapedDollar,markdownAutomaticLink,markdownFootnoteDef,markdownFootnoteBlock,markdownFootnoteID,markdownAmpersandEscape skipempty display
syn match markdownListItem /^\s*(\?x\=l\=\(i\{,3}[vx]\=\)\{,3}c\{,3}[.)].*$/ nextgroup=markdownListItem,markdownMathBlock,markdownLaTeXInlineMath,markdownEscapedDollar,markdownDelimitedCodeBlock,markdownListItemContinuation,markdownAutomaticLink skipempty display
syn match markdownListItemBullet /^(\?.\{-}[.)]/ contained containedin=markdownListItem
syn match markdownListItemBulletId /\(\d\+\|\l\|\#\|@.\{-}\|x\=l\=\(i\{,3}[vx]\=\)\{,3}c\{,3}\)/ contained containedin=markdownListItemBullet
hi def link markdownListItemBullet markdownOperator
hi def link markdownListItemBulletId markdownIdentifier
syn match markdownListItemContinuation /^\s\+\([-+*]\s\+\|(\?.\+[).]\)\@<!\([[:upper:][:lower:]_"[]\|\*\S\)\@=.*$/ nextgroup=markdownLaTeXMathBlock,markdownLaTeXInlineMath,markdownEscapedDollar,markdownDelimitedCodeBlock,markdownListItemContinuation,markdownListItem contains=@Spell,markdownItalic,markdownBold,markdownNoFormatted,markdownStrike,markdownSubscript,markdownSuperscript,markdownBoldItalic,markdownBoldItalic,markdownPCite,markdownICite,markdownCiteKey,markdownLinkText,markdownLinkURL,markdownLaTeXCommand,markdownLaTeXMathBlock,markdownLaTeXInlineMath,markdownEscapedDollar,markdownAutomaticLink,markdownFootnoteDef,markdownFootnoteBlock,markdownFootnoteID,markdownAmpersandEscape contained skipempty display
" definition list
syn region markdownDefinitionBlock start=/^\%(\_^\s*\([`~]\)\1\{2,}\)\@!.*\n\(^\s*\n\)\=\s\{0,2}\([:~]\)\(\3\{2,}\3*\)\@!/ skip=/\n\n\zs\s/ end=/\n\n/ contains=markdownDefinitionBlockDelimiter,markdownDefinitionBlockTerm,markdownCodeBlockInsideIndent,markdownItalic,markdownBold,markdownBoldItalic,markdownNoFormatted,markdownStrike,markdownSubscript,markdownSuperscript,markdownFootnoteID,markdownLinkURL,markdownLinkText,markdownLaTeXMathBlock,markdownLaTeXInlineMath,markdownEscapedDollar,markdownAutomaticLink,markdownEmDash,markdownEnDash,markdownFootnoteDef,markdownFootnoteBlock,markdownFootnoteID
syn match markdownDefinitionBlockTerm /^.*\n\(^\s*\n\)\=\(\s*[:~]\)\@=/ contained contains=markdownNoFormatted,markdownItalic,markdownBold,markdownLaTeXInlineMath,markdownEscapedDollar,markdownFootnoteDef,markdownFootnoteBlock,markdownFootnoteID nextgroup=markdownDefinitionBlockDelimiter
syn match markdownDefinitionBlockDelimiter /^\s*[:~]/ contained
hi def link markdownDefinitionBlockTerm markdownIdentifier
hi def link markdownDefinitionBlockDelimiter markdownDelimiter
" new line
syn match markdownNewLine /\%(\%(\S\)\@<= \{2,}\|\\\)$/ display containedin=markdownItalic,markdownBold,markdownBoldItalic,markdownBoldInItalic,markdownItalicInBold
hi def link markdownNewLine Error
" rule
syn match markdownHRule /^\s*\([*\-_]\)\s*\%(\1\s*\)\{2,}$/ display
hi def link markdownHRule markdownDelimiter
" &-escape
syn match markdownAmpersandEscape /\v\&(#\d+|#x\x+|[[:alnum:]]+)\;/ contains=NoSpell
hi def link markdownAmpersandEscape Special
" yaml
syn include @YAML syntax/yaml.vim
unlet! b:current_syntax
syn region markdownYAMLHeader start=/\%(\%^\|\_^\s*\n\)\@<=\_^-\{3}\ze\n.\+/ end=/^\([-.]\)\1\{2}$/ keepend contains=@YAML containedin=TOP
" Styling
hi def link markdownComment Comment
hi def link markdownConstant Constant
hi def link markdownString String
hi def link markdownCharacter Character
hi def link markdownNumber Number
hi def link markdownBoolean Boolean
hi def link markdownFloat Float
hi def link markdownIdentifier Identifier
hi def link markdownFunction Function
hi def link markdownStatement Statement
hi def link markdownConditional Conditional
hi def link markdownRepeat Repeat
hi def link markdownLabel Label
hi def link markdownOperator Operator
hi def link markdownKeyword Keyword
hi def link markdownException Exception
hi def link markdownPreProc PreProc
hi def link markdownInclude Include
hi def link markdownDefine Define
hi def link markdownMacro Macro
hi def link markdownPreCondit PreCondit
hi def link markdownType Type
hi def link markdownStorageClass StorageClass
hi def link markdownStructure Structure
hi def link markdownTypedef Typedef
hi def link markdownSpecial Special
hi def link markdownSpecialChar SpecialChar
hi def link markdownTag Tag
hi def link markdownDelimiter Delimiter
hi def link markdownSpecialComment SpecialComment
hi def link markdownDebug Debug
hi def link markdownUnderlined Underlined
hi def link markdownIgnore Ignore
hi def link markdownItalic htmlItalic
hi def link markdownBold htmlBold
hi def link markdownItalicBold htmlItalicBold
hi def link markdownStrike htmlStrike
hi def link markdownTitle Title
let b:current_syntax = "markdown"
" vim:set sw=2: