Ever wanted to know how noice
creates the cmdline or wanted your own one?
No one? Guess it's just me 🥲.
Anyway, this post is a simple tutorial for creating a basic cmdline in neovim.
---Utility for keymap creation. | |
---@param lhs string | |
---@param rhs string|function | |
---@param opts string|table | |
---@param mode? string|string[] | |
local function keymap(lhs, rhs, opts, mode) | |
opts = type(opts) == 'string' and { desc = opts } | |
or vim.tbl_extend('error', opts --[[@as table]], { buffer = bufnr }) | |
mode = mode or 'n' | |
vim.keymap.set(mode, lhs, rhs, opts) |
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.
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"
.
package main | |
import ( | |
"fmt" | |
) | |
func fib(n int) int { | |
fibs := make(map[int]int, n+1) | |
fibs[0] = 0 | |
fibs[1] = 1 |
package main | |
import ( | |
"context" | |
"flag" | |
"log" | |
"net/http" | |
"os" | |
"os/signal" | |
"time" |
# make sure you don't have any soon to be forgotten version of vim installed | |
$ sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-gui-common | |
# Install Deps | |
$ sudo apt-get install build-essential cmake | |
$ sudo apt-get install python3-dev | |
#Optional: so vim can be uninstalled again via `dpkg -r vim` | |
$ sudo apt-get install checkinstall |
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"strings" | |
"github.com/go-git/go-billy/v5/memfs" | |
gogit "github.com/go-git/go-git/v5" |
package bitly | |
import ( | |
"bytes" | |
"encoding/json" | |
"fmt" | |
"net/http" | |
) | |
const BaseURL = "https://api-ssl.bitly.com/v4" |
#!/bin/bash | |
#clean the com.apple.macl attribute from a file or folders using zip to sidestep SIP on Catalina | |
#WARNING: This will overwrite the original file/folders with the zipped version - DO NOT use on production data | |
#hold down command key at launch or touch /tmp/debug to enable xtrace command expansion | |
commandKeyDown=$(/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSCommandKeyMask > 1') | |
[ "$commandKeyDown" = "True" -o -f /tmp/debug ] && set -x && xtraceFlag=1 | |
#hacky example to clean the com.apple.macl attribute from a file using zip to sidestep SIP | |
: <<-EOL |