• Stars
    star
    522
  • Rank 82,129 (Top 2 %)
  • Language
    Lua
  • License
    MIT License
  • Created about 1 year ago
  • Updated 14 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use the w, e, b motions like a spider. Move by subwords and skip insignificant punctuation.

nvim-spider 🕷️🕸️

Use the w, e, b motions like a spider. Move by subwords and skip insignificant punctuation.

Lua implementation of CamelCaseMotion, with extra consideration of punctuation. Works in normal, visual, and operator-pending mode. Supports counts and dot-repeat.

Features

The w, e, b (and ge) motions work the same as the default ones by vim, except for two differences:

Subword Motion

The movements happen by subwords, meaning it stops at the sub-parts of a camelCase, SCREAMING_SNAKE_CASE, or kebab-case variable.

-- positions vim's `w` will move to
local myVariableName = FOO_BAR_BAZ
--    ^              ^ ^

-- positions spider's `w` will move to
local myVariableName = FOO_BAR_BAZ
--    ^ ^       ^    ^ ^   ^   ^

Skipping Insignificant Punctuation

A sequence of one or more punctuation characters is considered significant if it is surrounded by whitespace and does not include any non-punctuation characters.

foo == bar .. "baz"
--  ^      ^    significant punctuation

foo:find("a")
-- ^    ^  ^  insignificant punctuation

This speeds up the movement across the line by reducing the number of mostly unnecessary stops.

-- positions vim's `w` will move to
if foo:find("%d") and foo == bar then print("[foo] has" .. bar) end
-- ^  ^^   ^  ^^  ^   ^   ^  ^   ^    ^    ^  ^  ^ ^  ^ ^  ^  ^ ^  -> 21

-- positions spider's `w` will move to
if foo:find("%d") and foo == bar then print("[foo] has" .. bar) end
-- ^   ^      ^   ^   ^   ^  ^   ^    ^       ^    ^    ^  ^    ^  -> 14

If you prefer to use this plugin only for subword motion, you can disable this feature by setting skipInsignificantPunctuation = false in the .setup() call.

Note
This plugin ignores vim's iskeyword option.

Installation

-- packer
use { "chrisgrieser/nvim-spider" }

-- lazy.nvim
{ "chrisgrieser/nvim-spider", lazy = true },

No keybindings are created by default. Below are the mappings to replace the default w, e, and b motions with this plugin's version of them.

vim.keymap.set({"n", "o", "x"}, "w", "<cmd>lua require('spider').motion('w')<CR>", { desc = "Spider-w" })
vim.keymap.set({"n", "o", "x"}, "e", "<cmd>lua require('spider').motion('e')<CR>", { desc = "Spider-e" })
vim.keymap.set({"n", "o", "x"}, "b", "<cmd>lua require('spider').motion('b')<CR>", { desc = "Spider-b" })
vim.keymap.set({"n", "o", "x"}, "ge", "<cmd>lua require('spider').motion('ge')<CR>", { desc = "Spider-ge" })

Note
For dot-repeat to work, you have to call the motions as Ex-commands. When calling function() require("spider").motion("w") end as third argument of the keymap, dot-repeatability will not work.

Configuration

The .setup() call is optional. Currently, its only option is to disable the skipping of insignificant punctuation:

-- default value
require("spider").setup({
	skipInsignificantPunctuation = true
})

You can also pass this configuration table to the motion function:

require('spider').motion('w', { skipInsignificantPunctuation = false })

Any options passed here will be used, and any options not passed will use the default configuration (from setup() or the default configuration)

Notes on Operator-pending Mode

In operator pending mode, vim's web motions are actually a bit inconsistent. For instance, cw will change to the end of a word instead of the start of the next word, like dw does. This is probably done for convenience in vi's early days before there were text objects. In my view, this is quite problematic since it makes people habitualize inconsistent motion behavior.

In this plugin, such small inconsistencies are therefore deliberately not implemented. Apart from the inconsistency, such a behavior can create unexpected results when used in subwords or near punctuation. If you absolutely want to, you can map cw to ce though. (Remember to add remap = true as option for the keymap.)

Subword Text Object

This plugins supports w, e, and b in operater-pending mode, but does not include a subword-variant of iw. For a version of iw that considers camelCase, check out the subword text object of nvim-various-textobjs.

Credits

Thanks
To @vypxl and @ii14 for figuring out dot-repeatability.

About Me
In my day job, I am a sociologist studying the social mechanisms underlying the digital economy. For my PhD project, I investigate the governance of the app economy and how software ecosystems manage the tension between innovation and compatibility. If you are interested in this subject, feel free to get in touch.

Blog
I also occasionally blog about vim: Nano Tips for Vim

Profiles

Buy Me a Coffee

Buy Me a Coffee at ko-fi.com

More Repositories

1

shimmering-obsidian

Alfred Workflow with dozens of features for controlling your Obsidian vault.
JavaScript
779
star
2

nvim-various-textobjs

Bundle of more than 30 new text objects for Neovim.
Lua
459
star
3

shimmering-focus

Minimalistic Obsidian Theme for keyboard-centric users.
CSS
450
star
4

nvim-scissors

Automagical editing and creation of snippets.
Lua
276
star
5

nvim-genghis

Convenience file operations for neovim, written in lua.
Lua
192
star
6

nvim-recorder

Enhance the usage of macros in Neovim.
Lua
186
star
7

nvim-early-retirement

Send buffers into early retirement by automatically closing them after x minutes of inactivity.
Lua
163
star
8

obsidian-smarter-md-hotkeys

A plugin for Obsidian providing hotkeys that select words and lines in a smart way before applying markup. Multiple cursors are supported as well.
TypeScript
134
star
9

alfred-bibtex-citation-picker

Citation picker & lightweight reference manager for BibTeX files, via Alfred.
JavaScript
132
star
10

nvim-origami

Fold with relentless elegance.
Lua
121
star
11

nvim-tinygit

A lightweight bundle of commands focussed on swift and streamlined git operations.
Lua
117
star
12

nvim-kickstart-python

A launch point for your nvim configuration for Python
Lua
101
star
13

pandoc_alfred

Pandoc-Suite for Academic Writing in Markdown
JavaScript
97
star
14

obsidian-theme-design-utilities

Some Utilities and Quality-of-Life Features for Designers of Obsidian Themes
TypeScript
91
star
15

nvim-chainsaw

Speed up log creation. Create various kinds of language-specific log statements, such as logs of variables, assertions, or time-measuring.
Lua
81
star
16

pdf-annotation-extractor-alfred

Alfred Workflow to extract annotations from PDF files.
JavaScript
71
star
17

finder-vim-mode

Feature-rich mouseless control of macOS Finder, inspired by vim/ranger.
Shell
71
star
18

nvim-rulebook

Add inline-comments to ignore rules, or lookup rule documentation online.
Lua
65
star
19

.config

My personal dotfiles
Lua
56
star
20

nvim-puppeteer

Automatically convert strings to f-strings or template strings and back.
Lua
53
star
21

obsidian-divide-and-conquer

An Obsidian plugin that provides commands for bulk enabling/disabling of plugins. Useful for debugging when you have many plugins.
TypeScript
53
star
22

nvim-alt-substitute

A substitute of vim's :substitute that uses lua patterns instead of vim regex. Supports incremental preview.
Lua
42
star
23

zsh-magic-dashboard

Pressing "enter" on an empty buffer displays an information-rich and pretty dashboard.
Shell
42
star
24

grappling-hook

Obsidian Plugin for blazingly fast file switching. For those who find the Quick Switcher still too slow.
TypeScript
42
star
25

new-tab-default-page

Obsidian plugin to open a note of your choice when creating a new tab, like in the browser.
TypeScript
41
star
26

obsidian-quadro

Obsidian Plugin for social-scientific Qualitative Data Analysis (QDA). An open alternative to MAXQDA and atlas.ti, using Markdown to store data and research codes.
TypeScript
37
star
27

cmp-nerdfont

nvim-cmp source for nerdfont icons
Lua
36
star
28

cmp_yanky

cmp-source for clipboard history from yanky.nvim
Lua
28
star
29

alfred-neovim-utilities

Search neovim plugins and online :help via Alfred
JavaScript
27
star
30

nvim-dr-lsp

Status line component showing the number of LSP definition and reference of the token under the cursor.
Lua
25
star
31

alfred-docs-searches

Search more than two dozen official documentation sites via Alfred
JavaScript
23
star
32

twitter-workspace-for-drafts

Various capabilities for composing tweets in the Drafts app.
22
star
33

obsidian-sembr

Obsidian Plugin for Semantic Line Breaks
TypeScript
22
star
34

obsidian-footnote-indicator

Indicates the presence of footnotes in the gutter and the Status bar
Shell
20
star
35

alfred-reddit-browser

Browse your favorite subreddits (and hackernews) via Alfred.
JavaScript
19
star
36

nvim-pseudometa-plugin-template

A template for new nvim plugins
Shell
19
star
37

alfred-atop

System Monitoring and Process Management via Alfred
JavaScript
18
star
38

gitfred

Helpful GitHub Assistant for Alfred.
JavaScript
14
star
39

alfred-homebrew

Search, install, or uninstall homebrew packages conveniently via Alfred.
JavaScript
13
star
40

pdf-summarizer-alfred

Get summaries of your PDFs via ChatPDF.
Shell
12
star
41

obsidian-extra-md-commands

Obsidian plugin that adds various commands, e.g. for __bold__ or <cite>.
TypeScript
12
star
42

hyper-seek

Alfred workflow that shows inline search results, without a keyword.
JavaScript
11
star
43

wrench-knife

Collection of useful snippets for Hammerspoon
Lua
11
star
44

obsidian-nothing

An Obsidian plugin that adds a no-op command.
Shell
11
star
45

obsidian-sidebar-toggler

Finer control of the Obsidian sidebars. To be used with an external window manager.
TypeScript
10
star
46

pseudometa-obsidian-plugin-template

A description for the plugin
JavaScript
10
star
47

alfred-writing-assistant

Autocorrection and synonym suggestions for the word under the cursor. Rephrasing of the selected text. All with one key press.
Shell
10
star
48

pdf-annotation-extractor

Extracts Annotations from PDFs as well-formatted markdown
JavaScript
9
star
49

alfred-themes

A small collection of Alfred Themes I designed
8
star
50

alfred-pass

Alfred Client for the pass-cli
JavaScript
8
star
51

alfred-workflow-template

Shell
8
star
52

dotfiles-old

pseudometa's dotfiles
TeX
7
star
53

obsidian-smarter-paste

Improvements for when you paste things into Obsidian
TypeScript
7
star
54

alfred-read-later

Simple standalone read-later-app for Alfred. Saves the items in plaintext on your device.
JavaScript
7
star
55

alfred-steam-companion

Alfred Workflow that interacts with Steam. Launches games directly, creates aliases, uninstalls games, and searches the Steam Store
6
star
56

drafts-snooze

Combination of settings, draft actions and shortcuts to enable the snoozing of drafts.
5
star
57

obsidian-task-statusbar

Obsidian plugin that displays the number of completed and total tasks in the status bar.
Shell
4
star
58

portfolio-performance-alfred

Searches your watchlists in the Portfolio Performance App for securities. Select one to copy its Name, Symbol, ISIN, or WKN to the clipboard.
JavaScript
4
star
59

alfred-wikipedia-suggest

Get in-line Wikipedia search suggestions
JavaScript
3
star
60

axelrod-prisoner-dilemma

Recreation of the prisoner's dilemma model from Axelrod's "Evolution of Cooperation" in Python
Python
2
star
61

obsidian-personal-plugin

Personal Obsidian plugin, containing features customized to my workflow.
TypeScript
2
star
62

tot-alfred

Tot.app Integration for Alfred.
JavaScript
2
star
63

apuz-gender-analyzer

Analysis of the genders of the authors at the German journal "Aus Politik und Zeitgeschichte" (APuZ)
Python
2
star
64

quadro-example-vault

Example vault for Quadro, the QDA Plugin for Obsidian.
Makefile
2
star
65

name-gender-analyzer

Makefile
1
star
66

test-repo

This repo is currently only used for testing GitHub Release Actions
Shell
1
star
67

nanotipsforvim-blog

source for the blog
CSS
1
star