Last active
April 17, 2025 01:36
-
-
Save VonHeikemen/50b3212e32e5d08387ac7803534fe577 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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'}) | |
-- List of compatible language servers is here: | |
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md | |
require('lspconfig').gopls.setup({}) | |
require('lspconfig').rust_analyzer.setup({}) | |
vim.api.nvim_create_autocmd('LspAttach', { | |
desc = 'LSP actions', | |
callback = function(event) | |
local opts = {buffer = event.buf} | |
-- Display documentation of the symbol under the cursor | |
vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts) | |
-- Jump to the definition | |
vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts) | |
-- Format current file | |
vim.keymap.set({'n', 'x'}, 'gq', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts) | |
-- Displays a function's signature information | |
vim.keymap.set('i', '<C-s>', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts) | |
-- Jump to declaration | |
vim.keymap.set('n', '<leader>ld', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts) | |
-- Lists all the implementations for the symbol under the cursor | |
vim.keymap.set('n', '<leader>li', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts) | |
-- Jumps to the definition of the type symbol | |
vim.keymap.set('n', '<leader>lt', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts) | |
-- Lists all the references | |
vim.keymap.set('n', '<leader>lr', '<cmd>lua vim.lsp.buf.references()<cr>', opts) | |
-- Renames all references to the symbol under the cursor | |
vim.keymap.set('n', '<leader>ln', '<cmd>lua vim.lsp.buf.rename()<cr>', opts) | |
-- Selects a code action available at the current cursor position | |
vim.keymap.set('n', '<leader>la', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts) | |
end, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment