From d49177afd9806f651c0177f9cc68c5a22dba2938 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Sat, 6 Mar 2021 20:04:03 -0800 Subject: [PATCH] lsp: add custom syntax rules for lsp floating window --- runtime/ftplugin/lsp_markdown.vim | 11 +++++++++++ runtime/lua/vim/lsp/util.lua | 5 ++++- runtime/syntax/lsp_markdown.vim | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 runtime/ftplugin/lsp_markdown.vim create mode 100644 runtime/syntax/lsp_markdown.vim 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 +" 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 ~|"$%&'\/:;<=?@^ ]/ end=/.\zs/ keepend contains=mkdEscapeCh contained oneline concealends +syntax match mkdEscapeCh /./ contained +syntax match mkdNbsp / / conceal cchar= + +hi def link mkdEscape special