Something went wrong. Try again.
Vim/Neovim configurations just for me
neovim
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071local M = {}
local config_dir = vim.fn.stdpath("config")
function M.install() local res = vim.system({ "mise", "install" }, { cwd = config_dir }):wait() assert(res.code == 0, res.stderr) M.assume_installed()end
---@type {--- env: vim.SystemObj,---}?local children
function M.assume_installed() if children then return children end local opts = { cwd = config_dir } children = { env = vim.system({ "mise", "env", "--json" }, opts), } return childrenend
do local called = false function M.set_env() if called then return end called = true local res = M.assume_installed().env:wait() assert(res.code == 0, res.stderr) local out = vim.json.decode(res.stdout) ---@type table<string, string> for key, value in pairs(out) do assert(vim.uv.os_setenv(key, value)) end endend
function M.override_language_servers() local stub_files = vim.fs.find(function(name) return name:match(".*%.toml$") ~= nil end, { path = vim.fs.joinpath(config_dir, "mise", "stubs", "lsp"), limit = math.huge, })
for _, file_path in ipairs(stub_files) do local ls_name = vim.fs.basename(file_path):gsub("%.toml$", "") local cmd = vim.lsp.config[ls_name].cmd if type(cmd) == "table" then local new_cmd = { "mise", "tool-stub", file_path } for i = 2, #cmd do table.insert(new_cmd, cmd[i]) end vim.lsp.config(ls_name, { cmd = new_cmd, }) elseif ls_name == "tsgo" then vim.lsp.config("tsgo", { cmd = { "mise", "tool-stub", file_path, "--lsp", "--stdio" }, }) end endend
return M