Skip to content

Instantly share code, notes, and snippets.

@VonHeikemen
Last active July 21, 2025 01:30
Show Gist options
  • Save VonHeikemen/559ff3adac787e011f035afd38a4f9f5 to your computer and use it in GitHub Desktop.
Save VonHeikemen/559ff3adac787e011f035afd38a4f9f5 to your computer and use it in GitHub Desktop.
simple neovim config written in vimscript
" vimscript version of the config in this blog post:
" https://vonheikemen.github.io/devlog/tools/simple-neovim-config/
set number
set tabstop=2
set shiftwidth=2
set smartcase
set ignorecase
set nowrap
set nohlsearch
set signcolumn=yes
" Space as the leader key
let g:mapleader = ' '
" Basic clipboard interaction
nnoremap gy "+y
xnoremap gy "+y
nnoremap gp "+p
xnoremap gp "+p
" Command shortcuts
nnoremap <leader>w <cmd>write<cr>
nnoremap <leader>q <cmd>quitall<cr>
try
colorscheme retrobox
catch
colorscheme habamax
endtry
" Setup autocompletion module
" NOTE: the lua command only works for single line lua expresions
lua require('mini.completion').setup({})
" Setup file explorer
lua require('mini.files').setup({})
nnoremap <leader>e <cmd>lua Minifiles.open()<cr>
" Setup fuzzy finders
lua require('mini.pick').setup({})
nnoremap <leader><space> <cmd>Pick buffers<cr>
nnoremap <leader>ff <cmd>Pick files<cr>
nnoremap <leader>fh <cmd>Pick help<cr>
" This function will use the "legacy setup" on older Neovim version.
" The new api is only available on Neovim v0.11 or greater.
function! LspSetup(server, opts) abort
if has('nvim-0.11')
if len(a:opts)
call luaeval('vim.lsp.config(_A[1], _A[2])', [a:server, a:opts])
endif
call luaeval('vim.lsp.enable(_A[1])', [a:server])
else
call luaeval('require("lspconfig")[_A[1]].setup(_A[2])', [a:server, a:opts])
endif
endfunction
call LspSetup('gopls', {})
call LspSetup('rust_analyzer', {})
function! LspAttached() abort
" Display documentation of the symbol under the cursor
nnoremap <buffer> K <cmd>lua vim.lsp.buf.hover()<cr>
" Jump to the definition
nnoremap <buffer> gd <cmd>lua vim.lsp.buf.definition()<cr>
" Format current file
nnoremap <buffer> gq <cmd>lua vim.lsp.buf.format({async = true})<cr>
xnoremap <buffer> gq <cmd>lua vim.lsp.buf.format({async = true})<cr>
" Displays a function's signature information
nnoremap <buffer> <C-s> <cmd>lua vim.lsp.buf.signature_help()<cr>
inoremap <buffer> <C-s> <cmd>lua vim.lsp.buf.signature_help()<cr>
" Jump to declaration
nnoremap <buffer> <leader>ld <cmd>lua vim.lsp.buf.declaration()<cr>
" Lists all the implementations for the symbol under the cursor
nnoremap <buffer> <leader>li <cmd>lua vim.lsp.buf.implementation()<cr>
" Jumps to the definition of the type symbol
nnoremap <buffer> <leader>lt <cmd>lua vim.lsp.buf.type_definition()<cr>
" Lists all the references
nnoremap <buffer> <leader>lr <cmd>lua vim.lsp.buf.references()<cr>
" Renames all references to the symbol under the cursor
nnoremap <buffer> <leader>ln <cmd>lua vim.lsp.buf.rename()<cr>
" Selects a code action available at the current cursor position
nnoremap <buffer> <leader>la <cmd>lua vim.lsp.buf.code_action()<cr>
endfunction
autocmd LspAttach * call LspAttached()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment