diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-03-06 20:04:03 -0800 |
---|---|---|
committer | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-03-09 21:15:10 -0800 |
commit | d49177afd9806f651c0177f9cc68c5a22dba2938 (patch) | |
tree | d75d6c12479f2275b644dcfea68681eb86b44eb9 | |
parent | 0496b572ac8fb0e157f97f02d692aaa9055f6c1e (diff) | |
download | rneovim-d49177afd9806f651c0177f9cc68c5a22dba2938.tar.gz rneovim-d49177afd9806f651c0177f9cc68c5a22dba2938.tar.bz2 rneovim-d49177afd9806f651c0177f9cc68c5a22dba2938.zip |
lsp: add custom syntax rules for lsp floating window
-rw-r--r-- | runtime/ftplugin/lsp_markdown.vim | 11 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 5 | ||||
-rw-r--r-- | runtime/syntax/lsp_markdown.vim | 16 |
3 files changed, 31 insertions, 1 deletions
diff --git a/runtime/ftplugin/lsp_markdown.vim b/runtime/ftplugin/lsp_markdown.vim new file mode 100644 index 0000000000..d3244fc955 --- /dev/null +++ b/runtime/ftplugin/lsp_markdown.vim @@ -0,0 +1,11 @@ +" Vim filetype plugin +" Language: lsp_markdown +" Maintainer: Michael Lingelbach <m.j.lbach@gmail.com> +" Last Change: 2021 Mar 09 + +if exists("b:did_ftplugin") + finish +endif + +runtime! ftplugin/markdown.vim +" vim:set sw=2: diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 6fb9f09c99..e611ad3220 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -873,8 +873,11 @@ function M.fancy_floating_markdown(contents, opts) -- This is because the syntax command doesn't accept a target. local cwin = vim.api.nvim_get_current_win() vim.api.nvim_set_current_win(winnr) + api.nvim_win_set_option(winnr, 'conceallevel', 2) + api.nvim_win_set_option(winnr, 'concealcursor', 'n') - vim.cmd("ownsyntax markdown") + vim.cmd("ownsyntax lsp_markdown") + vim.cmd("set filetype=lsp_markdown") local idx = 1 --@private local function apply_syntax_to_region(ft, start, finish) diff --git a/runtime/syntax/lsp_markdown.vim b/runtime/syntax/lsp_markdown.vim new file mode 100644 index 0000000000..23658a9db6 --- /dev/null +++ b/runtime/syntax/lsp_markdown.vim @@ -0,0 +1,16 @@ +" Vim syntax file +" Language: lsp_markdown +" Maintainer: Michael Lingelbach <m.j.lbach@gmail.com +" URL: http://neovim.io +" Remark: Uses markdown syntax file + +runtime! syntax/markdown.vim + +syn cluster mkdNonListItem add=mkdEscape,mkdNbsp +syntax region mkdNonListItemBlock start=/\(\%^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@!\|\n\(\_^\_$\|\s\{4,}[^]\|\t+[^\t]\)\@!\)/ end=/^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@=/ contains=@mkdNonListItem + +syntax region mkdEscape matchgroup=mkdEscape start=/\\\ze[\\\x60*{}\[\]()#+\-,.!_>~|"$%&'\/:;<=?@^ ]/ end=/.\zs/ keepend contains=mkdEscapeCh contained oneline concealends +syntax match mkdEscapeCh /./ contained +syntax match mkdNbsp / / conceal cchar= + +hi def link mkdEscape special |