Skip to content

Commit d05dd6a

Browse files
authored
feat!: rewrite grapple (#89)
* feat: initial rewrite * refactor: remove old code * refactor: scope grapple types * fix: add empty api so that plugin can be loaded * feat: add wrapper for vim.fs.joinpath * fix: remove container during reset * Implement tag reconciliation when window closes Diffing assumes that all tags are removed and then re-added. This makes it easier to resolve at the cost of a larger performance impact. This should be negligible since container should not have many tags at any given point in time. Implement window quickfix method. Allow users to send tags to a quickfix list. * refactor: update relationship between window and content Window must know as little as possible about Content. The same goes for keymaps. However, there are actions available (i.e. tag selection) that must know about both the vim buffer and vim window. The revised models are as follows: The Window can render at most one Content at a time The Window can #attach or #detach from Content The Window can #update and #render Content The Content does not hold state for any vim constructs and must receive them from Window The Content uses #update to update internal state The Content uses #render to publish its state to a vim buffer The Content uses #attach to call hooks The Content uses #detach to reconcile modified entries A Content hook will receive a window for access to ui information A Content hook will receive a window to create keymaps or autocommands A Content hook will receive the content itself to perform actions * refactor: tag actions * fix: grapple.vim.win_opts title can only be a string * refactor: identify when window is rendered with content + dynamic content title * fix: delete old code * refactor: more ui work * refactor: temporarily remove old specs * test: update test harness and helper functions * work: add .neoconf.json to improve spec intellisense * fix: improve absolute path resolution + add spec * work: add stylua.toml * refactor: Util.absolute and Util.relative can now error * refactor: code organization + improve rendered tag content * feat: fix cursor to a minimum column position * refactor: functions are nillable + begin public api + functional scope manager * fix(test): Util.absolute is nillable * refactor: attempt to update on quit + loads more * fix: tag#update pulls the cursor from the current window * refactor: create grapple.app module * feat: add scope fallback * fix: add annotations for grapple.app * refactor: rename TagManager:container to TagManager:load * refactor: allow scope resolver to return a nil id * fix: use ExitPre to save cursor instead of QuitPre * refactor: removing cursor hack (yay!) * refactor: redundant definition of tag update callback * fix: only set title from content if returning true * feat: add user settings + add user command * feat: use lua file for loading grapple * refactor: simplify state error handling * fix: apply_changes returns a string, not a table * fix: remove debug save_path + fix cwd scope resolver + early exit git_branch * chore: remove unused selene.toml * feat: allow toggling icons in settings * feat: add :len and :is_empty to TagContainer * feat: emit GrappleUpdate on container transaction * fix: prefer BufWinLeave over BufLeave when closing window This allows (in the future) for actions to open their own floating window without closing the grapple window * feat: use api opts for tag/untag/toggle/select + add cycle forward and backward * doc: don't prefix type documentation with "vim.api" * refactor: sort buffer options * fix: invalidate mark when line is deleted * refactor: sort win_opts in settings * fix: remove files added from rebase * fix: delete autocmds file for the nth time * feat: add Path module * test: run tests sequentially * refactor: replace Util with Path in TagContent * feat: add Path.short, Path.exists, and Path.is_uri (unstable) * refactor: replace Util with Path in Tag * refactor: replace Util with Path in TagAction * refactor: replace Util with Path in TagContainer * feat: support title padding * feat: scope caching * fix: remove debugging * refactor: delete unused util module Replaced by the path module * refactor: repurpose util module for helpful methods and predicates * refactor: default use scope id as title * fix: defer closing closing window * fix: window doesn't use BufUnload * refactor: use concise name for callback function * docs: rename some lua classes * fix: remove unused opts from autocmd * fix: remove Grapple.setup overhead from Grapple.initialize * docs: update README and some settings documentation * docs: basic markdownlint config * fix: remove debug statements * docs: continue updating README * fix: ensure default scopes are not overridden + properly update settings * refactor: use App.enter to clean up duplicate top-level error handling code * refactor: rename StateManager as State * fix: trim whitespace from lines before parsing * feat: use "{{ titie }}" in settings to indicate use of content title * fix: better line parsing for tag content * refactor: move initialize to bottom + all api accepts grapple.options * refactor: window manages state instead of the content * fix: Window:is_rendered() requires is_open and has_content + remove content id * fix: improve window title resolution * feat: basic scopes window + scope description Add basic scope window. Will be used to select the default scope. Right now it only shows the scope's name and (new) description. Also, renamed some classes. The "." style wasn't quite working out. * feat: scope actions :) * fix: use initial neovim working directory for the "static" scope * fix: prevent re-entering the current buffer on tag selection * fix: ensure window boundaries are valid * feat: add Grapple.quickfix Also, fix off-by-one error in Grapple.cycle * fix(docs): double "and and" * fix: sort scopes by name in scope content * refactor: use correct name of State instead of StateManager * feat: container window + permit storing URIs * fix: assume URIs are already as short as possible * feat: add split and vsplit commands to tag window * refactor: rename TagManager.update to TagManager.update_all * fix: remove old comments * refactor: prefix scope and container titles with Grapple * fix: use container name when sorting * docs: update settings + update tag window keybinds + add container window section * docs: minor improvements and style fixes * feat: allow "cache = true" to cache indefinitely in scope definition * feat: support tag names fix: TagActions opts might not always exist fix: Parse empty values passed into Grapple as nil fix: Use correct set of arguments when calling via Grapple command refactor: TagContainer now accepts grapple.options rather than specialized args per method refactor: TagContainer.insert will insert or replace based on path refactor: Add fast lookup for tags based on path and name (unique) refactor: Create Path.fs_absolute and Path.fs_relative for when needing to observe the filesystem * docs: update readme * fix: do normal path joining for Windows paths * fix: error out when icons = true and nvim-web-devicons is not available * refactor: allow container transactions without syncing state Added to avoid the overhead of methods like Grapple.exists and Grapple.name_or_index since all they do are lookups * refactor: some code reorganization in TagContainer * refactor: cleanup TagActions.select * fix: filter modified entries before iterating when diffing content * fix: telescope extension * docs: add todo item * fix: ensure cache is closed when redefining a scope * docs: update grapple.scope_definition * feat: add Grapple.define_scope * refactor: address some linting errors * refactor: add deprecated commands. Will remove in a future release * feat: exclude tagging buffer by options Some defaults included in the settings * fix: silly mistake * fix: extract path from options in Grapple.exists and Grapple.name_or_index * fix: use vim.loop as vim.uv is a nightly feature * fix: vim.fs.joinpath is nightly too * fix: extmark opt "invalidate" is a nightly feature * refactor: cleanup Path.join and add nvim-0.10 comment * fix: vim.system is a nightly feature, use vim.fn.system instead * feat: add debounce to cache * docs: update statusline section in readme * docs: cleanup telescope and contributors section * docs: add luadocs for top-level API methods * fix: use "git" as the default scope * refactor: actions should use the top-level grapple api, not the other way around * docs: update readme showcase * docs: update grapple windows screenshot * docs: update link to Scopes API * feat: add dedicated statusline method * refactor: rename containers window to loaded scopes window * feat: add actions for loaded scopes window * feat: add simple reset scope action to loaded scopes window * refactor: move some code around * docs: update readme * fix: don't worry if path doesn't exist for tag selection * docs: update readme * fix: use cwd for "static" scope * fix: ensure grapple state directory is created on startup * docs: use "loaded scope" instead of "container" in readme
1 parent a714d01 commit d05dd6a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4459
-4052
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
.tests
12
.luarc.json

.markdownlint.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
MD013:
2+
line_length: 120
3+
4+
MD033:
5+
allowed_elements:
6+
- "a"
7+
- "b"
8+
- "details"
9+
- "img"
10+
- "summary"

.neoconf.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"neodev": {
3+
"library": {
4+
"plugins": ["plenary.nvim"]
5+
}
6+
},
7+
"lspconfig": {
8+
"lua_ls": {
9+
"Lua.runtime.version": "LuaJIT",
10+
"Lua.workspace.checkThirdParty": false
11+
}
12+
}
13+
}

Makefile

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
ifneq ($(strip $(spec)),)
2-
spec_file = $(spec)_spec.lua
3-
endif
4-
51
test:
6-
echo $(spec_file)
7-
nvim --headless --clean --noplugin \
8-
-u "tests/minimal_init.vim" \
9-
-c "PlenaryBustedDirectory tests/spec/$(spec_file) { minimal_init = 'tests/minimal_init.vim' }"
2+
printf "\n======\n\n" ; \
3+
nvim --version | head -n 1 && echo '' ; \
4+
nvim --headless \
5+
-u "tests/minimal_init.lua" \
6+
-c "PlenaryBustedDirectory tests { minimal_init = 'tests/minimal_init.lua', sequential = true }"
7+
8+
test_file:
9+
printf "\n======\n\n" ; \
10+
nvim --version | head -n 1 && echo '' ; \
11+
nvim --headless \
12+
-u "tests/minimal_init.lua" \
13+
-c "PlenaryBustedDirectory $(FILE) { minimal_init = 'tests/minimal_init.lua', sequential = true }"
14+
15+
clean:
16+
rm -rf .tests

0 commit comments

Comments
 (0)