1
0
Fork 0

add `nvim` config

main
urosm 2024-01-27 21:12:38 +01:00
parent 140a281c68
commit 25676d07e4
13 changed files with 823 additions and 0 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

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

View File

@ -0,0 +1,7 @@
-- options ---------------------------------------------------------------------
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
-- treesitter ------------------------------------------------------------------
vim.treesitter.start()

View File

@ -0,0 +1,5 @@
-- options ---------------------------------------------------------------------
vim.bo.tabstop = 2
vim.bo.shiftwidth = 2
vim.bo.expandtab = true
vim.bo.textwidth = 72

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

@ -0,0 +1,339 @@
-- basic neovim colorscheme template
--
-- A simple neovim colorscheme template that defines highlight groups
-- from a list of 8 colors.
-- colors ----------------------------------------------------------------------
local C = {
{ 0, "#292526" }, -- black
{ 1, "#ff404f" }, -- red
{ 2, "#00a147" }, -- green
{ 3, "#e06e00" }, -- orange
{ 4, "#6185ff" }, -- blue
{ 5, "#ff3e8b" }, -- magenta
{ 6, "#0095d7" }, -- cyan
{ 7, "#e3e0e1" }, -- white
{ 8, "#958a8d" }, -- black
{ 9, "#ffb3b6" }, -- red
{ 10, "#00e46a" }, -- green
{ 11, "#ffb598" }, -- orange
{ 12, "#b8c3ff" }, -- blue
{ 13, "#ffb1c5" }, -- magenta
{ 14, "#92ccff" }, -- cyan
{ 15, "#f4f3f3" }, -- white
}
local black_c = C[1]
local red_c = C[2]
local green_c = C[3]
local orange_c = C[4]
local blue_c = C[5]
local magenta_c = C[6]
local cyan_c = C[7]
local white_c = C[8]
-- init ------------------------------------------------------------------------
vim.cmd.highlight("clear")
if vim.fn.exists("syntax_on") then
vim.cmd.syntax("reset")
end
vim.opt.background = "dark"
vim.g.colors_name = "basic"
if
vim.env.TERM == "linux" or
vim.env.TERM == "screen" or
vim.env.TERM == "screen.linux"
then
vim.opt.termguicolors = false
else
vim.opt.termguicolors = true
end
local tty = vim.env.TERM == "linux" or vim.env.TERM == "screen.linux"
for _, v in ipairs(C) do
local key = ("terminal_color_%i"):format(v[1])
vim.g[key] = v[2]
end
-- highlights ------------------------------------------------------------------
local H = {}
function H:new(o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
function H:fg(c)
self.ctermfg = c[1]
self.fg = c[2]
if c[1] == 4 and tty then
self.bold = true
end
return self
end
function H:bg(c)
self.ctermbg = c[1]
self.bg = c[2]
if c[1] == 4 and tty then
self.bold = true
end
return self
end
function H:attr(a)
if tty then
if a == "underline" then return self end
end
self[a] = true
return self
end
local fg_c = white_c
local bg_c = black_c
local accent_c = magenta_c
local dimmed_c = blue_c
local function set_hl(group, def) vim.api.nvim_set_hl(0, group, def) end
-- normal ----------------------------------------------------------------------
local normal_h = {}
set_hl("Normal", normal_h)
set_hl("NormalNC", normal_h)
-- tui -------------------------------------------------------------------------
local tui_normal_h = {}
local tui_accent_h = H:new():fg(accent_c)
local tui_dimmed_h = H:new():fg(dimmed_c)
set_hl("StatusLine", tui_dimmed_h)
set_hl("StatusLineNC", tui_dimmed_h)
set_hl("TabLine", tui_dimmed_h)
set_hl("TabLineFill", tui_dimmed_h)
set_hl("TabLineSel", tui_accent_h)
set_hl("WinBar", tui_accent_h)
set_hl("WinBarNC", tui_dimmed_h)
set_hl("WinSeparator", tui_dimmed_h)
set_hl("LineNr", tui_accent_h)
set_hl("LineNrAbove", tui_dimmed_h)
set_hl("LineNrBelow", tui_dimmed_h)
set_hl("SignColumn", tui_dimmed_h)
set_hl("FoldColumn", tui_dimmed_h)
set_hl("WildMenu", tui_accent_h)
-- float -----------------------------------------------------------------------
local float_normal_h = H:new():fg(bg_c):bg(fg_c)
local float_accent_h = H:new():fg(accent_c):bg(fg_c)
set_hl("NormalFloat", float_normal_h)
set_hl("FloatBorder", float_normal_h)
set_hl("FloatTitle", float_accent_h)
-- menu ------------------------------------------------------------------------
local menu_normal_h = H:new():fg(bg_c):bg(fg_c)
local menu_accent_h = H:new():fg(accent_c):bg(fg_c)
local menu_accent_r_h = H:new():fg(accent_c):bg(fg_c):attr("reverse")
set_hl("Pmenu", menu_normal_h)
set_hl("PmenuSel", menu_accent_h)
set_hl("PmenuKind", menu_normal_h)
set_hl("PmenuKindSel", menu_accent_h)
set_hl("PmenuExtra", menu_normal_h)
set_hl("PmenuExtraSel", menu_accent_h)
set_hl("PmenuSbar", menu_accent_h)
set_hl("PmenuThumb", menu_accent_r_h)
-- messages --------------------------------------------------------------------
local message_normal_h = {}
local message_accent_h = H:new():fg(accent_c)
local message_error_h = H:new():fg(red_c)
local message_warn_h = H:new():fg(orange_c)
set_hl("MsgArea", message_normal_h)
set_hl("MsgSeparator", message_normal_h)
set_hl("ModeMsg", message_accent_h)
set_hl("MoreMsg", message_accent_h)
set_hl("WarningMsg", message_warn_h)
set_hl("ErrorMsg", message_error_h)
set_hl("Question", message_accent_h)
set_hl("Title", message_accent_h)
-- buffer ----------------------------------------------------------------------
local buffer_normal_h = H:new():fg(dimmed_c)
local buffer_normal_bg_h = H:new():bg(dimmed_c)
local buffer_accent_h = H:new():fg(accent_c)
set_hl("Conceal", buffer_normal_h)
set_hl("NonText", buffer_normal_h)
set_hl("EndOfBuffer", buffer_normal_h)
set_hl("Whitespace", buffer_normal_h)
set_hl("Folded", buffer_normal_h)
set_hl("SpecialKey", buffer_accent_h)
set_hl("ColorColumn", buffer_normal_bg_h)
-- cursor ----------------------------------------------------------------------
local cursor_normal_h = H:new():attr("reverse")
set_hl("CursorLine", cursor_normal_h)
set_hl("CursorLineNr", cursor_normal_h)
set_hl("CursorLineSign", cursor_normal_h)
set_hl("CursorLineFold", cursor_normal_h)
set_hl("CursorColumn", cursor_normal_h)
set_hl("QuickFixLine", cursor_normal_h)
set_hl("Cursor", cursor_normal_h)
set_hl("lCursor", cursor_normal_h)
set_hl("CursorIM", cursor_normal_h)
set_hl("TermCursor", cursor_normal_h)
set_hl("TermCursorNC", cursor_normal_h)
-- match -----------------------------------------------------------------------
local match_normal_h = H:new():fg(black_c):bg(orange_c)
local match_current_h = H:new():fg(black_c):bg(magenta_c)
local match_paren_h = H:new():fg(magenta_c):bg(orange_c)
set_hl("Search", match_normal_h)
set_hl("Substitute", match_normal_h)
set_hl("IncSearch", match_current_h)
set_hl("CurSearch", match_current_h)
set_hl("MatchParen", match_paren_h)
-- selection -------------------------------------------------------------------
local selection_normal_h = H:new():fg(black_c):bg(white_c)
set_hl("visual", selection_normal_h)
set_hl("visualnos", selection_normal_h)
-- diff ------------------------------------------------------------------------
local diff_add_h = H:new():fg(green_c)
local diff_change_h = H:new():fg(orange_c)
local diff_delete_h = H:new():fg(red_c)
local diff_text_h = H:new():fg(orange_c):attr("underline")
set_hl("DiffAdd", diff_add_h)
set_hl("DiffChange", diff_change_h)
set_hl("DiffDelete", diff_delete_h)
set_hl("DiffText", diff_text_h)
-- spell -----------------------------------------------------------------------
local spell_error_h = H:new():fg(red_c):attr("underline")
local spell_warn_h = H:new():fg(orange_c):attr("underline")
set_hl("SpellBad", spell_error_h)
set_hl("SpellCap", spell_warn_h)
set_hl("SpellLocal", spell_warn_h)
set_hl("SpellRare", spell_warn_h)
-- diagnostic ------------------------------------------------------------------
local diagnostic_error_h = H:new():fg(red_c)
local diagnostic_warn_h = H:new():fg(orange_c)
local diagnostic_info_h = H:new():fg(blue_c)
local diagnostic_hint_h = H:new():fg(white_c)
local diagnostic_ok_h = H:new():fg(green_c)
local diagnostic_error_u_h = H:new():fg(red_c):attr("underline")
local diagnostic_warn_u_h = H:new():fg(orange_c):attr("underline")
local diagnostic_info_u_h = H:new():fg(blue_c):attr("underline")
local diagnostic_hint_u_h = H:new():fg(white_c):attr("underline")
local diagnostic_ok_u_h = H:new():fg(green_c):attr("underline")
set_hl("DiagnosticError", diagnostic_error_h)
set_hl("DiagnosticWarn", diagnostic_warn_h)
set_hl("DiagnosticInfo", diagnostic_info_h)
set_hl("DiagnosticHint", diagnostic_hint_h)
set_hl("DiagnosticOk", diagnostic_ok_h)
set_hl("DiagnosticVirtualError", diagnostic_error_h)
set_hl("DiagnosticVirtualWarn", diagnostic_warn_h)
set_hl("DiagnosticVirtualInfo", diagnostic_info_h)
set_hl("DiagnosticVirtualHint", diagnostic_hint_h)
set_hl("DiagnosticVirtualOk", diagnostic_ok_h)
set_hl("DiagnosticUnderlineError", diagnostic_error_u_h)
set_hl("DiagnosticUnderlineWarn", diagnostic_warn_u_h)
set_hl("DiagnosticUnderlineInfo", diagnostic_info_u_h)
set_hl("DiagnosticUnderlineHint", diagnostic_hint_u_h)
set_hl("DiagnosticUnderlineOk", diagnostic_ok_u_h)
set_hl("DiagnosticFloatingError", diagnostic_error_h)
set_hl("DiagnosticFloatingWarn", diagnostic_warn_h)
set_hl("DiagnosticFloatingInfo", diagnostic_info_h)
set_hl("DiagnosticFloatingHint", diagnostic_hint_h)
set_hl("DiagnosticFloatingOk", diagnostic_ok_h)
set_hl("DiagnosticSingError", diagnostic_error_h)
set_hl("DiagnosticSingWarn", diagnostic_warn_h)
set_hl("DiagnosticSingInfo", diagnostic_info_h)
set_hl("DiagnosticSingHint", diagnostic_hint_h)
set_hl("DiagnosticSingOk", diagnostic_ok_h)
set_hl("DiagnosticDeprecated", diagnostic_hint_u_h)
set_hl("DiagnosticUnnecessary", diagnostic_hint_u_h)
-- misc ------------------------------------------------------------------------
set_hl("Directory", H:new():fg(blue_c):attr("bold"))
-- syntax ----------------------------------------------------------------------
local syntax_normal_h = {}
local syntax_comment_h = H:new():fg(blue_c):attr("bold")
local syntax_constant_h = H:new():fg(red_c)
local syntax_identifier_h = H:new()
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():fg(blue_c):attr("underline")
local syntax_ignore_h = H:new():fg(black_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("Constant", syntax_constant_h)
set_hl("String", syntax_constant_h)
set_hl("Character", syntax_constant_h)
set_hl("Number", syntax_constant_h)
set_hl("Boolean", syntax_constant_h)
set_hl("Float", syntax_constant_h)
set_hl("Identifier", syntax_identifier_h)
set_hl("Function", syntax_identifier_h)
set_hl("Statement", syntax_statement_h)
set_hl("Conditional", syntax_statement_h)
set_hl("Repeat", syntax_statement_h)
set_hl("Label", syntax_statement_h)
set_hl("Operator", syntax_statement_h)
set_hl("Keyword", syntax_statement_h)
set_hl("Exception", syntax_statement_h)
set_hl("PreProc", syntax_preproc_h)
set_hl("Include", syntax_preproc_h)
set_hl("Define", syntax_preproc_h)
set_hl("Macro", syntax_preproc_h)
set_hl("PreCondit", syntax_preproc_h)
set_hl("Type", syntax_type_h)
set_hl("StorageClass", syntax_type_h)
set_hl("Structure", syntax_type_h)
set_hl("Typedef", syntax_type_h)
set_hl("Special", syntax_special_h)
set_hl("SpecialChar", syntax_special_h)
set_hl("Tag", syntax_special_h)
set_hl("Delimiter", syntax_special_h)
set_hl("SpecialComment", syntax_special_h)
set_hl("Debug", syntax_special_h)
set_hl("Underlined", syntax_underline_h)
set_hl("Ignore", syntax_ignore_h)
set_hl("Error", syntax_error_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)
local markdown_underline_h = H:new():fg(blue_c):attr("underline")
set_hl("markdownLabel", markdown_label_h)
set_hl("markdownDelimiter", markdown_delimiter_h)
set_hl("markdownUnderlined", markdown_underline_h)

View File

@ -0,0 +1,177 @@
-- options ---------------------------------------------------------------------
-- colorscheme
vim.cmd.colorscheme("basic")
-- leader
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.keymap.set({ "n", "v" }, "<space>", "<nop>", { silent = true })
-- general
vim.opt.undofile = true
vim.opt.backup = false
vim.opt.writebackup = false
vim.opt.mouse = {}
vim.opt.title = true
-- appearance
vim.opt.shortmess:append({ I = true })
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.signcolumn = "number"
vim.opt.textwidth = 80
vim.opt.colorcolumn = "+1"
-- tabline, winbar, statusline
vim.opt.showtabline = 2
vim.opt.winbar = "%f%( %h%m%r%y%)"
vim.opt.laststatus = 3
function _G.statusline()
local col = vim.api.nvim_win_get_cursor(0)[2] + 1
local char = vim.api.nvim_get_current_line():sub(col, col):gsub("%%", "%%%1")
local wc = vim.fn.wordcount()
return table.concat({
vim.fn.pathshorten(vim.fn.getcwd()),
"%=",
"<", char, "> %b ",
wc.visual_chars or wc.cursor_chars, "/", wc.chars, " ",
wc.visual_words or wc.cursor_words, "/", wc.words
})
end
vim.opt.statusline = "%!v:lua.statusline()"
-- behaviour
vim.opt.ignorecase = true
vim.opt.infercase = true
vim.opt.smartcase = true
vim.opt.smartindent = true
vim.opt.clipboard = "unnamedplus"
vim.opt.whichwrap = {
["b"] = true,
["s"] = true,
["h"] = true,
["l"] = true,
["<"] = true,
[">"] = true,
["~"] = true,
["["] = true,
["]"] = true
}
vim.opt.wildoptions = { "fuzzy" }
vim.opt.wildignorecase = true
-- path
vim.opt.path = ".,,**"
-- local root = vim.fs.find({ ".git" }, { upward = true })[1]
-- completion
vim.opt.completeopt = {
"menuone",
"preview",
"noinsert",
"noselect"
}
-- keymaps ---------------------------------------------------------------------
-- clear hlsearch
vim.keymap.set( "n", "<esc>", function()
vim.cmd.nohlsearch()
end, { desc = "Stop the highlighting for the 'hlsearch' option" })
-- move cursor with alt in c-mode
vim.keymap.set("c", "<m-h>", "<left>", { desc = "Left" })
vim.keymap.set("c", "<m-l>", "<right>", { desc = "Right" })
-- move cursor with alt in i-mode
vim.keymap.set("i", "<m-h>", "<left>", { desc = "Left" })
vim.keymap.set("i", "<m-j>", "<down>", { desc = "Down" })
vim.keymap.set("i", "<m-k>", "<up>", { desc = "Up" })
vim.keymap.set("i", "<m-l>", "<right>", { desc = "Right" })
-- move cursor with alt in t-mode
vim.keymap.set("t", "<m-h>", "<left>", { desc = "Left" })
vim.keymap.set("t", "<m-j>", "<down>", { desc = "Down" })
vim.keymap.set("t", "<m-k>", "<up>", { desc = "Up" })
vim.keymap.set("t", "<m-l>", "<right>", { desc = "Right" })
-- navigate windows
vim.keymap.set("n", "<c-h>", "<c-w>h", { desc = "Navigate window left"})
vim.keymap.set("n", "<c-j>", "<c-w>j", { desc = "Navigate window down"})
vim.keymap.set("n", "<c-k>", "<c-w>k", { desc = "Navigate window up"})
vim.keymap.set("n", "<c-l>", "<c-w>l", { desc = "Navigate window right"})
vim.keymap.set("i", "<c-h>", "<c-\\><c-n><c-w>h", { desc = "Navigate window left"})
vim.keymap.set("i", "<c-j>", "<c-\\><c-n><c-w>j", { desc = "Navigate window down"})
vim.keymap.set("i", "<c-k>", "<c-\\><c-n><c-w>k", { desc = "Navigate window up"})
vim.keymap.set("i", "<c-l>", "<c-\\><c-n><c-w>l", { desc = "Navigate window right"})
vim.keymap.set("t", "<c-h>", "<c-\\><c-n><c-w>h", { desc = "Navigate window left"})
vim.keymap.set("t", "<c-j>", "<c-\\><c-n><c-w>j", { desc = "Navigate window down"})
vim.keymap.set("t", "<c-k>", "<c-\\><c-n><c-w>k", { desc = "Navigate window up"})
vim.keymap.set("t", "<c-l>", "<c-\\><c-n><c-w>l", { desc = "Navigate window right"})
-- navigate buffer
vim.keymap.set("n", "<c-d>", "<c-d>zz")
vim.keymap.set("n", "<c-u>", "<c-u>zz")
-- cmdline history navigation
vim.keymap.set("c", "<c-p>", "<up>")
vim.keymap.set("c", "<c-n>", "<down>")
-- menus
vim.keymap.set("n", "<leader>f", ":find ", { desc = ":find" })
vim.keymap.set("n", "<leader>b", ":buffer ", { desc = ":buffer" })
vim.keymap.set("n", "<leader>h", ":help ", { desc = ":help" })
-- spell
vim.keymap.set("n", "<leader>s", function()
vim.opt_local.spell = not(vim.opt_local.spell:get())
end, { desc = "Toggle spell" })
-- make
vim.keymap.set("n", "<leader>m", "<cmd>make<cr>", { desc = ":make" })
-- buffers ---------------------------------------------------------------------
vim.keymap.set("n", "]b", "<cmd>bnext<cr>", { desc = "Next buffer" })
vim.keymap.set("n", "[b", "<cmd>bprev<cr>", { desc = "Previous buffer" })
vim.keymap.set("n", "<leader>d", "<cmd>enew<cr><cmd>bd #<cr>", { desc = "Delete buffer" })
vim.keymap.set("n", "<leader>D", "<cmd>bd<cr>", { desc = "Delete buffer and close window" })
-- tabs ------------------------------------------------------------------------
vim.keymap.set("n", "]t", "<cmd>tabnext<cr>", { desc = "Next tab" })
vim.keymap.set("n", "[t", "<cmd>tabprevious<cr>", { desc = "Previous tab" })
-- vimgrep ---------------------------------------------------------------------
vim.keymap.set("n", "<leader>g", ":vimgrep / **/*<c-left><c-left>/")
local vimgrep_group = vim.api.nvim_create_augroup("Vimgrep", {})
vim.api.nvim_create_autocmd("QuickfixCmdPost", {
group = vimgrep_group,
pattern = "vimgrep",
desc = "Open quickfix window after :vimgrep",
command = "copen"
})
-- quickfix --------------------------------------------------------------------
vim.keymap.set("n", "co", "<cmd>copen<cr>", { desc = "Open quickfix window" })
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>cprev<cr>zz", { desc = "Previous quickfix item" })
-- netrw -----------------------------------------------------------------------
vim.g.netrw_use_errorwindow = 0
vim.g.netrw_banner = 0
vim.g.netrw_bufsettings = "noma nomod nowrap ro nobl"
vim.g.netrw_fastbrowse = 0
vim.keymap.set("n", "<leader>.", "<cmd>Explore .<cr>",
{ desc = "Explore current working directory" })
local netrw_group = vim.api.nvim_create_augroup("Netrw", {})
vim.api.nvim_create_autocmd("Filetype", {
group = netrw_group,
pattern = "netrw",
desc = "Set keymap netrw buffers",
callback = function()
vim.keymap.set("n", "<esc>", "<cmd>Rexplore<cr>",
{ buffer = true, desc = "Return to/from Explorer" })
end
})

View File

@ -0,0 +1 @@
gl

Binary file not shown.

View File

@ -0,0 +1,276 @@
" 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*>\)\+/ containedin=markdownItalic,markdownBold,markdownPCite,markdownSuperscript,markdownSubscript,markdownStrike,markdownUListItem,markdownNoFormatted
hi def link markdownBlockquote 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
" strikeout
syn region markdownStrike start=/\~\~/ end=/\~\~/ contains=markdownStrikeout,@Spell keepend
hi def link markdownStrike htmlStrike
syn match markdownStrikeDelimiter /\~\~/ contained
hi def link markdownStrikeDelimiter markdownDelimiter
" subscript
syn region markdownSubscript start=/\~\(\([[:graph:]]\(\\ \)\=\)\{-}\~\)\@=/ end=/\~/ contains=markdownSubscriptDelimiter keepend
syn match markdownSubscriptDelimiter /\~/ contained
hi def link markdownSubscriptDelimiter markdownDelimiter
" superscript
syn region markdownSuperscript start=/\^\(\([[:graph:]]\(\\ \)\=\)\{-}\^\)\@=/ skip=/\\ / end=/\^/ contains=markdownSuperscriptDelimiter keepend
syn match markdownSuperscriptDelimiter /\^/ contained
hi def link markdownSuperscriptDelimiter markdownDelimiter
" heading
syn match markdownAtxHeading /\(\%^\|<.\+>.*\n\|^\s*\n\)\@<=#\{1,6}.*\n/ contains=markdownItalic,markdownBold,markdownNoFormatted,markdownLaTeXInlineMath,markdownEscapedDollar,@Spell,markdownAmpersandEscape,markdownLink 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=markdownLink,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=markdownLink,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,markdownLink,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: