Skip to content

Instantly share code, notes, and snippets.

@VonHeikemen
VonHeikemen / commit-hash.vim
Last active January 23, 2022 00:48
collect commit hash from vim plugins using vimscript
let s:packpath = expand('~/.local/share/nvim/site/pack/minpac')
let s:hash_dir = expand('~/.local/share/nvim/site/pack/minpac/hashes')
let s:pattern = '/{opt,start}'
function! s:save_hashes() abort
let plugin_dirs = glob(s:packpath .. s:pattern, 1, 1)
if empty(plugin_dirs)
return
endif
@VonHeikemen
VonHeikemen / map_utils.lua
Last active March 27, 2022 16:15
Allows you to use lua functions with `vim.api.nvim_set_keymap` (for neovim 0.6.1 or lower)
local M = {}
local module_name = 'map_utils'
local fn_store = {}
local function register_fn(fn)
table.insert(fn_store, fn)
return #fn_store
end
function M.apply_function(id)
@VonHeikemen
VonHeikemen / prompt-backspace.lua
Last active January 10, 2022 01:57
Neovim: Use backspace when `buftype=prompt`
-- Taken from here:
-- https://github.com/neovim/neovim/issues/14116#issuecomment-977555102
function PromptBackspace()
-- Have to know the length of the prompt
local prompt = 2
local cursor = vim.api.nvim_win_get_cursor(0)
local line = cursor[1]
local col = cursor[2]
if col ~= prompt then
@VonHeikemen
VonHeikemen / completion.lua
Created November 16, 2021 17:20
Sublime-like autocompletion for neovim, using nvim-cmp and luasnip
--[[
Dependencies:
Completion:
https://github.com/hrsh7th/nvim-cmp
https://github.com/hrsh7th/cmp-buffer
https://github.com/hrsh7th/cmp-path
https://github.com/saadparwaiz1/cmp_luasnip
Snippets:
@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
#! /usr/bin/env node
const os = require('os');
const getNetworkAddress = (interfaces) => {
for (const name of Object.keys(interfaces)) {
for (const interface of interfaces[name]) {
const {address, family, internal} = interface;
if (family === 'IPv4' && !internal) {
return address;
@VonHeikemen
VonHeikemen / esm.json
Last active February 10, 2021 13:22
Create a productive environment for small personal scripts. Only try this at home.
{
"cache": false,
"await": true
}
@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 / better-netrw.vim
Last active November 26, 2024 12:28
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 / rc.vim
Created January 4, 2021 03:02
simple vimrc
" ============================================================================ "
" === EDITING OPTIONS === "
" ============================================================================ "
" Don't include vi compatibility
set nocompatible
" Sensible backspace
set backspace=indent,eol,start