Skip to content

Instantly share code, notes, and snippets.

@td0m
Created January 12, 2026 10:59
Show Gist options
  • Select an option

  • Save td0m/98d20092d45e5bd54856b55695ade0a5 to your computer and use it in GitHub Desktop.

Select an option

Save td0m/98d20092d45e5bd54856b55695ade0a5 to your computer and use it in GitHub Desktop.
mvim - mini neovim config
-- minimal vim
-- ___ ____ _____ ___ ___ _ _ ____
-- / _ \| _ \_ _|_ _/ _ \| \ | / ___|
-- | | | | |_) || | | | | | | \| \___ \
-- | |_| | __/ | | | | |_| | |\ |___) |
-- \___/|_| |_| |___\___/|_| \_|____/
-- need the leader to be space
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- minimalism
vim.o.laststatus = 0
vim.o.cmdheight = 1 -- tried at zero but handy when typing numbers e.g. 80G in insert mode
vim.opt.list = false
vim.opt.listchars = { space = "", tab = "" }
-- behaviour i like
vim.o.splitright = true
vim.o.splitbelow = true
vim.o.undofile = true
vim.o.wrap = false
vim.o.tabstop = 2 -- how wide the tab is
vim.o.shiftwidth = 2 -- how much to shift by when tab pressed
vim.o.expandtab = true -- spaces by default
vim.o.foldlevelstart = 99 -- disable folds
vim.opt.isfname:append("32") -- need for 'gf' to work with files that contain spaces (ASCII 32)
-- some shell stuff, huh???
vim.g.shell = "/bin/zsh"
vim.o.termguicolors = true -- setting this explicitly as otherwise opening a neovim tab in tmux via send-keys
-- local init.lua! for more: `:h exrc`
vim.o.exrc = true
vim.o.secure = true
-- _____ _ _ _ _ ____ _____ ___ ___ _ _ ____
-- | ___| | | | \ | |/ ___|_ _|_ _/ _ \| \ | / ___|
-- | |_ | | | | \| | | | | | | | | | \| \___ \
-- | _| | |_| | |\ | |___ | | | | |_| | |\ |___) |
-- |_| \___/|_| \_|\____| |_| |___\___/|_| \_|____/
-- save if not exists
function save_if_not_exists()
local path = vim.fn.expand("%:p:h") -- Get the directory of the current file
if vim.fn.isdirectory(path) == 0 then
vim.fn.mkdir(path, "p") -- Create the directory if it doesn't exist
end
vim.cmd("write") -- Save the file
end
function exec_to_buffer()
vim.ui.input({ prompt = "$ " }, function(c)
if not c or c == "" then
return
end
c = vim.fn.expandcmd(c)
vim.cmd("noswapfile vnew")
vim.bo.buftype = "nofile"
vim.bo.bufhidden = "wipe"
vim.api.nvim_buf_set_lines(0, 0, -1, false, vim.fn.systemlist(c))
end)
end
-- _ _________ ______ ___ _ _ ____ ___ _ _ ____ ____
-- | |/ / ____\ \ / / __ )_ _| \ | | _ \_ _| \ | |/ ___/ ___|
-- | ' /| _| \ V /| _ \| || \| | | | | || \| | | _\___ \
-- | . \| |___ | | | |_) | || |\ | |_| | || |\ | |_| |___) |
-- |_|\_\_____| |_| |____/___|_| \_|____/___|_| \_|\____|____/
-- more convenient clipboard!
vim.keymap.set({ "n", "v" }, "<leader>c", '"+', { silent = true })
-- backspace to go to "last" file
vim.keymap.set("n", "<BS>", ":b#<CR>", { silent = true })
-- copying keeps selection
vim.keymap.set("n", "gy", "`[v`]", { silent = true })
vim.keymap.set("n", "gp", "`[v`]", { silent = true })
-- convenient selection
vim.keymap.set({ "n", "v" }, "<leader>y", [["+y]])
vim.keymap.set({ "n", "v" }, "<leader>p", [["+p]])
-- quickfix list
vim.keymap.set("n", "]c", ":cn<CR>", { silent = true })
vim.keymap.set("n", "[c", ":cp<CR>", { silent = true })
vim.keymap.set("n", "<leader>q", ":copen<CR>", { silent = true })
-- escape in the terminal
vim.keymap.set("t", "<ESC>", [[<C-\><C-n>]])
-- insert on terminal open
vim.api.nvim_create_autocmd({ "TermOpen" }, {
callback = function()
vim.cmd([[startinsert]])
end,
})
-- lets you execute any command and get the output in a tmp buffer
vim.keymap.set("n", "<leader>c", exec_to_buffer)
vim.api.nvim_create_user_command("W", save_if_not_exists, { nargs = 0 })
-- LSP
-- vim.keymap.set("n", "gd", require("dom.go_to_definition"))
vim.keymap.set("n", "gr", vim.lsp.buf.references)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename)
vim.keymap.set("n", "<leader>a", vim.lsp.buf.code_action)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
vim.keymap.set("n", "K", vim.lsp.buf.hover)
-- quick open
vim.keymap.set("n", "<leader>o", [[:!open "%"<CR>]], { silent = true, desc = "Open file in default app" })
-- vim.keymap.set("n", "<leader>ov", ":e .nvim.lua<CR>", { silent = true, desc = "Open neoVim config" })
-- vim.keymap.set("n", "<leader>ot", ":e .dt/tasks<CR>", { silent = true, desc = "Open tasks" })
-- vim.keymap.set("n", "<leader>op", ":e .dt/playbook.md<CR>", { silent = true, desc = "Open Playbook" })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment