nvim-context 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/AGENTS.md +70 -6
- data/CLAUDE.md +1 -0
- data/README.md +27 -80
- data/lib/nvim_context/version.rb +1 -1
- metadata +12 -68
- data/CLAUDE.md +0 -38
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f3a92b390810e2ca6d9bb8b5ae1cdf8e7857d241030f45d862bd4394dd1b38c
|
|
4
|
+
data.tar.gz: 3cd54046591babf16e395dda269c277f42bc84b66116cfc41ac0d25751f178a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 05fb6b21b901b2eb8b3e9fda9e6b301f4be2c160c127d1e88a384787f4ebecf23ceb111f4afc7b55d59d52dd21389a4b47056ccf9c7854bb364b7f8c8f66567b
|
|
7
|
+
data.tar.gz: 6343f612a126c06c374da6b4d03579bbcf301d23d3636cbc2d6e977ce826a571a6cd85623054a0688e79d3ce6dd5eddc093924d01f3dbb2ed7ebe767b075e24c
|
data/AGENTS.md
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
# AGENTS.md
|
|
2
|
+
## Project overview
|
|
3
|
+
`nvim-context` is a Ruby gem that bridges running Neovim instances and agentic
|
|
4
|
+
coding tools. It extracts live context from the editor via a Unix socket
|
|
5
|
+
connection and outputs JSON with cursor position, current file, visual
|
|
6
|
+
selection and diagnostics.
|
|
7
|
+
|
|
8
|
+
**Version**: 1.0.0
|
|
9
|
+
**Ruby**: >= 3.4.0
|
|
10
|
+
**Dependencies**: `neovim` gem (~> 0.10.0)
|
|
2
11
|
|
|
3
12
|
## Commands
|
|
4
13
|
- **Test all**: `bundle exec rspec`
|
|
@@ -6,13 +15,68 @@
|
|
|
6
15
|
- **Test integration**: `bundle exec rspec spec/integration/`
|
|
7
16
|
- **Test single file**: `bundle exec rspec path/to/spec.rb`
|
|
8
17
|
- **Lint**: `bundle exec rubocop`
|
|
9
|
-
- **
|
|
18
|
+
- **Run tool**: `bin/nvim-context`
|
|
19
|
+
- **Build gem**: `gem build nvim-context.gemspec`
|
|
20
|
+
|
|
21
|
+
## Architecture
|
|
22
|
+
### Entry point
|
|
23
|
+
`bin/nvim-context` - CLI executable that calls `NvimContext::Fetcher.fetch` and
|
|
24
|
+
prints JSON to stdout.
|
|
25
|
+
|
|
26
|
+
### Core components (`lib/nvim_context/`)
|
|
27
|
+
- `fetcher.rb` - Main entry point class with static `fetch` method. Orchestrates
|
|
28
|
+
data extraction, handles all error types, and returns JSON responses
|
|
29
|
+
- `connector.rb` - Manages Neovim socket connection using the `neovim` gem.
|
|
30
|
+
Reads socket path from `NVIM_CONTEXT_SOCKET` env var or defaults to
|
|
31
|
+
`nvim-context.sock` in current directory
|
|
32
|
+
- `data_extractor.rb` - Static methods to extract cursor position, current file
|
|
33
|
+
path, visual selection (with text content), and diagnostics from Neovim
|
|
34
|
+
- `errors.rb` - Custom error classes: `ConnectionError` (socket failures) and
|
|
35
|
+
`ContextError` (Neovim operation failures)
|
|
36
|
+
- `version.rb` - Gem version constant
|
|
37
|
+
|
|
38
|
+
### Data Flow
|
|
39
|
+
1. User runs `nvim-context` CLI
|
|
40
|
+
2. `Fetcher.fetch` creates a `Connector` instance
|
|
41
|
+
3. `Connector` attaches to Neovim via Unix socket
|
|
42
|
+
4. `DataExtractor` methods query Neovim for context data
|
|
43
|
+
5. JSON output returned to stdout (or error JSON on failure)
|
|
10
44
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
45
|
+
### JSON output format
|
|
46
|
+
Success:
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"cursor": { "line": 43, "col": 3 },
|
|
50
|
+
"file": "/path/to/file.rb",
|
|
51
|
+
"selection": null,
|
|
52
|
+
"diagnostics": []
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Error:
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"error": "Connection failed",
|
|
60
|
+
"details": "Failed to connect to Neovim socket: No such file"
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Code style
|
|
65
|
+
- Ruby 3.4, line length max 80 chars
|
|
66
|
+
- Use double quotes for strings, frozen string literals enabled
|
|
14
67
|
- Classes in `NvimContext` module with descriptive names
|
|
15
68
|
- Private constants at class bottom with `private_constant`
|
|
16
69
|
- Error handling with custom error classes in `errors.rb`
|
|
17
|
-
- Use `attr_reader` for private
|
|
18
|
-
- RSpec with expect syntax,
|
|
70
|
+
- Use `attr_reader` for private instance variables
|
|
71
|
+
- RSpec with expect syntax, monkey patching disabled
|
|
72
|
+
- Follow Rubocop rules in `.rubocop.yml`
|
|
73
|
+
|
|
74
|
+
## Testing
|
|
75
|
+
- Unit tests mock the Neovim client
|
|
76
|
+
- Integration tests require a running Neovim instance with socket
|
|
77
|
+
- Test files mirror lib structure: `spec/lib/nvim_context/`
|
|
78
|
+
|
|
79
|
+
## Integration examples
|
|
80
|
+
The gem is designed for use with agentic coding tools like Claude Code,
|
|
81
|
+
OpenCode, Amp Code, Codex, and Gemini. See README.md for integration examples
|
|
82
|
+
including Claude Code skill configuration and OpenCode custom tool setup.
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
AGENTS.md
|
data/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# `nvim-context`
|
|
2
2
|

|
|
3
3
|
[](https://badge.fury.io/rb/nvim-context)
|
|
4
|
+
|
|
4
5
|
`nvim-context` is a bridge between running Neovim instances and agentic coding
|
|
5
6
|
tools. It extracts context from the editor via a Unix socket connection and
|
|
6
7
|
outputs JSON with the cursor position, current file, visual selection and
|
|
@@ -10,6 +11,7 @@ It allows agentic coding tools running outside Neovim to answer questions such
|
|
|
10
11
|
as:
|
|
11
12
|
- What does this line do?
|
|
12
13
|
- Can you convert the current line to uppercase?
|
|
14
|
+
- What does the method under my cursor do?
|
|
13
15
|
- Are these lines idiomatic Ruby?
|
|
14
16
|
|
|
15
17
|
## Motivation
|
|
@@ -17,10 +19,10 @@ While the Neovim community provides several plugins for integrating agentic
|
|
|
17
19
|
coding assistants into the editor (see the [AI section in the Awesome Neovim
|
|
18
20
|
repository](https://github.com/rockerboo/awesome-neovim?tab=readme-ov-file#ai)),
|
|
19
21
|
it seems that few tools offer a way to let any agentic coding tool running
|
|
20
|
-
*outside* Neovim retrieve the state in an agnostic manner.
|
|
22
|
+
*outside* Neovim retrieve the state of the editor in an agnostic manner.
|
|
21
23
|
|
|
22
|
-
The goal with `nvim-context` is to separate concerns, so
|
|
23
|
-
Codex,
|
|
24
|
+
The goal with `nvim-context` is to separate concerns, so Amp Code, Claude Code,
|
|
25
|
+
Codex, etc., can query the current state of a Neovim session by calling
|
|
24
26
|
this tool. See the [Integration with agentic
|
|
25
27
|
tools](#integration-with-agentic-tools) section below for suggestions on how to
|
|
26
28
|
set this up.
|
|
@@ -49,10 +51,6 @@ nvim --listen $NVIM_CONTEXT_SOCKET
|
|
|
49
51
|
If no environment variable is set, the tool defaults to `nvim-context.sock` in
|
|
50
52
|
the current directory.
|
|
51
53
|
|
|
52
|
-
> [!NOTE]
|
|
53
|
-
> To avoid cluttering your Git repository, consider adding `nvim-context.sock`
|
|
54
|
-
> to your `.gitignore` file.
|
|
55
|
-
|
|
56
54
|
## Usage
|
|
57
55
|
Once Neovim is running, you can retrieve the current context by running
|
|
58
56
|
`nvim-context`.
|
|
@@ -71,94 +69,43 @@ selection (if any), and diagnostics in this format:
|
|
|
71
69
|
"diagnostics": []
|
|
72
70
|
}
|
|
73
71
|
```
|
|
74
|
-
```
|
|
75
72
|
|
|
76
73
|
### Integration with agentic tools
|
|
77
74
|
#### Amp Code
|
|
75
|
+
```sh
|
|
76
|
+
amp skill add majjoha/nvim-context/nvim-context
|
|
77
|
+
```
|
|
78
78
|
|
|
79
79
|
#### Claude Code
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
name: nvim-context
|
|
85
|
-
description: Get the current Neovim context as JSON (cursor position, current
|
|
86
|
-
file, visual selection and diagnostics) to help answer questions about code at
|
|
87
|
-
the current cursor position, visual selections and diagnostics. Use when users
|
|
88
|
-
ask about "this line", "current file", "selection" or need context about their
|
|
89
|
-
Neovim editor state.
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
# Neovim context provider
|
|
93
|
-
## Purpose
|
|
94
|
-
Provides live context from the user's Neovim editor session to help answer
|
|
95
|
-
context-aware questions about code.
|
|
96
|
-
|
|
97
|
-
## How it works
|
|
98
|
-
1. Executes the `nvim-context` tool to get the current editor state.
|
|
99
|
-
2. Returns JSON data including cursor position, open file, visual selection and
|
|
100
|
-
diagnostics.
|
|
101
|
-
3. Use this information to understand references like "this line", "the
|
|
102
|
-
selection", "current file", etc.
|
|
80
|
+
```sh
|
|
81
|
+
# Add the repository as a marketplace
|
|
82
|
+
/plugin marketplace add majjoha/nvim-context
|
|
103
83
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
- "What file am I in?" → Return current file path
|
|
108
|
-
- "Show me all errors" → List all LSP diagnostics
|
|
84
|
+
# Install the plugin
|
|
85
|
+
/plugin install nvim-context@nvim-context
|
|
86
|
+
```
|
|
109
87
|
|
|
110
|
-
|
|
111
|
-
|
|
88
|
+
The plugin provides the `nvim-context` skill which gives Claude Code access to
|
|
89
|
+
your live Neovim editor state.
|
|
112
90
|
|
|
113
|
-
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
"cursor": {
|
|
117
|
-
"line": 43,
|
|
118
|
-
"col": 3
|
|
119
|
-
},
|
|
120
|
-
"file": "/path/to/current/file.rb",
|
|
121
|
-
"selection": null,
|
|
122
|
-
"diagnostics": []
|
|
123
|
-
}
|
|
124
|
-
```
|
|
91
|
+
#### Codex
|
|
92
|
+
```sh
|
|
93
|
+
$skill-installer install https://github.com/majjoha/nvim-context/tree/main/.codex/skills/nvim-context
|
|
125
94
|
```
|
|
126
|
-
</details>
|
|
127
|
-
|
|
128
|
-
### Codex
|
|
129
|
-
TBD.
|
|
130
95
|
|
|
131
96
|
#### Gemini
|
|
132
97
|
TBD.
|
|
133
98
|
|
|
134
99
|
#### OpenCode
|
|
135
|
-
|
|
136
100
|
<details>
|
|
137
|
-
<summary
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
args: {},
|
|
146
|
-
async execute(args) {
|
|
147
|
-
try {
|
|
148
|
-
const output = execSync(
|
|
149
|
-
"/Users/mathias/Dropbox/Kode/Ruby/nvim-context/bin/nvim-context",
|
|
150
|
-
{
|
|
151
|
-
encoding: "utf8",
|
|
152
|
-
timeout: 5000,
|
|
153
|
-
},
|
|
154
|
-
);
|
|
155
|
-
return output.trim();
|
|
156
|
-
} catch (error) {
|
|
157
|
-
return `nvim-context unavailable: ${error.message}`;
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
```
|
|
101
|
+
<summary><code>~/.config/opencode/command/nvim-context.md</code></summary>
|
|
102
|
+
<pre>
|
|
103
|
+
---
|
|
104
|
+
description: Show current Neovim context
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
!`nvim-context`
|
|
108
|
+
</pre>
|
|
162
109
|
</details>
|
|
163
110
|
|
|
164
111
|
## Disclaimer
|
data/lib/nvim_context/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nvim-context
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mathias Jean Johansen
|
|
@@ -23,69 +23,10 @@ dependencies:
|
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: 0.10.0
|
|
26
|
-
- !ruby/object:Gem::Dependency
|
|
27
|
-
name: rspec
|
|
28
|
-
requirement: !ruby/object:Gem::Requirement
|
|
29
|
-
requirements:
|
|
30
|
-
- - "~>"
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: 3.13.0
|
|
33
|
-
type: :development
|
|
34
|
-
prerelease: false
|
|
35
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
-
requirements:
|
|
37
|
-
- - "~>"
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: 3.13.0
|
|
40
|
-
- !ruby/object:Gem::Dependency
|
|
41
|
-
name: rubocop
|
|
42
|
-
requirement: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - "~>"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: 1.81.0
|
|
47
|
-
type: :development
|
|
48
|
-
prerelease: false
|
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: 1.81.0
|
|
54
|
-
- !ruby/object:Gem::Dependency
|
|
55
|
-
name: rubocop-performance
|
|
56
|
-
requirement: !ruby/object:Gem::Requirement
|
|
57
|
-
requirements:
|
|
58
|
-
- - "~>"
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
version: 1.26.0
|
|
61
|
-
type: :development
|
|
62
|
-
prerelease: false
|
|
63
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
-
requirements:
|
|
65
|
-
- - "~>"
|
|
66
|
-
- !ruby/object:Gem::Version
|
|
67
|
-
version: 1.26.0
|
|
68
|
-
- !ruby/object:Gem::Dependency
|
|
69
|
-
name: rubocop-rspec
|
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
|
71
|
-
requirements:
|
|
72
|
-
- - "~>"
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
version: 3.8.0
|
|
75
|
-
type: :development
|
|
76
|
-
prerelease: false
|
|
77
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
-
requirements:
|
|
79
|
-
- - "~>"
|
|
80
|
-
- !ruby/object:Gem::Version
|
|
81
|
-
version: 3.8.0
|
|
82
26
|
description: |
|
|
83
|
-
`nvim-context`
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
assistance by giving agents awareness of your current Neovim editor state,
|
|
87
|
-
supporting questions like "What does this line do?" or analysis of selected
|
|
88
|
-
code.
|
|
27
|
+
`nvim-context` has been renamed to `nvim-control`. This final release
|
|
28
|
+
exists only to point users at the new gem. Install `nvim-control`
|
|
29
|
+
instead. See https://github.com/majjoha/nvim-control.
|
|
89
30
|
email: mathias@mjj.io
|
|
90
31
|
executables:
|
|
91
32
|
- nvim-context
|
|
@@ -104,14 +45,17 @@ files:
|
|
|
104
45
|
- lib/nvim_context/errors.rb
|
|
105
46
|
- lib/nvim_context/fetcher.rb
|
|
106
47
|
- lib/nvim_context/version.rb
|
|
107
|
-
homepage: https://github.com/majjoha/nvim-
|
|
48
|
+
homepage: https://github.com/majjoha/nvim-control
|
|
108
49
|
licenses:
|
|
109
50
|
- ISC
|
|
110
51
|
metadata:
|
|
111
52
|
rubygems_mfa_required: 'true'
|
|
112
|
-
source_code_uri: https://github.com/majjoha/nvim-
|
|
113
|
-
|
|
114
|
-
|
|
53
|
+
source_code_uri: https://github.com/majjoha/nvim-control
|
|
54
|
+
bug_tracker_uri: https://github.com/majjoha/nvim-control/issues
|
|
55
|
+
post_install_message: |
|
|
56
|
+
nvim-context has been renamed to nvim-control.
|
|
57
|
+
Please switch: gem install nvim-control
|
|
58
|
+
See https://github.com/majjoha/nvim-control
|
|
115
59
|
rdoc_options: []
|
|
116
60
|
require_paths:
|
|
117
61
|
- lib
|
|
@@ -128,5 +72,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
128
72
|
requirements: []
|
|
129
73
|
rubygems_version: 3.6.9
|
|
130
74
|
specification_version: 4
|
|
131
|
-
summary:
|
|
75
|
+
summary: 'DEPRECATED: renamed to nvim-control.'
|
|
132
76
|
test_files: []
|
data/CLAUDE.md
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to Claude Code (claude.ai/code) when working with
|
|
4
|
-
code in this repository.
|
|
5
|
-
|
|
6
|
-
## Commands
|
|
7
|
-
- **Test all**: `bundle exec rspec`
|
|
8
|
-
- **Test unit**: `bundle exec rspec --exclude-pattern "spec/integration/*"`
|
|
9
|
-
- **Test integration**: `bundle exec rspec spec/integration/`
|
|
10
|
-
- **Test single file**: `bundle exec rspec path/to/spec.rb`
|
|
11
|
-
- **Lint**: `bundle exec rubocop`
|
|
12
|
-
- **Run tool**: `bin/nvim-context`
|
|
13
|
-
|
|
14
|
-
## Architecture
|
|
15
|
-
This gem extracts context from a running Neovim instance via Unix socket
|
|
16
|
-
connection. It outputs JSON with cursor position, current file, visual
|
|
17
|
-
selection, and LSP diagnostics.
|
|
18
|
-
|
|
19
|
-
### Core Components
|
|
20
|
-
- `Connector` - Manages Neovim socket connection using the `neovim` gem. Uses
|
|
21
|
-
`NVIM_CONTEXT_SOCKET` env var or defaults to `nvim-context.sock`
|
|
22
|
-
- `Fetcher` - Entry point that orchestrates data extraction and returns JSON.
|
|
23
|
-
Handles all error types and formats error responses
|
|
24
|
-
- `DataExtractor` - Static methods to extract cursor, file, selection, and
|
|
25
|
-
diagnostics from Neovim client
|
|
26
|
-
|
|
27
|
-
### Error Handling
|
|
28
|
-
Custom errors in `errors.rb`: `ConnectionError` (socket failures) and
|
|
29
|
-
`ContextError` (Neovim operation failures). Fetcher catches all errors and
|
|
30
|
-
returns JSON error objects.
|
|
31
|
-
|
|
32
|
-
## Code Style
|
|
33
|
-
- Ruby 3.4, line length max 80 chars
|
|
34
|
-
- Double quotes for strings, frozen string literals not enforced by Rubocop
|
|
35
|
-
- Classes in `NvimContext` module
|
|
36
|
-
- Private constants at class bottom with `private_constant`
|
|
37
|
-
- Use `attr_reader` for private attributes
|
|
38
|
-
- RSpec with expect syntax, monkey patching disabled
|