]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/vim-lsp/syntax/lsp-hover.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / vim-lsp / syntax / lsp-hover.vim
diff --git a/.vim/bundle/vim-lsp/syntax/lsp-hover.vim b/.vim/bundle/vim-lsp/syntax/lsp-hover.vim
new file mode 100644 (file)
index 0000000..22d3e9f
--- /dev/null
@@ -0,0 +1,50 @@
+" Converts a markdown language (```foo) to the corresponding Vim filetype
+function! s:get_vim_filetype(lang_markdown) abort
+    " If the user hasn't customised markdown fenced languages, just return the
+    " markdown language
+    if !exists('g:markdown_fenced_languages')
+        return a:lang_markdown
+    endif
+
+    " Otherwise, check if it has an entry for the given language
+    for l:type in g:markdown_fenced_languages
+        let l:vim_type = substitute(matchstr(l:type, '[^=]*$'), '\..*', '', '')
+        let l:markdown_type = matchstr(l:type, '[^=]*')
+
+        if l:markdown_type ==# a:lang_markdown
+            " Found entry
+            return l:vim_type
+        endif
+    endfor
+
+    " Not found
+    return a:lang_markdown
+endfunction
+
+function! s:do_highlight() abort
+    if exists('b:lsp_syntax_highlights')
+        for l:entry in b:lsp_syntax_highlights
+            let l:line = l:entry['line']
+            let l:lang = l:entry['language']
+            let l:ft = s:get_vim_filetype(l:lang)
+
+            execute printf('syntax match markdownHighlight%s contains=@markdownHighlight%s /^\%%%sl.*$/', l:ft, l:ft, l:line)
+        endfor
+    endif
+endfunction
+
+function! s:cleanup_markdown() abort
+    " Don't highlight _ in words
+    syntax match markdownError "\w\@<=\w\@="
+
+    " Conceal escaped characters
+    " Workaround for: https://github.com/palantir/python-language-server/issues/386
+    if has('conceal')
+        for l:escaped_char in ['`', '*', '_', '{', '}', '(', ')', '<', '>', '#', '+', '.', '!', '-']
+            execute printf('syntax region vimLspMarkdownEscape matchgroup=Conceal start="\\\ze[%s]" end="[%s]\zs" concealends', l:escaped_char, l:escaped_char)
+        endfor
+    end
+endfunction
+
+call s:do_highlight()
+call s:cleanup_markdown()