Skip to content

Instantly share code, notes, and snippets.

@VonHeikemen
Last active April 17, 2025 01:38
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>
" List of compatible language servers is here:
" https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md
lua require('lspconfig').gopls.setup({})
lua require('lspconfig').rust_analyzer.setup({})
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