Skip to content

Instantly share code, notes, and snippets.

@VonHeikemen
VonHeikemen / complete-rc.vim
Last active March 21, 2024 11:51
make vim into a nice editor with this completely pluginless rc
" ============================================================================ "
" === EDITING OPTIONS === "
" ============================================================================ "
" Don't include vi compatibility
set nocompatible
" Sensible backspace
set backspace=indent,eol,start
@VonHeikemen
VonHeikemen / init.lua
Last active February 27, 2024 20:09
Minimal configuration of lsp-zero used in the demo https://asciinema.org/a/636643 (doesn't include colorscheme)
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
-- Auto-install lazy.nvim if not present
if not vim.loop.fs_stat(lazypath) then
print('Installing lazy.nvim....')
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
@VonHeikemen
VonHeikemen / better-netrw.vim
Last active February 21, 2024 03:33
Making a more intuitive netrw
" Open Netrw on the directory of the current file
nnoremap <leader>dd :Lexplore %:p:h<CR>
" Toggle the Netrw window
nnoremap <Leader>da :Lexplore<CR>
if &columns < 90
" If the screen is small, occupy half
let g:netrw_winsize = 50
else
@VonHeikemen
VonHeikemen / init.lua
Last active December 22, 2023 07:53
nvim-lspconfig + nvim-cmp setup
--[[
blogpost:
https://vonheikemen.github.io/devlog/tools/setup-nvim-lspconfig-plus-nvim-cmp/
Dependencies:
LSP:
https://github.com/neovim/nvim-lspconfig
https://github.com/williamboman/mason.nvim (optional)
https://github.com/williamboman/mason-lspconfig.nvim (optional)
@VonHeikemen
VonHeikemen / snippet-expansion.lua
Last active December 16, 2023 08:55
enhanced native completion to expand snippets
-- based on u/YungDaVinci work:
-- https://www.reddit.com/r/neovim/comments/ydlgzi/expand_lsp_snippets_with_luasnip_while_using/
vim.api.nvim_create_augroup('user-snippet-expand', {})
vim.api.nvim_create_autocmd('CompleteDone', {
group = 'user-snippet-expand',
desc = 'Expand LSP snippet',
pattern = '*',
callback = function(opts)
local comp = vim.v.completed_item
@VonHeikemen
VonHeikemen / nvchad-setup.lua
Created September 24, 2022 23:58
Separate NvChad's configuration from Neovim's default configuration
local path_sep = vim.loop.os_uname().version:match('Windows') and '\\' or '/'
local join = function(...) return table.concat({...}, path_sep) end
local getpath = function(arg)
local path = vim.fn.stdpath(arg)
return vim.fn.substitute(path, [[\(.*\)\zsnvim]], 'nvchad', '')
end
local user_path = getpath('config')
local data_path = getpath('data')
local chad_core = join(data_path, 'core', 'nvim')
@VonHeikemen
VonHeikemen / astronvim-setup.lua
Last active October 3, 2023 11:36
Separate astronvim's configuration from Neovim's default.
--- For details of usage and explanation see:
--- https://dev.to/vonheikemen/how-to-install-astronvim-without-overriding-your-existing-neovim-configuration-1nke
local path_sep = vim.loop.os_uname().version:match('Windows') and '\\' or '/'
local join = function(...) return table.concat({...}, path_sep) end
local getpath = function(arg)
local path = vim.fn.stdpath(arg)
return vim.fn.substitute(path, [[\(.*\)\zsnvim]], 'astronvim', '')
end
@VonHeikemen
VonHeikemen / example-transducers-v1.js
Created December 26, 2020 19:07
Contrived example of transducers in action
// Common Utilities
function compose(...fns) {
const apply = (arg, fn) => fn(arg);
return (initial) => fns.reduceRight(apply, initial);
}
function curry(arity, fn, ...rest) {
if(arity <= rest.length) {
return fn(...rest);
@VonHeikemen
VonHeikemen / lsp.lua
Last active August 15, 2023 19:00
Primeagen's LSP config without lsp-zero
vim.opt.signcolumn = 'yes'
vim.diagnostic.config({
virtual_text = true,
})
vim.api.nvim_create_autocmd('LspAttach', {
desc = 'LSP keybindings',
callback = function(event)
local opts = {buffer = event.buf}
@VonHeikemen
VonHeikemen / simple.lua
Last active July 6, 2023 15:59
a simple neovim config you can use as init.lua
-- ========================================================================== --
-- == EDITOR SETTINGS == --
-- ========================================================================== --
local set = vim.opt
set.hidden = true
set.swapfile = false
set.backup = false
set.hlsearch = false