From 12262491a41a320188d9958e631f9f66b59c633f Mon Sep 17 00:00:00 2001 From: mint Date: Sun, 21 Dec 2025 11:30:06 +0800 Subject: [PATCH] feat(extras): added matlab support --- lua/lazyvim/plugins/extras/lang/matlab.lua | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/lang/matlab.lua diff --git a/lua/lazyvim/plugins/extras/lang/matlab.lua b/lua/lazyvim/plugins/extras/lang/matlab.lua new file mode 100644 index 00000000..a15d175f --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/matlab.lua @@ -0,0 +1,71 @@ +if lazyvim_docs then + -- Formatter to use for MATLAB. + -- Set to "miss_hit" to use mh_style instead of matlab_ls. + vim.g.lazyvim_matlab_formatter = "lsp" +end + +local formatter = vim.g.lazyvim_matlab_formatter or "lsp" + +return { + recommended = function() + return LazyVim.extras.wants({ + ft = "matlab", + root = { "*.prj" }, + }) + end, + { + "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "matlab" } }, + }, + { + "mason-org/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "matlab_language_server" }) + if formatter == "miss_hit" then + vim.list_extend(opts.ensure_installed, { "miss_hit" }) + end + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + matlab_ls = {}, + }, + }, + }, + -- tmux required + { + "idossha/matlab.nvim", + ft = "matlab", + opts = { + auto_start = false, + default_mappings = true, + mappings = { + prefix = "m", + }, + }, + }, + -- `mh_style` from `miss_hit` + { + "stevearc/conform.nvim", + optional = true, + opts = function(_, opts) + if formatter == "miss_hit" then + opts.formatters_by_ft = opts.formatters_by_ft or {} + opts.formatters_by_ft.matlab = { "mh_style" } + end + end, + }, + { + "folke/which-key.nvim", + optional = true, + opts = { + spec = { + { "m", group = "MATLAB", icon = { icon = "" } }, + { "md", group = "debug" }, + }, + }, + }, +}