From 4982ececf730da0f6cc61eebb4ec252abed06027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=C3=BAc=20L=C3=AA=20Kh=E1=BA=AFc?= Date: Sun, 16 Jul 2023 16:54:09 +0200 Subject: [PATCH] feat(python): add semantic highlighting --- .../extras/lang/python/semantic-highlight.lua | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/lang/python/semantic-highlight.lua diff --git a/lua/lazyvim/plugins/extras/lang/python/semantic-highlight.lua b/lua/lazyvim/plugins/extras/lang/python/semantic-highlight.lua new file mode 100644 index 00000000..ad3b7cff --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/python/semantic-highlight.lua @@ -0,0 +1,34 @@ +-- NOTE: You might need to open a Python file, then manually run `:UpdateRemotePlugins` +-- since the build command might be run when semshi has not been loaded due to lazyness +return { + -- "numiras/semshi", + "wookayin/semshi", -- use a maintained fork + ft = "python", + build = ":UpdateRemotePlugins", + init = function() + -- Disabled these features better provided by LSP or other more general plugins + vim.g["semshi#error_sign"] = false + vim.g["semshi#simplify_markup"] = false + vim.g["semshi#mark_selected_nodes"] = false + vim.g["semshi#update_delay_factor"] = 0.001 + + -- This autocmd must be defined in init to take effect + vim.api.nvim_create_autocmd({ "VimEnter", "ColorScheme" }, + { + group = vim.api.nvim_create_augroup("SemanticHighlight", {}), + callback = function() + -- Only add style, inherit or link to the LSP's colors + vim.cmd [[ + highlight! semshiGlobal gui=italic + highlight! semshiImported gui=bold + highlight! link semshiParameter @lsp.type.parameter + highlight! link semshiParameterUnused DiagnosticUnnecessary + highlight! link semshiBuiltin @function.builtin + highlight! link semshiAttribute @attribute + highlight! link semshiSelf @lsp.type.selfKeyword + highlight! link semshiUnresolved @lsp.type.unresolvedReference + ]] + end + }) + end, +}