Merge pull request #35 from barrettruth/feat/deslop
feat: qol oss improvements
This commit is contained in:
commit
8f7442eaa2
8 changed files with 152 additions and 72 deletions
77
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
77
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
name: Bug Report
|
||||
description: Report a bug
|
||||
title: "bug: "
|
||||
labels: [bug]
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Prerequisites
|
||||
options:
|
||||
- label: I have searched [existing issues](https://github.com/barrettruth/fugitive-ts.nvim/issues)
|
||||
required: true
|
||||
- label: I have updated to the latest version
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Neovim version"
|
||||
description: "Output of `nvim --version`"
|
||||
render: text
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Operating system"
|
||||
placeholder: "e.g. Arch Linux, macOS 15, Ubuntu 24.04"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Description
|
||||
description: What happened? What did you expect?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: Minimal steps to trigger the bug
|
||||
value: |
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Health check"
|
||||
description: "Output of `:checkhealth fugitive-ts`"
|
||||
render: text
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Minimal reproduction
|
||||
description: |
|
||||
Save the script below as `repro.lua`, edit if needed, and run:
|
||||
```
|
||||
nvim -u repro.lua
|
||||
```
|
||||
Confirm the bug reproduces with this config before submitting.
|
||||
render: lua
|
||||
value: |
|
||||
vim.env.LAZY_STDPATH = '.repro'
|
||||
load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))()
|
||||
require('lazy.nvim').setup({
|
||||
spec = {
|
||||
'tpope/vim-fugitive',
|
||||
{
|
||||
'barrettruth/fugitive-ts.nvim',
|
||||
opts = {},
|
||||
},
|
||||
},
|
||||
})
|
||||
validations:
|
||||
required: true
|
||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Questions
|
||||
url: https://github.com/barrettruth/fugitive-ts.nvim/discussions
|
||||
about: Ask questions and discuss ideas
|
||||
28
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
28
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
name: Feature Request
|
||||
description: Suggest a feature
|
||||
title: "feat: "
|
||||
labels: [enhancement]
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Prerequisites
|
||||
options:
|
||||
- label: I have searched [existing issues](https://github.com/barrettruth/fugitive-ts.nvim/issues)
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Problem
|
||||
description: What problem does this solve?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Proposed solution
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Alternatives considered
|
||||
|
|
@ -70,10 +70,6 @@ CONFIGURATION *fugitive-ts-config*
|
|||
Vim syntax highlighting options (experimental).
|
||||
See |fugitive-ts.VimConfig| for fields.
|
||||
|
||||
{diffsplit} (table, default: see below)
|
||||
Diffsplit highlighting options.
|
||||
See |fugitive-ts.DiffsplitConfig| for fields.
|
||||
|
||||
{highlights} (table, default: see below)
|
||||
Controls which highlight features are enabled.
|
||||
See |fugitive-ts.Highlights| for fields.
|
||||
|
|
@ -102,15 +98,6 @@ CONFIGURATION *fugitive-ts-config*
|
|||
this many lines. Lower than the treesitter default
|
||||
due to the per-character cost of |synID()|.
|
||||
|
||||
*fugitive-ts.DiffsplitConfig*
|
||||
Diffsplit config fields: ~
|
||||
{enabled} (boolean, default: true)
|
||||
Override diff highlight foreground colors in
|
||||
|:Gdiffsplit| and |:Gvdiffsplit| windows so
|
||||
treesitter syntax is visible through the diff
|
||||
backgrounds. Uses window-local 'winhighlight'
|
||||
and only applies to fugitive-owned buffers.
|
||||
|
||||
*fugitive-ts.Highlights*
|
||||
Highlights table fields: ~
|
||||
{background} (boolean, default: true)
|
||||
|
|
|
|||
|
|
@ -1,21 +1,6 @@
|
|||
local M = {}
|
||||
|
||||
local debug_enabled = false
|
||||
|
||||
---@param enabled boolean
|
||||
function M.set_debug(enabled)
|
||||
debug_enabled = enabled
|
||||
end
|
||||
|
||||
---@param msg string
|
||||
---@param ... any
|
||||
local function dbg(msg, ...)
|
||||
if not debug_enabled then
|
||||
return
|
||||
end
|
||||
local formatted = string.format(msg, ...)
|
||||
vim.notify('[fugitive-ts] ' .. formatted, vim.log.levels.DEBUG)
|
||||
end
|
||||
local dbg = require('fugitive-ts.log').dbg
|
||||
|
||||
---@param bufnr integer
|
||||
---@param ns integer
|
||||
|
|
|
|||
|
|
@ -10,9 +10,6 @@
|
|||
---@field enabled boolean
|
||||
---@field max_lines integer
|
||||
|
||||
---@class fugitive-ts.DiffsplitConfig
|
||||
---@field enabled boolean
|
||||
|
||||
---@class fugitive-ts.Config
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
|
|
@ -21,7 +18,6 @@
|
|||
---@field treesitter fugitive-ts.TreesitterConfig
|
||||
---@field vim fugitive-ts.VimConfig
|
||||
---@field highlights fugitive-ts.Highlights
|
||||
---@field diffsplit fugitive-ts.DiffsplitConfig
|
||||
|
||||
---@class fugitive-ts
|
||||
---@field attach fun(bufnr?: integer)
|
||||
|
|
@ -30,6 +26,7 @@
|
|||
local M = {}
|
||||
|
||||
local highlight = require('fugitive-ts.highlight')
|
||||
local log = require('fugitive-ts.log')
|
||||
local parser = require('fugitive-ts.parser')
|
||||
|
||||
local ns = vim.api.nvim_create_namespace('fugitive_ts')
|
||||
|
|
@ -84,9 +81,6 @@ local default_config = {
|
|||
background = true,
|
||||
gutter = true,
|
||||
},
|
||||
diffsplit = {
|
||||
enabled = true,
|
||||
},
|
||||
}
|
||||
|
||||
---@type fugitive-ts.Config
|
||||
|
|
@ -104,15 +98,7 @@ function M.is_fugitive_buffer(bufnr)
|
|||
return vim.api.nvim_buf_get_name(bufnr):match('^fugitive://') ~= nil
|
||||
end
|
||||
|
||||
---@param msg string
|
||||
---@param ... any
|
||||
local function dbg(msg, ...)
|
||||
if not config.debug then
|
||||
return
|
||||
end
|
||||
local formatted = string.format(msg, ...)
|
||||
vim.notify('[fugitive-ts] ' .. formatted, vim.log.levels.DEBUG)
|
||||
end
|
||||
local dbg = log.dbg
|
||||
|
||||
---@param bufnr integer
|
||||
local function highlight_buffer(bufnr)
|
||||
|
|
@ -256,7 +242,7 @@ local DIFF_WINHIGHLIGHT = table.concat({
|
|||
}, ',')
|
||||
|
||||
function M.attach_diff()
|
||||
if not config.enabled or not config.diffsplit.enabled then
|
||||
if not config.enabled then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -308,15 +294,8 @@ function M.setup(opts)
|
|||
treesitter = { opts.treesitter, 'table', true },
|
||||
vim = { opts.vim, 'table', true },
|
||||
highlights = { opts.highlights, 'table', true },
|
||||
diffsplit = { opts.diffsplit, 'table', true },
|
||||
})
|
||||
|
||||
if opts.diffsplit then
|
||||
vim.validate({
|
||||
['diffsplit.enabled'] = { opts.diffsplit.enabled, 'boolean', true },
|
||||
})
|
||||
end
|
||||
|
||||
if opts.treesitter then
|
||||
vim.validate({
|
||||
['treesitter.enabled'] = { opts.treesitter.enabled, 'boolean', true },
|
||||
|
|
@ -338,9 +317,18 @@ function M.setup(opts)
|
|||
})
|
||||
end
|
||||
|
||||
if opts.debounce_ms and opts.debounce_ms < 0 then
|
||||
error('fugitive-ts: debounce_ms must be >= 0')
|
||||
end
|
||||
if opts.treesitter and opts.treesitter.max_lines and opts.treesitter.max_lines < 1 then
|
||||
error('fugitive-ts: treesitter.max_lines must be >= 1')
|
||||
end
|
||||
if opts.vim and opts.vim.max_lines and opts.vim.max_lines < 1 then
|
||||
error('fugitive-ts: vim.max_lines must be >= 1')
|
||||
end
|
||||
|
||||
config = vim.tbl_deep_extend('force', default_config, opts)
|
||||
parser.set_debug(config.debug)
|
||||
highlight.set_debug(config.debug)
|
||||
log.set_enabled(config.debug)
|
||||
|
||||
compute_highlight_groups()
|
||||
|
||||
|
|
|
|||
19
lua/fugitive-ts/log.lua
Normal file
19
lua/fugitive-ts/log.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
local M = {}
|
||||
|
||||
local enabled = false
|
||||
|
||||
---@param val boolean
|
||||
function M.set_enabled(val)
|
||||
enabled = val
|
||||
end
|
||||
|
||||
---@param msg string
|
||||
---@param ... any
|
||||
function M.dbg(msg, ...)
|
||||
if not enabled then
|
||||
return
|
||||
end
|
||||
vim.notify('[fugitive-ts] ' .. string.format(msg, ...), vim.log.levels.DEBUG)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -9,22 +9,7 @@
|
|||
|
||||
local M = {}
|
||||
|
||||
local debug_enabled = false
|
||||
|
||||
---@param enabled boolean
|
||||
function M.set_debug(enabled)
|
||||
debug_enabled = enabled
|
||||
end
|
||||
|
||||
---@param msg string
|
||||
---@param ... any
|
||||
local function dbg(msg, ...)
|
||||
if not debug_enabled then
|
||||
return
|
||||
end
|
||||
local formatted = string.format(msg, ...)
|
||||
vim.notify('[fugitive-ts] ' .. formatted, vim.log.levels.DEBUG)
|
||||
end
|
||||
local dbg = require('fugitive-ts.log').dbg
|
||||
|
||||
---@param filename string
|
||||
---@return string?
|
||||
|
|
@ -116,7 +101,13 @@ function M.parse_buffer(bufnr)
|
|||
local prefix = line:sub(1, 1)
|
||||
if prefix == ' ' or prefix == '+' or prefix == '-' then
|
||||
table.insert(hunk_lines, line)
|
||||
elseif line == '' or line:match('^[MADRC%?!]%s+') or line:match('^%a') then
|
||||
elseif
|
||||
line == ''
|
||||
or line:match('^[MADRC%?!]%s+')
|
||||
or line:match('^diff ')
|
||||
or line:match('^index ')
|
||||
or line:match('^Binary ')
|
||||
then
|
||||
flush_hunk()
|
||||
current_filename = nil
|
||||
current_ft = nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue