Skip to content

Instantly share code, notes, and snippets.

@VonHeikemen
Last active October 25, 2025 12:41
Show Gist options
  • Save VonHeikemen/50b3212e32e5d08387ac7803534fe577 to your computer and use it in GitHub Desktop.
Save VonHeikemen/50b3212e32e5d08387ac7803534fe577 to your computer and use it in GitHub Desktop.
-- Lua config from this blog post:
-- https://vonheikemen.github.io/devlog/tools/simple-neovim-config/
-- Dependencies:
-- https://github.com/neovim/nvim-lspconfig
-- https://github.com/echasnovski/mini.nvim
vim.o.number = true
vim.o.tabstop = 2
vim.o.shiftwidth = 2
vim.o.smartcase = true
vim.o.ignorecase = true
vim.o.wrap = false
vim.o.hlsearch = false
vim.o.signcolumn = 'yes'
-- Space as the leader key
vim.g.mapleader = ' '
-- Basic clipboard interaction
vim.keymap.set({'n', 'x'}, 'gy', '"+y', {desc = 'Copy to clipboard'})
vim.keymap.set({'n', 'x'}, 'gp', '"+p', {desc = 'Paste clipboard text'})
-- Command shortcuts
vim.keymap.set('n', '<leader>w', '<cmd>write<cr>', {desc = 'Save file'})
vim.keymap.set('n', '<leader>q', '<cmd>quitall<cr>', {desc = 'Exit vim'})
local ok_theme = pcall(vim.cmd.colorscheme, 'retrobox')
if not ok_theme then
vim.cmd.colorscheme('habamax')
end
require('mini.snippets').setup({})
require('mini.completion').setup({})
require('mini.files').setup({})
vim.keymap.set('n', '<leader>e', '<cmd>lua MiniFiles.open()<cr>', {desc = 'File explorer'})
require('mini.pick').setup({})
vim.keymap.set('n', '<leader><space>', '<cmd>Pick buffers<cr>', {desc = 'Search open files'})
vim.keymap.set('n', '<leader>ff', '<cmd>Pick files<cr>', {desc = 'Search all files'})
vim.keymap.set('n', '<leader>fh', '<cmd>Pick help<cr>', {desc = 'Search help tags'})
-- Displays a function's signature information
vim.keymap.set('i', '<C-s>', '<cmd>lua vim.lsp.buf.signature_help()<cr>')
-- Lists all symbols in the current buffer
vim.keymap.set('n', 'gO', '<cmd>lua vim.lsp.buf.document_symbol()<cr>')
-- Lists all the implementations for the symbol under the cursor
vim.keymap.set('n', 'gri', '<cmd>lua vim.lsp.buf.implementation()<cr>')
-- Jumps to the definition of the type symbol
vim.keymap.set('n', 'grt', '<cmd>lua vim.lsp.buf.type_definition()<cr>')
-- Lists all the references
vim.keymap.set('n', 'grr', '<cmd>lua vim.lsp.buf.references()<cr>')
-- Renames all references to the symbol under the cursor
vim.keymap.set('n', 'grn', '<cmd>lua vim.lsp.buf.rename()<cr>')
-- Selects a code action available at the current cursor position
vim.keymap.set('n', 'gra', '<cmd>lua vim.lsp.buf.code_action()<cr>')
-- Show diagnostics in a floating window
vim.keymap.set('n', '<C-w>d', '<cmd>lua vim.diagnostic.open_float()<cr>')
vim.keymap.set('n', '<C-w><C-d>', '<cmd>lua vim.diagnostic.open_float()<cr>')
if vim.fn.has('nvim-0.11') == 0 then
-- Jump next/previous diagnostic in the current buffer
vim.keymap.set('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
vim.keymap.set('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
end
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(event)
-- NOTE: By default `K` uses the program specified in the 'keywordprg' option.
-- Here we override the default behavior, we force it to use the LSP client
-- Display documentation of the symbol under the cursor
vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', {buffer = event.buf})
end,
})
-- This function will use the "legacy setup" on older Neovim version.
-- The new api is only available on Neovim v0.11 or greater.
local function lsp_setup(server, opts)
if vim.fn.has('nvim-0.11') == 0 then
require('lspconfig')[server].setup(opts)
return
end
if not vim.tbl_isempty(opts) then
vim.lsp.config(server, opts)
end
vim.lsp.enable(server)
end
-- List of compatible language servers is here:
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md
lsp_setup('gopls', {})
lsp_setup('rust_analyzer', {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment