This commit is contained in:
Dane Sabo 2025-02-19 20:13:14 -05:00
parent a370342a04
commit 7db92a3485
7 changed files with 66 additions and 5 deletions

View File

@ -1,7 +1,7 @@
---@type ChadrcConfig
local M = {}
M.ui = { theme = 'melange' }
M.ui = { theme = 'oceanic-light' }
M.plugins = 'custom.plugins'
M.mappings = require "custom.mappings"
return M

View File

@ -2,7 +2,7 @@ local config = require("plugins.configs.lspconfig")
local on_attach = function(client, bufnr)
config.on_attach(client, bufnr)
-- Keybinding to show hover documentation
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>h', '<cmd>lua vim.lsp.buf.hover()<CR>', { noremap = true, silent = true })
@ -19,7 +19,7 @@ local lspconfig = require("lspconfig")
local servers = {
"pyright",
"ruff_lsp",
"ruff_lsp"
}
for _, lsp in ipairs(servers) do
@ -38,6 +38,20 @@ for _, lsp in ipairs(servers) do
})
end
lspconfig.hls.setup{
on_attach = on_attach,
capabilities = capabilities,
filetypes = {'haskell', 'lhaskell', 'cabal'}
}
lspconfig.matlab_ls.setup{
on_attach = on_attach,
capabilities = capabilities,
filetypes = {'matlab'}
}
-- Function to show diagnostics on hover
vim.api.nvim_create_autocmd("CursorHold", {
callback = function()

View File

@ -1,2 +1,2 @@
vim.g.dap_virtual_text = false
vim.env.PATH = vim.env.PATH .. ":/home/danesabo/.ghcup/bin"

View File

@ -0,0 +1,43 @@
-- Global variables to store the MATLAB terminal buffer and job ID
local matlab_term_buf = nil
local matlab_term_job = nil
-- Create the "RunMatlab" user command
vim.api.nvim_create_user_command("RunMatlab", function()
-- Get the absolute path of the current file
local file = vim.fn.expand("%:p")
-- Escape single quotes by doubling them for MATLAB's string literal.
local matlab_file = file:gsub("'", "''")
-- Construct the command to run MATLAB in batch mode, executing the current file.
local cmd = 'matlab -batch "run(\'' .. matlab_file .. '\')"'
-- If we already have a MATLAB terminal and it's valid, reuse it.
if matlab_term_buf and vim.api.nvim_buf_is_valid(matlab_term_buf) and matlab_term_job then
-- Check if the terminal buffer is visible in any window.
local wins = vim.fn.win_findbuf(matlab_term_buf)
if #wins == 0 then
-- If not visible, open it in a vertical split.
vim.cmd("split")
vim.cmd("buffer " .. matlab_term_buf)
else
-- Otherwise, switch focus to that window.
vim.api.nvim_set_current_win(wins[1])
end
-- Send the MATLAB command to the terminal. (You can add a clear command here if desired.)
vim.api.nvim_chan_send(matlab_term_job, cmd .. "\n")
else
-- If the MATLAB terminal doesn't exist, open a new vertical split terminal.
vim.cmd("split")
vim.cmd("terminal")
-- Store the terminal buffer and job ID for future reuse.
matlab_term_buf = vim.api.nvim_get_current_buf()
matlab_term_job = vim.b.terminal_job_id
-- Optionally, rename the terminal buffer for clarity.
vim.api.nvim_buf_set_name(matlab_term_buf, "MATLAB Output")
-- Send the MATLAB command to run the current file.
vim.api.nvim_chan_send(matlab_term_job, cmd .. "\n")
end
end, {})
-- Map <space>+r+m (i.e. <leader>rm) to run the MATLAB code
vim.keymap.set("n", "<leader>rm", ":RunMatlab<CR>", { noremap = true, silent = true })

View File

@ -27,4 +27,6 @@ M.crates = {
}
}
require("custom.language_specific_commands.matlab")
return M

View File

@ -6,6 +6,8 @@ local plugins = {
opts = {
ensure_installed = {
"rust-analyzer",
"haskell-language-server",
"matlab-language-server",
},
},
},

View File

@ -1,5 +1,5 @@
local options = {
ensure_installed = { "lua", "vim", "vimdoc","c","rust"},
ensure_installed = { "lua", "vim", "vimdoc","c","rust","haskell", "matlab", "tlaplus"},
highlight = {
enable = true,