Skip to content

Instantly share code, notes, and snippets.

@runiq
runiq / README.md
Last active November 17, 2023 00:40
🌈

HOW TO 🌈

  1. Save as 🌈.lua
  2. cd $(dirname path/to/🌈.lua)
  3. nvim 🌈.lua
  4. :luafile %
  5. Press F5 to 🌈

The F5 bit is just for demonstration. In an actual statusline, you'll want to uncomment line 65 so it actually checks for LSP messages.

@runiq
runiq / add_incr_print.lua
Last active March 17, 2021 00:46
Automatically numbered print statements
local counter = 1
local M = {}
--- Creates a function to insert customized numbered print statements.
---
--@param context (string, default "print('%d')") The format string for the debug
--- statement. Should contain a single `%d`, which will be the insertion point
--- of the current counter value.
function M.debug_statement_factory(context)
local context = context or [[print('%d')]]
@runiq
runiq / fix-floating-preview.lua
Last active March 16, 2021 18:16
Sanity check
-- 1. Clone https://github.com/neovim/neovim/pull/12720
-- 2. Run with `nvim -u NONE fix-floating-preview.lua '+luafile %'`
-- 3. press F7 twice.
-- 4. Does it echo your current line (including line numbers!) to the :messages
-- pane before switching into the floating window?
function __beep() return vim.lsp.util.open_floating_preview({'foo', 'boo'}, 'lua', {focus_id='beep'}) end
vim.api.nvim_buf_set_keymap(0, '', '<f7>', '<cmd>lua __beep()<cr>', {silent = true, noremap = true})
vim.wo.number = true
@runiq
runiq / .bash_profile
Created January 20, 2021 00:04
How I handle envvars
[[ -f "$HOME/.profile" ]] && source "$HOME/.profile"
[[ $- == *i* && -f "$HOME/.bashrc" ]] && source "$HOME/.bashrc"
@runiq
runiq / util.lua
Created January 15, 2021 16:49
Neovim: "native" Lua callbacks in mappings
local M = {}
M._cbs = {}
--- Saves a Lua function as a callback and returns a string that can be used to
--- run that function.
---
---@param fn Callback
---@return string
function M.lua_callback(fn)
assert(type(fn) == 'function', tb('fn must be a function'))
@runiq
runiq / Android - Enable ADB from recovery.md
Created November 13, 2020 14:44 — forked from varhub/Android - Enable ADB from recovery.md
Android - Enable ADB from recovery

Android - Enable ADB from recovery

Credits to @TheOnlyAnil-@Firelord[^stackoverflow]

  • Requirements: a) stock recovery + rooted phone b) custom recovery

  • Files changed:

@runiq
runiq / README.md
Last active July 9, 2024 15:35
Neovim throttle & debounce

What are these?

Functions that allow you to call a function not more than once in a given timeframe.

Throttling on the leading edge

This can be illustrated with timing diagrams. In the following diagrams, f designates call to the throttled function, t is the period where the timer is running, and x shows you the actual execution point of the throttled function.

f 1  2  3  4  5  6
@runiq
runiq / patch.patch
Created August 6, 2020 17:51
Integrating snippets.nvim and completion-nvim
diff --git i/lua/completion.lua w/lua/completion.lua
index 1fed4f4..4c9774b 100644
--- i/lua/completion.lua
+++ w/lua/completion.lua
@@ -107,6 +107,8 @@ local function hasConfirmedCompletion()
api.nvim_input("<c-r>".."=neosnippet#expand('"..completed_item.word.."')".."<CR>")
elseif completed_item.kind == 'vim-vsnip' then
api.nvim_call_function('vsnip#expand', {})
+ elseif completed_item.kind == 'snippets.nvim' then
+ require'snippets'.expand_at_cursor()
#######
LanguageClient 0.1.157 4b35f5d6859ab3d42546192cbede9add59a7435a
#######
10:01:27 DEBUG unnamed src/language_client.rs:78 state: null ==> {"apply_completion_additional_text_edits":true,"auto_start":true,"capabilities":{"rust":{"capabilities":{"callHierarchyProvider":true,"codeActionProvider":{"codeActionKinds":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]},"codeLensProvider":{"resolveProvider":true},"completionProvider":{"triggerCharacters":[":","."]},"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"=","moreTriggerCharacter":[".",">"]},"documentSymbolProvider":true,"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"documentProvider":true,"legend":{"tokenModifiers":["documentation
@runiq
runiq / text_document_document_symbol.diff
Last active June 23, 2020 13:04
Patch for LCN's text_document_document_symbol()
diff --git i/src/language_server_protocol.rs w/src/language_server_protocol.rs
index 9922afa..e2916d9 100644
--- i/src/language_server_protocol.rs
+++ w/src/language_server_protocol.rs
@@ -1420,111 +1420,46 @@ impl LanguageClient {
let syms = <lsp_types::request::DocumentSymbolRequest as lsp_types::request::Request>::Result::deserialize(&result)?;
let title = format!("[LC]: symbols for {}", filename);
- let selection_ui = self.get(|state| state.selection_ui)?;
- let selection_ui_auto_open = self.get(|state| state.selection_ui_auto_open)?;