feat: rename everything
This commit is contained in:
parent
8f7442eaa2
commit
67116f38bc
16 changed files with 172 additions and 165 deletions
17
.github/DISCUSSION_TEMPLATE/q-a.yml
vendored
Normal file
17
.github/DISCUSSION_TEMPLATE/q-a.yml
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
title: "Q&A"
|
||||||
|
labels: []
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Use this space for questions, ideas, and general discussion about diffs.nvim.
|
||||||
|
For bug reports, please [open an issue](https://github.com/barrettruth/diffs.nvim/issues/new/choose) instead.
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Question or topic
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Context
|
||||||
|
description: Any relevant details (Neovim version, config, screenshots)
|
||||||
6
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
6
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
|
|
@ -7,7 +7,7 @@ body:
|
||||||
attributes:
|
attributes:
|
||||||
label: Prerequisites
|
label: Prerequisites
|
||||||
options:
|
options:
|
||||||
- label: I have searched [existing issues](https://github.com/barrettruth/fugitive-ts.nvim/issues)
|
- label: I have searched [existing issues](https://github.com/barrettruth/diffs.nvim/issues)
|
||||||
required: true
|
required: true
|
||||||
- label: I have updated to the latest version
|
- label: I have updated to the latest version
|
||||||
required: true
|
required: true
|
||||||
|
|
@ -48,7 +48,7 @@ body:
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: "Health check"
|
label: "Health check"
|
||||||
description: "Output of `:checkhealth fugitive-ts`"
|
description: "Output of `:checkhealth diffs`"
|
||||||
render: text
|
render: text
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|
@ -68,7 +68,7 @@ body:
|
||||||
spec = {
|
spec = {
|
||||||
'tpope/vim-fugitive',
|
'tpope/vim-fugitive',
|
||||||
{
|
{
|
||||||
'barrettruth/fugitive-ts.nvim',
|
'barrettruth/diffs.nvim',
|
||||||
opts = {},
|
opts = {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
2
.github/ISSUE_TEMPLATE/config.yml
vendored
2
.github/ISSUE_TEMPLATE/config.yml
vendored
|
|
@ -1,5 +1,5 @@
|
||||||
blank_issues_enabled: false
|
blank_issues_enabled: false
|
||||||
contact_links:
|
contact_links:
|
||||||
- name: Questions
|
- name: Questions
|
||||||
url: https://github.com/barrettruth/fugitive-ts.nvim/discussions
|
url: https://github.com/barrettruth/diffs.nvim/discussions
|
||||||
about: Ask questions and discuss ideas
|
about: Ask questions and discuss ideas
|
||||||
|
|
|
||||||
2
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
2
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
|
|
@ -7,7 +7,7 @@ body:
|
||||||
attributes:
|
attributes:
|
||||||
label: Prerequisites
|
label: Prerequisites
|
||||||
options:
|
options:
|
||||||
- label: I have searched [existing issues](https://github.com/barrettruth/fugitive-ts.nvim/issues)
|
- label: I have searched [existing issues](https://github.com/barrettruth/diffs.nvim/issues)
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|
|
||||||
25
README.md
25
README.md
|
|
@ -1,16 +1,17 @@
|
||||||
# fugitive-ts.nvim
|
# diffs.nvim
|
||||||
|
|
||||||
**Treesitter syntax highlighting for vim-fugitive**
|
**Syntax highlighting for diffs in Neovim**
|
||||||
|
|
||||||
Enhance the great `vim-fugitive` with syntax-aware code to easily work with
|
Enhance vim-fugitive and Neovim's built-in diff mode with language-aware syntax
|
||||||
diffs.
|
highlighting.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Treesitter syntax highlighting in `:Git` diffs and commit views
|
- Treesitter syntax highlighting in `:Git` diffs and commit views
|
||||||
- `:Gdiffsplit` / `:Gvdiffsplit` syntax through diff backgrounds
|
- `:Gdiffsplit` / `:Gvdiffsplit` syntax through diff backgrounds
|
||||||
|
- Background-only diff colors for any `&diff` buffer
|
||||||
- Vim syntax fallback for languages without a treesitter parser
|
- Vim syntax fallback for languages without a treesitter parser
|
||||||
- Hunk header context highlighting (`@@ ... @@ function foo()`)
|
- Hunk header context highlighting (`@@ ... @@ function foo()`)
|
||||||
- Configurable debouncing, max lines, and diff prefix concealment
|
- Configurable debouncing, max lines, and diff prefix concealment
|
||||||
|
|
@ -26,7 +27,7 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim):
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
'barrettruth/fugitive-ts.nvim',
|
'barrettruth/diffs.nvim',
|
||||||
dependencies = { 'tpope/vim-fugitive' },
|
dependencies = { 'tpope/vim-fugitive' },
|
||||||
opts = {},
|
opts = {},
|
||||||
}
|
}
|
||||||
|
|
@ -35,20 +36,18 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim):
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
:help fugitive-ts.nvim
|
:help diffs.nvim
|
||||||
```
|
```
|
||||||
|
|
||||||
## Known Limitations
|
## Known Limitations
|
||||||
|
|
||||||
- Syntax "flashing": `fugitive-ts.nvim` hooks into the `FileType fugitive` event
|
- Syntax "flashing": diffs.nvim hooks into the `FileType fugitive` event
|
||||||
triggered by `vim-fugitive`, at which point the `fugitive` buffer is
|
triggered by vim-fugitive, at which point the buffer is preliminarily painted.
|
||||||
preliminarily painted. The buffer is then re-painted after `debounce_ms`
|
The buffer is then re-painted after `debounce_ms` milliseconds, causing an
|
||||||
milliseconds, causing an unavoidable visual "flash" even when
|
unavoidable visual "flash" even when `debounce_ms = 0`.
|
||||||
`debounce_ms = 0`. Feel free to reach out if you know how to fix this!
|
|
||||||
|
|
||||||
## Acknowledgements
|
## Acknowledgements
|
||||||
|
|
||||||
- [vim-fugitive](https://github.com/tpope/vim-fugitive)
|
- [vim-fugitive](https://github.com/tpope/vim-fugitive)
|
||||||
- [codediff.nvim](https://github.com/esmuellert/codediff.nvim)
|
- [codediff.nvim](https://github.com/esmuellert/codediff.nvim)
|
||||||
- [diffview.nvim](https://github.com/sindrets/diffview.nvim)
|
- [diffview.nvim](https://github.com/sindrets/diffview.nvim)
|
||||||
- [resolve.nvim](https://github.com/spacedentist/resolve.nvim)
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
rockspec_format = '3.0'
|
rockspec_format = '3.0'
|
||||||
package = 'fugitive-ts.nvim'
|
package = 'diffs.nvim'
|
||||||
version = 'scm-1'
|
version = 'scm-1'
|
||||||
|
|
||||||
source = {
|
source = {
|
||||||
url = 'git+https://github.com/barrettruth/fugitive-ts.nvim.git',
|
url = 'git+https://github.com/barrettruth/diffs.nvim.git',
|
||||||
}
|
}
|
||||||
|
|
||||||
description = {
|
description = {
|
||||||
summary = 'Treesitter syntax highlighting for vim-fugitive',
|
summary = 'Syntax highlighting for diffs in Neovim',
|
||||||
homepage = 'https://github.com/barrettruth/fugitive-ts.nvim',
|
homepage = 'https://github.com/barrettruth/diffs.nvim',
|
||||||
license = 'MIT',
|
license = 'MIT',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,54 +1,55 @@
|
||||||
*fugitive-ts.nvim.txt* Treesitter highlighting for vim-fugitive diffs
|
*diffs.nvim.txt* Syntax highlighting for diffs in Neovim
|
||||||
|
|
||||||
Author: Barrett Ruth <br.barrettruth@gmail.com>
|
Author: Barrett Ruth <br.barrettruth@gmail.com>
|
||||||
License: MIT
|
License: MIT
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
INTRODUCTION *fugitive-ts.nvim*
|
INTRODUCTION *diffs.nvim*
|
||||||
|
|
||||||
fugitive-ts.nvim adds treesitter-based syntax highlighting to vim-fugitive
|
diffs.nvim adds syntax highlighting to diff views. It overlays language-aware
|
||||||
diff views. It overlays language-aware highlights on top of fugitive's
|
highlights on top of default diff highlighting in vim-fugitive and Neovim's
|
||||||
default regex-based diff highlighting.
|
built-in diff mode.
|
||||||
|
|
||||||
Features: ~
|
Features: ~
|
||||||
- Syntax highlighting in |:Git| summary diffs and commit detail views
|
- Syntax highlighting in |:Git| summary diffs and commit detail views
|
||||||
- Syntax highlighting in |:Gdiffsplit| / |:Gvdiffsplit| side-by-side diffs
|
- Syntax highlighting in |:Gdiffsplit| / |:Gvdiffsplit| side-by-side diffs
|
||||||
|
- Background-only diff colors for any `&diff` buffer (vimdiff, diffthis, etc.)
|
||||||
- Vim syntax fallback for languages without a treesitter parser
|
- Vim syntax fallback for languages without a treesitter parser
|
||||||
- Blended diff background colors that preserve syntax visibility
|
- Blended diff background colors that preserve syntax visibility
|
||||||
- Optional diff prefix (`+`/`-`/` `) concealment
|
- Optional diff prefix (`+`/`-`/` `) concealment
|
||||||
- Gutter (line number) highlighting
|
- Gutter (line number) highlighting
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
REQUIREMENTS *fugitive-ts-requirements*
|
REQUIREMENTS *diffs-requirements*
|
||||||
|
|
||||||
- Neovim 0.9.0+
|
- Neovim 0.9.0+
|
||||||
- vim-fugitive (https://github.com/tpope/vim-fugitive)
|
- vim-fugitive (https://github.com/tpope/vim-fugitive) for unified diff views
|
||||||
- Treesitter parsers for languages you want highlighted
|
- Treesitter parsers for languages you want highlighted
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
SETUP *fugitive-ts-setup*
|
SETUP *diffs-setup*
|
||||||
|
|
||||||
Using lazy.nvim: >lua
|
Using lazy.nvim: >lua
|
||||||
{
|
{
|
||||||
'barrettruth/fugitive-ts.nvim',
|
'barrettruth/diffs.nvim',
|
||||||
dependencies = { 'tpope/vim-fugitive' },
|
dependencies = { 'tpope/vim-fugitive' },
|
||||||
opts = {},
|
opts = {},
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
The plugin works automatically with no configuration required. For
|
The plugin works automatically with no configuration required. For
|
||||||
customization, see |fugitive-ts-config|.
|
customization, see |diffs-config|.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
CONFIGURATION *fugitive-ts-config*
|
CONFIGURATION *diffs-config*
|
||||||
|
|
||||||
*fugitive-ts.Config*
|
*diffs.Config*
|
||||||
Fields: ~
|
Fields: ~
|
||||||
{enabled} (boolean, default: true)
|
{enabled} (boolean, default: true)
|
||||||
Enable or disable highlighting globally.
|
Enable or disable highlighting globally.
|
||||||
|
|
||||||
{debug} (boolean, default: false)
|
{debug} (boolean, default: false)
|
||||||
Enable debug logging to |:messages| with
|
Enable debug logging to |:messages| with
|
||||||
`[fugitive-ts]` prefix.
|
`[diffs]` prefix.
|
||||||
|
|
||||||
{debounce_ms} (integer, default: 0)
|
{debounce_ms} (integer, default: 0)
|
||||||
Debounce delay in milliseconds for re-highlighting
|
Debounce delay in milliseconds for re-highlighting
|
||||||
|
|
@ -64,17 +65,17 @@ CONFIGURATION *fugitive-ts-config*
|
||||||
|
|
||||||
{treesitter} (table, default: see below)
|
{treesitter} (table, default: see below)
|
||||||
Treesitter highlighting options.
|
Treesitter highlighting options.
|
||||||
See |fugitive-ts.TreesitterConfig| for fields.
|
See |diffs.TreesitterConfig| for fields.
|
||||||
|
|
||||||
{vim} (table, default: see below)
|
{vim} (table, default: see below)
|
||||||
Vim syntax highlighting options (experimental).
|
Vim syntax highlighting options (experimental).
|
||||||
See |fugitive-ts.VimConfig| for fields.
|
See |diffs.VimConfig| for fields.
|
||||||
|
|
||||||
{highlights} (table, default: see below)
|
{highlights} (table, default: see below)
|
||||||
Controls which highlight features are enabled.
|
Controls which highlight features are enabled.
|
||||||
See |fugitive-ts.Highlights| for fields.
|
See |diffs.Highlights| for fields.
|
||||||
|
|
||||||
*fugitive-ts.TreesitterConfig*
|
*diffs.TreesitterConfig*
|
||||||
Treesitter config fields: ~
|
Treesitter config fields: ~
|
||||||
{enabled} (boolean, default: true)
|
{enabled} (boolean, default: true)
|
||||||
Apply treesitter syntax highlighting to code.
|
Apply treesitter syntax highlighting to code.
|
||||||
|
|
@ -83,7 +84,7 @@ CONFIGURATION *fugitive-ts-config*
|
||||||
Skip treesitter highlighting for hunks larger than
|
Skip treesitter highlighting for hunks larger than
|
||||||
this many lines. Prevents lag on massive diffs.
|
this many lines. Prevents lag on massive diffs.
|
||||||
|
|
||||||
*fugitive-ts.VimConfig*
|
*diffs.VimConfig*
|
||||||
Vim config fields: ~
|
Vim config fields: ~
|
||||||
{enabled} (boolean, default: false)
|
{enabled} (boolean, default: false)
|
||||||
Use vim syntax highlighting as fallback when no
|
Use vim syntax highlighting as fallback when no
|
||||||
|
|
@ -98,12 +99,12 @@ CONFIGURATION *fugitive-ts-config*
|
||||||
this many lines. Lower than the treesitter default
|
this many lines. Lower than the treesitter default
|
||||||
due to the per-character cost of |synID()|.
|
due to the per-character cost of |synID()|.
|
||||||
|
|
||||||
*fugitive-ts.Highlights*
|
*diffs.Highlights*
|
||||||
Highlights table fields: ~
|
Highlights table fields: ~
|
||||||
{background} (boolean, default: true)
|
{background} (boolean, default: true)
|
||||||
Apply background highlighting to `+`/`-` lines
|
Apply background highlighting to `+`/`-` lines
|
||||||
using `FugitiveTsAdd`/`FugitiveTsDelete` groups
|
using `DiffsAdd`/`DiffsDelete` groups (derived
|
||||||
(derived from `DiffAdd`/`DiffDelete` backgrounds).
|
from `DiffAdd`/`DiffDelete` backgrounds).
|
||||||
|
|
||||||
{gutter} (boolean, default: true)
|
{gutter} (boolean, default: true)
|
||||||
Highlight line numbers with matching colors.
|
Highlight line numbers with matching colors.
|
||||||
|
|
@ -118,22 +119,22 @@ CONFIGURATION *fugitive-ts-config*
|
||||||
|vim.filetype.add()| and |vim.treesitter.language.register()|.
|
|vim.filetype.add()| and |vim.treesitter.language.register()|.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
API *fugitive-ts-api*
|
API *diffs-api*
|
||||||
|
|
||||||
setup({opts}) *fugitive-ts.setup()*
|
setup({opts}) *diffs.setup()*
|
||||||
Configure the plugin with `opts`.
|
Configure the plugin with `opts`.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
{opts} (|fugitive-ts.Config|, optional) Configuration table.
|
{opts} (|diffs.Config|, optional) Configuration table.
|
||||||
|
|
||||||
attach({bufnr}) *fugitive-ts.attach()*
|
attach({bufnr}) *diffs.attach()*
|
||||||
Manually attach highlighting to a buffer. Called automatically for
|
Manually attach highlighting to a buffer. Called automatically for
|
||||||
fugitive buffers via the `FileType fugitive` autocmd.
|
fugitive buffers via the `FileType fugitive` autocmd.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
{bufnr} (integer, optional) Buffer number. Defaults to current buffer.
|
{bufnr} (integer, optional) Buffer number. Defaults to current buffer.
|
||||||
|
|
||||||
refresh({bufnr}) *fugitive-ts.refresh()*
|
refresh({bufnr}) *diffs.refresh()*
|
||||||
Manually refresh highlighting for a buffer. Useful after external changes
|
Manually refresh highlighting for a buffer. Useful after external changes
|
||||||
or for debugging.
|
or for debugging.
|
||||||
|
|
||||||
|
|
@ -141,11 +142,11 @@ refresh({bufnr}) *fugitive-ts.refresh()*
|
||||||
{bufnr} (integer, optional) Buffer number. Defaults to current buffer.
|
{bufnr} (integer, optional) Buffer number. Defaults to current buffer.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
IMPLEMENTATION *fugitive-ts-implementation*
|
IMPLEMENTATION *diffs-implementation*
|
||||||
|
|
||||||
Summary / commit detail views: ~
|
Summary / commit detail views: ~
|
||||||
1. `FileType fugitive` or `FileType git` (for `fugitive://` buffers)
|
1. `FileType fugitive` or `FileType git` (for `fugitive://` buffers)
|
||||||
triggers |fugitive-ts.attach()|
|
triggers |diffs.attach()|
|
||||||
2. The buffer is parsed to detect file headers (`M path/to/file`,
|
2. The buffer is parsed to detect file headers (`M path/to/file`,
|
||||||
`diff --git a/... b/...`) and hunk headers (`@@ -10,3 +10,4 @@`)
|
`diff --git a/... b/...`) and hunk headers (`@@ -10,3 +10,4 @@`)
|
||||||
3. For each hunk:
|
3. For each hunk:
|
||||||
|
|
@ -154,45 +155,42 @@ Summary / commit detail views: ~
|
||||||
- Code is parsed with |vim.treesitter.get_string_parser()|
|
- Code is parsed with |vim.treesitter.get_string_parser()|
|
||||||
- If no treesitter parser and `vim.enabled`: vim syntax fallback via
|
- If no treesitter parser and `vim.enabled`: vim syntax fallback via
|
||||||
scratch buffer and |synID()|
|
scratch buffer and |synID()|
|
||||||
- Background extmarks (`FugitiveTsAdd`/`FugitiveTsDelete`) at priority 198
|
- Background extmarks (`DiffsAdd`/`DiffsDelete`) at priority 198
|
||||||
- `Normal` extmarks at priority 199 clear underlying diff foreground
|
- `Normal` extmarks at priority 199 clear underlying diff foreground
|
||||||
- Syntax highlights are applied as extmarks at priority 200
|
- Syntax highlights are applied as extmarks at priority 200
|
||||||
- Conceal extmarks hide diff prefixes when `hide_prefix` is enabled
|
- Conceal extmarks hide diff prefixes when `hide_prefix` is enabled
|
||||||
4. Re-highlighting occurs on `TextChanged` (debounced) and `Syntax` events
|
4. Re-highlighting occurs on `TextChanged` (debounced) and `Syntax` events
|
||||||
|
|
||||||
Diffsplit views: ~
|
Diff mode views: ~
|
||||||
1. `OptionSet diff` detects when a window enters diff mode
|
1. `OptionSet diff` detects when any window enters diff mode
|
||||||
2. If any `&diff` window in the tabpage contains a `fugitive://` buffer,
|
2. All `&diff` windows in the tabpage receive a window-local 'winhighlight'
|
||||||
all `&diff` windows receive a window-local 'winhighlight' override
|
override that remaps `DiffAdd`/`DiffDelete`/`DiffChange`/`DiffText` to
|
||||||
3. The override remaps `DiffAdd`/`DiffDelete`/`DiffChange`/`DiffText` to
|
|
||||||
background-only variants, allowing existing treesitter highlighting to
|
background-only variants, allowing existing treesitter highlighting to
|
||||||
show through the diff colors
|
show through the diff colors
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
KNOWN LIMITATIONS *fugitive-ts-limitations*
|
KNOWN LIMITATIONS *diffs-limitations*
|
||||||
|
|
||||||
Syntax Highlighting Flash ~
|
Syntax Highlighting Flash ~
|
||||||
*fugitive-ts-flash*
|
*diffs-flash*
|
||||||
When opening a fugitive buffer, there is an unavoidable visual "flash" where
|
When opening a fugitive buffer, there is an unavoidable visual "flash" where
|
||||||
the buffer briefly shows fugitive's default diff highlighting before
|
the buffer briefly shows fugitive's default diff highlighting before
|
||||||
fugitive-ts.nvim applies treesitter highlights.
|
diffs.nvim applies treesitter highlights.
|
||||||
|
|
||||||
This occurs because fugitive-ts.nvim hooks into the `FileType fugitive` event,
|
This occurs because diffs.nvim hooks into the `FileType fugitive` event,
|
||||||
which fires after vim-fugitive has already painted the buffer. Even with
|
which fires after vim-fugitive has already painted the buffer. Even with
|
||||||
`debounce_ms = 0`, the re-painting goes through Neovim's event loop.
|
`debounce_ms = 0`, the re-painting goes through Neovim's event loop.
|
||||||
|
|
||||||
To minimize the flash, use a low debounce value: >lua
|
To minimize the flash, use a low debounce value: >lua
|
||||||
require('fugitive-ts').setup({
|
require('diffs').setup({
|
||||||
debounce_ms = 0,
|
debounce_ms = 0,
|
||||||
})
|
})
|
||||||
<
|
<
|
||||||
See https://github.com/barrettruth/fugitive-ts.nvim/issues/18 for discussion
|
|
||||||
and potential solutions.
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
HEALTH CHECK *fugitive-ts-health*
|
HEALTH CHECK *diffs-health*
|
||||||
|
|
||||||
Run |:checkhealth| fugitive-ts to verify your setup.
|
Run |:checkhealth| diffs to verify your setup.
|
||||||
|
|
||||||
Checks performed:
|
Checks performed:
|
||||||
- Neovim version >= 0.9.0
|
- Neovim version >= 0.9.0
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.check()
|
function M.check()
|
||||||
vim.health.start('fugitive-ts.nvim')
|
vim.health.start('diffs.nvim')
|
||||||
|
|
||||||
if vim.fn.has('nvim-0.9.0') == 1 then
|
if vim.fn.has('nvim-0.9.0') == 1 then
|
||||||
vim.health.ok('Neovim 0.9.0+ detected')
|
vim.health.ok('Neovim 0.9.0+ detected')
|
||||||
else
|
else
|
||||||
vim.health.error('fugitive-ts.nvim requires Neovim 0.9.0+')
|
vim.health.error('diffs.nvim requires Neovim 0.9.0+')
|
||||||
end
|
end
|
||||||
|
|
||||||
local fugitive_loaded = vim.fn.exists(':Git') == 2
|
local fugitive_loaded = vim.fn.exists(':Git') == 2
|
||||||
if fugitive_loaded then
|
if fugitive_loaded then
|
||||||
vim.health.ok('vim-fugitive detected')
|
vim.health.ok('vim-fugitive detected')
|
||||||
else
|
else
|
||||||
vim.health.warn('vim-fugitive not detected (required for this plugin to be useful)')
|
vim.health.warn('vim-fugitive not detected (required for unified diff highlighting)')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local dbg = require('fugitive-ts.log').dbg
|
local dbg = require('diffs.log').dbg
|
||||||
|
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@param ns integer
|
---@param ns integer
|
||||||
---@param hunk fugitive-ts.Hunk
|
---@param hunk diffs.Hunk
|
||||||
---@param col_offset integer
|
---@param col_offset integer
|
||||||
---@param text string
|
---@param text string
|
||||||
---@param lang string
|
---@param lang string
|
||||||
|
|
@ -49,15 +49,15 @@ local function highlight_text(bufnr, ns, hunk, col_offset, text, lang)
|
||||||
return extmark_count
|
return extmark_count
|
||||||
end
|
end
|
||||||
|
|
||||||
---@class fugitive-ts.HunkOpts
|
---@class diffs.HunkOpts
|
||||||
---@field hide_prefix boolean
|
---@field hide_prefix boolean
|
||||||
---@field treesitter fugitive-ts.TreesitterConfig
|
---@field treesitter diffs.TreesitterConfig
|
||||||
---@field vim fugitive-ts.VimConfig
|
---@field vim diffs.VimConfig
|
||||||
---@field highlights fugitive-ts.Highlights
|
---@field highlights diffs.Highlights
|
||||||
|
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@param ns integer
|
---@param ns integer
|
||||||
---@param hunk fugitive-ts.Hunk
|
---@param hunk diffs.Hunk
|
||||||
---@param code_lines string[]
|
---@param code_lines string[]
|
||||||
---@return integer
|
---@return integer
|
||||||
local function highlight_treesitter(bufnr, ns, hunk, code_lines)
|
local function highlight_treesitter(bufnr, ns, hunk, code_lines)
|
||||||
|
|
@ -125,9 +125,9 @@ local function highlight_treesitter(bufnr, ns, hunk, code_lines)
|
||||||
return extmark_count
|
return extmark_count
|
||||||
end
|
end
|
||||||
|
|
||||||
---@alias fugitive-ts.SyntaxQueryFn fun(line: integer, col: integer): integer, string
|
---@alias diffs.SyntaxQueryFn fun(line: integer, col: integer): integer, string
|
||||||
|
|
||||||
---@param query_fn fugitive-ts.SyntaxQueryFn
|
---@param query_fn diffs.SyntaxQueryFn
|
||||||
---@param code_lines string[]
|
---@param code_lines string[]
|
||||||
---@return {line: integer, col_start: integer, col_end: integer, hl_name: string}[]
|
---@return {line: integer, col_start: integer, col_end: integer, hl_name: string}[]
|
||||||
function M.coalesce_syntax_spans(query_fn, code_lines)
|
function M.coalesce_syntax_spans(query_fn, code_lines)
|
||||||
|
|
@ -168,7 +168,7 @@ end
|
||||||
|
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@param ns integer
|
---@param ns integer
|
||||||
---@param hunk fugitive-ts.Hunk
|
---@param hunk diffs.Hunk
|
||||||
---@param code_lines string[]
|
---@param code_lines string[]
|
||||||
---@return integer
|
---@return integer
|
||||||
local function highlight_vim_syntax(bufnr, ns, hunk, code_lines)
|
local function highlight_vim_syntax(bufnr, ns, hunk, code_lines)
|
||||||
|
|
@ -223,8 +223,8 @@ end
|
||||||
|
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@param ns integer
|
---@param ns integer
|
||||||
---@param hunk fugitive-ts.Hunk
|
---@param hunk diffs.Hunk
|
||||||
---@param opts fugitive-ts.HunkOpts
|
---@param opts diffs.HunkOpts
|
||||||
function M.highlight_hunk(bufnr, ns, hunk, opts)
|
function M.highlight_hunk(bufnr, ns, hunk, opts)
|
||||||
local use_ts = hunk.lang and opts.treesitter.enabled
|
local use_ts = hunk.lang and opts.treesitter.enabled
|
||||||
local use_vim = not use_ts and hunk.ft and opts.vim.enabled
|
local use_vim = not use_ts and hunk.ft and opts.vim.enabled
|
||||||
|
|
@ -267,10 +267,8 @@ function M.highlight_hunk(bufnr, ns, hunk, opts)
|
||||||
local prefix = line:sub(1, 1)
|
local prefix = line:sub(1, 1)
|
||||||
|
|
||||||
local is_diff_line = prefix == '+' or prefix == '-'
|
local is_diff_line = prefix == '+' or prefix == '-'
|
||||||
local line_hl = is_diff_line and (prefix == '+' and 'FugitiveTsAdd' or 'FugitiveTsDelete')
|
local line_hl = is_diff_line and (prefix == '+' and 'DiffsAdd' or 'DiffsDelete') or nil
|
||||||
or nil
|
local number_hl = is_diff_line and (prefix == '+' and 'DiffsAddNr' or 'DiffsDeleteNr') or nil
|
||||||
local number_hl = is_diff_line and (prefix == '+' and 'FugitiveTsAddNr' or 'FugitiveTsDeleteNr')
|
|
||||||
or nil
|
|
||||||
|
|
||||||
if opts.hide_prefix then
|
if opts.hide_prefix then
|
||||||
local virt_hl = (opts.highlights.background and line_hl) or nil
|
local virt_hl = (opts.highlights.background and line_hl) or nil
|
||||||
|
|
@ -1,35 +1,35 @@
|
||||||
---@class fugitive-ts.Highlights
|
---@class diffs.Highlights
|
||||||
---@field background boolean
|
---@field background boolean
|
||||||
---@field gutter boolean
|
---@field gutter boolean
|
||||||
|
|
||||||
---@class fugitive-ts.TreesitterConfig
|
---@class diffs.TreesitterConfig
|
||||||
---@field enabled boolean
|
---@field enabled boolean
|
||||||
---@field max_lines integer
|
---@field max_lines integer
|
||||||
|
|
||||||
---@class fugitive-ts.VimConfig
|
---@class diffs.VimConfig
|
||||||
---@field enabled boolean
|
---@field enabled boolean
|
||||||
---@field max_lines integer
|
---@field max_lines integer
|
||||||
|
|
||||||
---@class fugitive-ts.Config
|
---@class diffs.Config
|
||||||
---@field enabled boolean
|
---@field enabled boolean
|
||||||
---@field debug boolean
|
---@field debug boolean
|
||||||
---@field debounce_ms integer
|
---@field debounce_ms integer
|
||||||
---@field hide_prefix boolean
|
---@field hide_prefix boolean
|
||||||
---@field treesitter fugitive-ts.TreesitterConfig
|
---@field treesitter diffs.TreesitterConfig
|
||||||
---@field vim fugitive-ts.VimConfig
|
---@field vim diffs.VimConfig
|
||||||
---@field highlights fugitive-ts.Highlights
|
---@field highlights diffs.Highlights
|
||||||
|
|
||||||
---@class fugitive-ts
|
---@class diffs
|
||||||
---@field attach fun(bufnr?: integer)
|
---@field attach fun(bufnr?: integer)
|
||||||
---@field refresh fun(bufnr?: integer)
|
---@field refresh fun(bufnr?: integer)
|
||||||
---@field setup fun(opts?: fugitive-ts.Config)
|
---@field setup fun(opts?: diffs.Config)
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local highlight = require('fugitive-ts.highlight')
|
local highlight = require('diffs.highlight')
|
||||||
local log = require('fugitive-ts.log')
|
local log = require('diffs.log')
|
||||||
local parser = require('fugitive-ts.parser')
|
local parser = require('diffs.parser')
|
||||||
|
|
||||||
local ns = vim.api.nvim_create_namespace('fugitive_ts')
|
local ns = vim.api.nvim_create_namespace('diffs')
|
||||||
|
|
||||||
---@param hex integer
|
---@param hex integer
|
||||||
---@param bg_hex integer
|
---@param bg_hex integer
|
||||||
|
|
@ -63,7 +63,7 @@ local function resolve_hl(name)
|
||||||
return hl
|
return hl
|
||||||
end
|
end
|
||||||
|
|
||||||
---@type fugitive-ts.Config
|
---@type diffs.Config
|
||||||
local default_config = {
|
local default_config = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
debug = false,
|
debug = false,
|
||||||
|
|
@ -83,7 +83,7 @@ local default_config = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
---@type fugitive-ts.Config
|
---@type diffs.Config
|
||||||
local config = vim.deepcopy(default_config)
|
local config = vim.deepcopy(default_config)
|
||||||
|
|
||||||
---@type table<integer, boolean>
|
---@type table<integer, boolean>
|
||||||
|
|
@ -220,25 +220,25 @@ local function compute_highlight_groups()
|
||||||
local blended_add = blend_color(add_bg, bg, 0.4)
|
local blended_add = blend_color(add_bg, bg, 0.4)
|
||||||
local blended_del = blend_color(del_bg, bg, 0.4)
|
local blended_del = blend_color(del_bg, bg, 0.4)
|
||||||
|
|
||||||
vim.api.nvim_set_hl(0, 'FugitiveTsAdd', { bg = blended_add })
|
vim.api.nvim_set_hl(0, 'DiffsAdd', { bg = blended_add })
|
||||||
vim.api.nvim_set_hl(0, 'FugitiveTsDelete', { bg = blended_del })
|
vim.api.nvim_set_hl(0, 'DiffsDelete', { bg = blended_del })
|
||||||
vim.api.nvim_set_hl(0, 'FugitiveTsAddNr', { fg = add_fg, bg = blended_add })
|
vim.api.nvim_set_hl(0, 'DiffsAddNr', { fg = add_fg, bg = blended_add })
|
||||||
vim.api.nvim_set_hl(0, 'FugitiveTsDeleteNr', { fg = del_fg, bg = blended_del })
|
vim.api.nvim_set_hl(0, 'DiffsDeleteNr', { fg = del_fg, bg = blended_del })
|
||||||
|
|
||||||
local diff_change = resolve_hl('DiffChange')
|
local diff_change = resolve_hl('DiffChange')
|
||||||
local diff_text = resolve_hl('DiffText')
|
local diff_text = resolve_hl('DiffText')
|
||||||
|
|
||||||
vim.api.nvim_set_hl(0, 'FugitiveTsDiffAdd', { bg = diff_add.bg })
|
vim.api.nvim_set_hl(0, 'DiffsDiffAdd', { bg = diff_add.bg })
|
||||||
vim.api.nvim_set_hl(0, 'FugitiveTsDiffDelete', { bg = diff_delete.bg })
|
vim.api.nvim_set_hl(0, 'DiffsDiffDelete', { bg = diff_delete.bg })
|
||||||
vim.api.nvim_set_hl(0, 'FugitiveTsDiffChange', { bg = diff_change.bg })
|
vim.api.nvim_set_hl(0, 'DiffsDiffChange', { bg = diff_change.bg })
|
||||||
vim.api.nvim_set_hl(0, 'FugitiveTsDiffText', { bg = diff_text.bg })
|
vim.api.nvim_set_hl(0, 'DiffsDiffText', { bg = diff_text.bg })
|
||||||
end
|
end
|
||||||
|
|
||||||
local DIFF_WINHIGHLIGHT = table.concat({
|
local DIFF_WINHIGHLIGHT = table.concat({
|
||||||
'DiffAdd:FugitiveTsDiffAdd',
|
'DiffAdd:DiffsDiffAdd',
|
||||||
'DiffDelete:FugitiveTsDiffDelete',
|
'DiffDelete:DiffsDiffDelete',
|
||||||
'DiffChange:FugitiveTsDiffChange',
|
'DiffChange:DiffsDiffChange',
|
||||||
'DiffText:FugitiveTsDiffText',
|
'DiffText:DiffsDiffText',
|
||||||
}, ',')
|
}, ',')
|
||||||
|
|
||||||
function M.attach_diff()
|
function M.attach_diff()
|
||||||
|
|
@ -249,20 +249,15 @@ function M.attach_diff()
|
||||||
local tabpage = vim.api.nvim_get_current_tabpage()
|
local tabpage = vim.api.nvim_get_current_tabpage()
|
||||||
local wins = vim.api.nvim_tabpage_list_wins(tabpage)
|
local wins = vim.api.nvim_tabpage_list_wins(tabpage)
|
||||||
|
|
||||||
local has_fugitive = false
|
|
||||||
local diff_wins = {}
|
local diff_wins = {}
|
||||||
|
|
||||||
for _, win in ipairs(wins) do
|
for _, win in ipairs(wins) do
|
||||||
if vim.api.nvim_win_is_valid(win) and vim.wo[win].diff then
|
if vim.api.nvim_win_is_valid(win) and vim.wo[win].diff then
|
||||||
table.insert(diff_wins, win)
|
table.insert(diff_wins, win)
|
||||||
local bufnr = vim.api.nvim_win_get_buf(win)
|
|
||||||
if M.is_fugitive_buffer(bufnr) then
|
|
||||||
has_fugitive = true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not has_fugitive then
|
if #diff_wins == 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -282,7 +277,7 @@ function M.detach_diff()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param opts? fugitive-ts.Config
|
---@param opts? diffs.Config
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
|
||||||
|
|
@ -318,13 +313,13 @@ function M.setup(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts.debounce_ms and opts.debounce_ms < 0 then
|
if opts.debounce_ms and opts.debounce_ms < 0 then
|
||||||
error('fugitive-ts: debounce_ms must be >= 0')
|
error('diffs: debounce_ms must be >= 0')
|
||||||
end
|
end
|
||||||
if opts.treesitter and opts.treesitter.max_lines and opts.treesitter.max_lines < 1 then
|
if opts.treesitter and opts.treesitter.max_lines and opts.treesitter.max_lines < 1 then
|
||||||
error('fugitive-ts: treesitter.max_lines must be >= 1')
|
error('diffs: treesitter.max_lines must be >= 1')
|
||||||
end
|
end
|
||||||
if opts.vim and opts.vim.max_lines and opts.vim.max_lines < 1 then
|
if opts.vim and opts.vim.max_lines and opts.vim.max_lines < 1 then
|
||||||
error('fugitive-ts: vim.max_lines must be >= 1')
|
error('diffs: vim.max_lines must be >= 1')
|
||||||
end
|
end
|
||||||
|
|
||||||
config = vim.tbl_deep_extend('force', default_config, opts)
|
config = vim.tbl_deep_extend('force', default_config, opts)
|
||||||
|
|
@ -13,7 +13,7 @@ function M.dbg(msg, ...)
|
||||||
if not enabled then
|
if not enabled then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
vim.notify('[fugitive-ts] ' .. string.format(msg, ...), vim.log.levels.DEBUG)
|
vim.notify('[diffs] ' .. string.format(msg, ...), vim.log.levels.DEBUG)
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
---@class fugitive-ts.Hunk
|
---@class diffs.Hunk
|
||||||
---@field filename string
|
---@field filename string
|
||||||
---@field ft string?
|
---@field ft string?
|
||||||
---@field lang string?
|
---@field lang string?
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local dbg = require('fugitive-ts.log').dbg
|
local dbg = require('diffs.log').dbg
|
||||||
|
|
||||||
---@param filename string
|
---@param filename string
|
||||||
---@return string?
|
---@return string?
|
||||||
|
|
@ -38,10 +38,10 @@ local function get_lang_from_ft(ft)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@return fugitive-ts.Hunk[]
|
---@return diffs.Hunk[]
|
||||||
function M.parse_buffer(bufnr)
|
function M.parse_buffer(bufnr)
|
||||||
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
|
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
|
||||||
---@type fugitive-ts.Hunk[]
|
---@type diffs.Hunk[]
|
||||||
local hunks = {}
|
local hunks = {}
|
||||||
|
|
||||||
---@type string?
|
---@type string?
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
if vim.g.loaded_fugitive_ts then
|
if vim.g.loaded_diffs then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
vim.g.loaded_fugitive_ts = 1
|
vim.g.loaded_diffs = 1
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('FileType', {
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
pattern = { 'fugitive', 'git' },
|
pattern = { 'fugitive', 'git' },
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
local ft = require('fugitive-ts')
|
local diffs = require('diffs')
|
||||||
if args.match == 'git' and not ft.is_fugitive_buffer(args.buf) then
|
if args.match == 'git' and not diffs.is_fugitive_buffer(args.buf) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
ft.attach(args.buf)
|
diffs.attach(args.buf)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -18,9 +18,9 @@ vim.api.nvim_create_autocmd('OptionSet', {
|
||||||
pattern = 'diff',
|
pattern = 'diff',
|
||||||
callback = function()
|
callback = function()
|
||||||
if vim.wo.diff then
|
if vim.wo.diff then
|
||||||
require('fugitive-ts').attach_diff()
|
require('diffs').attach_diff()
|
||||||
else
|
else
|
||||||
require('fugitive-ts').detach_diff()
|
require('diffs').detach_diff()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
require('spec.helpers')
|
require('spec.helpers')
|
||||||
local highlight = require('fugitive-ts.highlight')
|
local highlight = require('diffs.highlight')
|
||||||
|
|
||||||
describe('highlight', function()
|
describe('highlight', function()
|
||||||
describe('highlight_hunk', function()
|
describe('highlight_hunk', function()
|
||||||
|
|
@ -9,8 +9,8 @@ describe('highlight', function()
|
||||||
ns = vim.api.nvim_create_namespace('fugitive_ts_test')
|
ns = vim.api.nvim_create_namespace('fugitive_ts_test')
|
||||||
local diff_add = vim.api.nvim_get_hl(0, { name = 'DiffAdd' })
|
local diff_add = vim.api.nvim_get_hl(0, { name = 'DiffAdd' })
|
||||||
local diff_delete = vim.api.nvim_get_hl(0, { name = 'DiffDelete' })
|
local diff_delete = vim.api.nvim_get_hl(0, { name = 'DiffDelete' })
|
||||||
vim.api.nvim_set_hl(0, 'FugitiveTsAdd', { bg = diff_add.bg })
|
vim.api.nvim_set_hl(0, 'DiffsAdd', { bg = diff_add.bg })
|
||||||
vim.api.nvim_set_hl(0, 'FugitiveTsDelete', { bg = diff_delete.bg })
|
vim.api.nvim_set_hl(0, 'DiffsDelete', { bg = diff_delete.bg })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function create_buffer(lines)
|
local function create_buffer(lines)
|
||||||
|
|
@ -325,7 +325,7 @@ describe('highlight', function()
|
||||||
local extmarks = get_extmarks(bufnr)
|
local extmarks = get_extmarks(bufnr)
|
||||||
local has_diff_add = false
|
local has_diff_add = false
|
||||||
for _, mark in ipairs(extmarks) do
|
for _, mark in ipairs(extmarks) do
|
||||||
if mark[4] and mark[4].line_hl_group == 'FugitiveTsAdd' then
|
if mark[4] and mark[4].line_hl_group == 'DiffsAdd' then
|
||||||
has_diff_add = true
|
has_diff_add = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
@ -358,7 +358,7 @@ describe('highlight', function()
|
||||||
local extmarks = get_extmarks(bufnr)
|
local extmarks = get_extmarks(bufnr)
|
||||||
local has_diff_delete = false
|
local has_diff_delete = false
|
||||||
for _, mark in ipairs(extmarks) do
|
for _, mark in ipairs(extmarks) do
|
||||||
if mark[4] and mark[4].line_hl_group == 'FugitiveTsDelete' then
|
if mark[4] and mark[4].line_hl_group == 'DiffsDelete' then
|
||||||
has_diff_delete = true
|
has_diff_delete = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
@ -523,7 +523,7 @@ describe('highlight', function()
|
||||||
local extmarks = get_extmarks(bufnr)
|
local extmarks = get_extmarks(bufnr)
|
||||||
local has_diff_add = false
|
local has_diff_add = false
|
||||||
for _, mark in ipairs(extmarks) do
|
for _, mark in ipairs(extmarks) do
|
||||||
if mark[4] and mark[4].line_hl_group == 'FugitiveTsAdd' then
|
if mark[4] and mark[4].line_hl_group == 'DiffsAdd' then
|
||||||
has_diff_add = true
|
has_diff_add = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
@ -554,7 +554,7 @@ describe('highlight', function()
|
||||||
|
|
||||||
local hunk = {
|
local hunk = {
|
||||||
filename = 'test.lua',
|
filename = 'test.lua',
|
||||||
ft = 'lua',
|
ft = 'abap',
|
||||||
lang = nil,
|
lang = nil,
|
||||||
start_line = 1,
|
start_line = 1,
|
||||||
lines = { ' local x = 1', '+local y = 2' },
|
lines = { ' local x = 1', '+local y = 2' },
|
||||||
|
|
@ -587,7 +587,7 @@ describe('highlight', function()
|
||||||
|
|
||||||
local hunk = {
|
local hunk = {
|
||||||
filename = 'test.lua',
|
filename = 'test.lua',
|
||||||
ft = 'lua',
|
ft = 'abap',
|
||||||
lang = nil,
|
lang = nil,
|
||||||
start_line = 1,
|
start_line = 1,
|
||||||
lines = { ' local x = 1', '+local y = 2' },
|
lines = { ' local x = 1', '+local y = 2' },
|
||||||
|
|
@ -618,7 +618,7 @@ describe('highlight', function()
|
||||||
local bufnr = create_buffer(lines)
|
local bufnr = create_buffer(lines)
|
||||||
local hunk = {
|
local hunk = {
|
||||||
filename = 'test.lua',
|
filename = 'test.lua',
|
||||||
ft = 'lua',
|
ft = 'abap',
|
||||||
lang = nil,
|
lang = nil,
|
||||||
start_line = 1,
|
start_line = 1,
|
||||||
lines = hunk_lines,
|
lines = hunk_lines,
|
||||||
|
|
@ -645,7 +645,7 @@ describe('highlight', function()
|
||||||
|
|
||||||
local hunk = {
|
local hunk = {
|
||||||
filename = 'test.lua',
|
filename = 'test.lua',
|
||||||
ft = 'lua',
|
ft = 'abap',
|
||||||
lang = nil,
|
lang = nil,
|
||||||
start_line = 1,
|
start_line = 1,
|
||||||
lines = { ' local x = 1', '+local y = 2' },
|
lines = { ' local x = 1', '+local y = 2' },
|
||||||
|
|
@ -661,7 +661,7 @@ describe('highlight', function()
|
||||||
local extmarks = get_extmarks(bufnr)
|
local extmarks = get_extmarks(bufnr)
|
||||||
local has_diff_add = false
|
local has_diff_add = false
|
||||||
for _, mark in ipairs(extmarks) do
|
for _, mark in ipairs(extmarks) do
|
||||||
if mark[4] and mark[4].line_hl_group == 'FugitiveTsAdd' then
|
if mark[4] and mark[4].line_hl_group == 'DiffsAdd' then
|
||||||
has_diff_add = true
|
has_diff_add = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
@ -692,7 +692,7 @@ describe('highlight', function()
|
||||||
|
|
||||||
local hunk = {
|
local hunk = {
|
||||||
filename = 'test.lua',
|
filename = 'test.lua',
|
||||||
ft = 'lua',
|
ft = 'abap',
|
||||||
lang = nil,
|
lang = nil,
|
||||||
start_line = 1,
|
start_line = 1,
|
||||||
lines = { ' local x = 1', '+local y = 2' },
|
lines = { ' local x = 1', '+local y = 2' },
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
require('spec.helpers')
|
require('spec.helpers')
|
||||||
local fugitive_ts = require('fugitive-ts')
|
local diffs = require('diffs')
|
||||||
|
|
||||||
describe('fugitive-ts', function()
|
describe('diffs', function()
|
||||||
describe('setup', function()
|
describe('setup', function()
|
||||||
it('accepts empty config', function()
|
it('accepts empty config', function()
|
||||||
assert.has_no.errors(function()
|
assert.has_no.errors(function()
|
||||||
fugitive_ts.setup({})
|
diffs.setup({})
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('accepts nil config', function()
|
it('accepts nil config', function()
|
||||||
assert.has_no.errors(function()
|
assert.has_no.errors(function()
|
||||||
fugitive_ts.setup()
|
diffs.setup()
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('accepts full config', function()
|
it('accepts full config', function()
|
||||||
assert.has_no.errors(function()
|
assert.has_no.errors(function()
|
||||||
fugitive_ts.setup({
|
diffs.setup({
|
||||||
enabled = false,
|
enabled = false,
|
||||||
debug = true,
|
debug = true,
|
||||||
debounce_ms = 100,
|
debounce_ms = 100,
|
||||||
|
|
@ -40,7 +40,7 @@ describe('fugitive-ts', function()
|
||||||
|
|
||||||
it('accepts partial config', function()
|
it('accepts partial config', function()
|
||||||
assert.has_no.errors(function()
|
assert.has_no.errors(function()
|
||||||
fugitive_ts.setup({
|
diffs.setup({
|
||||||
debounce_ms = 25,
|
debounce_ms = 25,
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
@ -61,13 +61,13 @@ describe('fugitive-ts', function()
|
||||||
end
|
end
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
fugitive_ts.setup({ enabled = true })
|
diffs.setup({ enabled = true })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not error on empty buffer', function()
|
it('does not error on empty buffer', function()
|
||||||
local bufnr = create_buffer({})
|
local bufnr = create_buffer({})
|
||||||
assert.has_no.errors(function()
|
assert.has_no.errors(function()
|
||||||
fugitive_ts.attach(bufnr)
|
diffs.attach(bufnr)
|
||||||
end)
|
end)
|
||||||
delete_buffer(bufnr)
|
delete_buffer(bufnr)
|
||||||
end)
|
end)
|
||||||
|
|
@ -80,7 +80,7 @@ describe('fugitive-ts', function()
|
||||||
'+local y = 2',
|
'+local y = 2',
|
||||||
})
|
})
|
||||||
assert.has_no.errors(function()
|
assert.has_no.errors(function()
|
||||||
fugitive_ts.attach(bufnr)
|
diffs.attach(bufnr)
|
||||||
end)
|
end)
|
||||||
delete_buffer(bufnr)
|
delete_buffer(bufnr)
|
||||||
end)
|
end)
|
||||||
|
|
@ -88,9 +88,9 @@ describe('fugitive-ts', function()
|
||||||
it('is idempotent', function()
|
it('is idempotent', function()
|
||||||
local bufnr = create_buffer({})
|
local bufnr = create_buffer({})
|
||||||
assert.has_no.errors(function()
|
assert.has_no.errors(function()
|
||||||
fugitive_ts.attach(bufnr)
|
diffs.attach(bufnr)
|
||||||
fugitive_ts.attach(bufnr)
|
diffs.attach(bufnr)
|
||||||
fugitive_ts.attach(bufnr)
|
diffs.attach(bufnr)
|
||||||
end)
|
end)
|
||||||
delete_buffer(bufnr)
|
delete_buffer(bufnr)
|
||||||
end)
|
end)
|
||||||
|
|
@ -110,22 +110,22 @@ describe('fugitive-ts', function()
|
||||||
end
|
end
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
fugitive_ts.setup({ enabled = true })
|
diffs.setup({ enabled = true })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not error on unattached buffer', function()
|
it('does not error on unattached buffer', function()
|
||||||
local bufnr = create_buffer({})
|
local bufnr = create_buffer({})
|
||||||
assert.has_no.errors(function()
|
assert.has_no.errors(function()
|
||||||
fugitive_ts.refresh(bufnr)
|
diffs.refresh(bufnr)
|
||||||
end)
|
end)
|
||||||
delete_buffer(bufnr)
|
delete_buffer(bufnr)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not error on attached buffer', function()
|
it('does not error on attached buffer', function()
|
||||||
local bufnr = create_buffer({})
|
local bufnr = create_buffer({})
|
||||||
fugitive_ts.attach(bufnr)
|
diffs.attach(bufnr)
|
||||||
assert.has_no.errors(function()
|
assert.has_no.errors(function()
|
||||||
fugitive_ts.refresh(bufnr)
|
diffs.refresh(bufnr)
|
||||||
end)
|
end)
|
||||||
delete_buffer(bufnr)
|
delete_buffer(bufnr)
|
||||||
end)
|
end)
|
||||||
|
|
@ -133,7 +133,7 @@ describe('fugitive-ts', function()
|
||||||
|
|
||||||
describe('config options', function()
|
describe('config options', function()
|
||||||
it('enabled=false prevents highlighting', function()
|
it('enabled=false prevents highlighting', function()
|
||||||
fugitive_ts.setup({ enabled = false })
|
diffs.setup({ enabled = false })
|
||||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {
|
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {
|
||||||
'M test.lua',
|
'M test.lua',
|
||||||
|
|
@ -141,9 +141,9 @@ describe('fugitive-ts', function()
|
||||||
' local x = 1',
|
' local x = 1',
|
||||||
'+local y = 2',
|
'+local y = 2',
|
||||||
})
|
})
|
||||||
fugitive_ts.attach(bufnr)
|
diffs.attach(bufnr)
|
||||||
|
|
||||||
local ns = vim.api.nvim_create_namespace('fugitive_ts')
|
local ns = vim.api.nvim_create_namespace('diffs')
|
||||||
local extmarks = vim.api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, {})
|
local extmarks = vim.api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, {})
|
||||||
assert.are.equal(0, #extmarks)
|
assert.are.equal(0, #extmarks)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
require('spec.helpers')
|
require('spec.helpers')
|
||||||
local parser = require('fugitive-ts.parser')
|
local parser = require('diffs.parser')
|
||||||
|
|
||||||
describe('parser', function()
|
describe('parser', function()
|
||||||
describe('parse_buffer', function()
|
describe('parse_buffer', function()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue