Skip to content

Instantly share code, notes, and snippets.

Avatar

Andy Shevchenko ur4ltz

  • Kharkiv - Ukraine, Glory to Ukraine
View GitHub Profile
@Lattay
Lattay / README.md
Last active Jan 6, 2023
Configure luarocks for Neovim at startup (Linux)
View README.md

When using Lua-based plugins for Neovim, you may need to install some packages with luarocks. To use these packages, the environment variables LUA_PATH and LUA_CPATH needs to contain the luarocks directories. Problem is, Neovim uses LuaJIT which is a Lua 5.1 implementation; however, you may already have your environment setup for a different Lua version, for example the current last version 5.4. To resolve this problem, this gist patches the Lua paths in the startup configuration instead of relying on the environment variables as is default in Neovim.

View feline.lua
local feline = require('feline')
local vi_mode = require('feline.providers.vi_mode')
--
-- 1. define some constants
--
-- left and right constants (first and second items of the components array)
local LEFT = 1
local RIGHT = 2
@MunifTanjim
MunifTanjim / .config--hammerspoon--.nvimrc.lua
Last active Aug 24, 2022
Neovim - Project Local Config with exrc.nvim
View .config--hammerspoon--.nvimrc.lua
require("config.lsp.custom").patch_lsp_settings("sumneko_lua", function(settings)
settings.Lua.diagnostics.globals = { "hs", "spoon" }
settings.Lua.workspace.library = {}
local hammerspoon_emmpylua_annotations = vim.fn.expand("~/.config/hammerspoon/Spoons/EmmyLua.spoon/annotations")
if vim.fn.isdirectory(hammerspoon_emmpylua_annotations) == 1 then
table.insert(settings.Lua.workspace.library, hammerspoon_emmpylua_annotations)
end
@kylechui
kylechui / dot-repeating.md
Last active Jan 16, 2023
A basic overview of how to manage dot-repeating in your Neovim plugin, as well as manipulate it to "force" what action is repeated.
View dot-repeating.md

Adding dot-repeat to your Neovim plugin

In Neovim, the . character repeats "the most recent action"; however, this is not always respected by plugin actions. Here we will explore how to build dot-repeat support directly into your plugin, bypassing the requirement of dependencies like repeat.vim.

The Basics

When some buffer-modifying action is performed, Neovim implicitly remembers the operator (e.g. d), motion (e.g. iw), and some other miscellaneous information. When the dot-repeat command is called, Neovim repeats that operator-motion combination. For example, if we type ci"text<Esc>, then we replace the inner contents of some double quotes with text, i.e. "hello world""text". Dot-repeating from here will do the same, i.e. "more samples""text".

Using operatorfunc

@NNBnh
NNBnh / wm.md
Created May 3, 2022
My old windows manager ranking
View wm.md
@VonHeikemen
VonHeikemen / map_utils.lua
Last active Mar 27, 2022
Allows you to use lua functions with `vim.api.nvim_set_keymap` (for neovim 0.6.1 or lower)
View map_utils.lua
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 Jan 10, 2022
Neovim: Use backspace when `buftype=prompt`
View prompt-backspace.lua
-- 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 Nov 16, 2021
Sublime-like autocompletion for neovim, using nvim-cmp and luasnip
View completion.lua
--[[
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:
@numToStr
numToStr / au.lua
Last active Jan 16, 2023
Neovim autocmd in lua
View au.lua
--
-- Move this file to your neovim lua runtime path ie. ~/.config/nvim/lua/au.lua
--
local cmd = vim.api.nvim_command
local function autocmd(this, event, spec)
local is_table = type(spec) == 'table'
local pattern = is_table and spec[1] or '*'
local action = is_table and spec[2] or spec
if type(action) == 'function' then
View rust_tools_lsp_config.lua
local function setup_rust_tools()
local tools = {
autoSetHints = true,
runnables = {use_telescope = true},
inlay_hints = {show_parameter_hints = true},
hover_actions = {auto_focus = true}
}
require('rust-tools').setup({
tools = tools,
server = {