Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add pre-commits #25

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: stylua
if: success() || failure()
uses: pre-commit/[email protected]
with:
extra_args: stylua-github --all-files

- name: codespell
if: success() || failure()
uses: pre-commit/[email protected]
with:
extra_args: codespell --all-files
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- repo: https://github.com/JohnnyMorganz/StyLua
rev: v2.0.1
hooks:
- id: stylua-github
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v3.6.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
install:
pre-commit install -t pre-commit -t commit-msg

lint:
pre-commit run --all-files
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,22 @@ lua require('smear_cursor').cursor_color = '#d3cdc3'
- No smear when buffer is duplicated
- No smear outside buffer (further than the last line)
- No smear through wrapped lines


# Contributing

Please feel free to open an issue or a pull request if you have any suggestions or improvements!
This project uses [pre-commit](https://pre-commit.com/) hooks to ensure code quality (with [StyLua](https://github.com/JohnnyMorganz/StyLua)) and meaningful commit messages (following [Conventional Commits](https://www.conventionalcommits.org/))


## Requirements

- Neovim >= 0.10.2
- Make
- pre-commit (`pip install pre-commit`)


## Setup

1. Clone the repository
2. Run `make install` to install the pre-commit hooks
4 changes: 2 additions & 2 deletions lua/smear_cursor/draw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ M.draw_line = function(row_start, col_start, row_end, col_end, end_reached)
if L.slope_abs <= config.max_slope_horizontal then
-- logging.debug("Drawing horizontal-ish line")
-- if math.abs(L.row_shift) > 1 then
-- -- Avoid bulding on thin lines
-- -- Avoid bulging on thin lines
-- L.thickness = math.max(L.thickness, 1)
-- end
draw_horizontal_ish_line(L, draw_vertically_shifted_block)
Expand All @@ -447,7 +447,7 @@ M.draw_line = function(row_start, col_start, row_end, col_end, end_reached)
if L.slope_abs >= config.min_slope_vertical then
-- logging.debug("Drawing vertical-ish line")
-- if math.abs(L.col_shift) > 1 then
-- -- Avoid bulding on thin lines
-- -- Avoid bulging on thin lines
-- L.thickness = math.max(L.thickness, 1)
-- end
draw_vertical_ish_line(L, draw_horizontally_shifted_block)
Expand Down
4 changes: 2 additions & 2 deletions stylua.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
indent_type = "Tabs"
indent_width = 2
indent_width = 4
column_width = 120

[sort_requires]
enabled = true

33 changes: 16 additions & 17 deletions tests/test.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
-- Instructions: open this file in Neovim and run `source %`


local foldable_lines = {
{
"Hello",
Expand All @@ -20,9 +19,9 @@ local foldable_lines = {
-- Line with extmark below

-- Line with 🎉 emoji



--
--
--
-- Also test:
-- - Popup menus
-- - Sidebar
Expand All @@ -47,7 +46,6 @@ local foldable_lines = {
-- ───────────────┘│
-- 4───1───2───3───4


-- This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line.

--
Expand Down Expand Up @@ -80,7 +78,6 @@ local foldable_lines = {
-- ....
--


local buffer_id = vim.api.nvim_get_current_buf()
local ns = vim.api.nvim_create_namespace("smear_cursor_test")
vim.api.nvim_buf_clear_namespace(buffer_id, ns, 0, -1)
Expand All @@ -92,28 +89,30 @@ vim.cmd([[
setlocal concealcursor=n
]])

vim.api.nvim_buf_set_extmark(buffer_id, ns, 15, 0, {
virt_lines = {{{"Extmark above", "Question"}}},
local extmarks_first_line = 14

vim.api.nvim_buf_set_extmark(buffer_id, ns, extmarks_first_line, 0, {
virt_lines = { { { "Extmark above", "Question" } } },
virt_lines_above = true,
})

vim.api.nvim_buf_set_extmark(buffer_id, ns, 16, 0, {
virt_text = {{"*", "Question"}},
vim.api.nvim_buf_set_extmark(buffer_id, ns, extmarks_first_line + 1, 0, {
virt_text = { { "*", "Question" } },
virt_text_pos = "eol",
})

vim.api.nvim_buf_set_extmark(buffer_id, ns, 17, 10, {
virt_text = {{"*", "Question"}},
vim.api.nvim_buf_set_extmark(buffer_id, ns, extmarks_first_line + 2, 10, {
virt_text = { { "*", "Question" } },
virt_text_pos = "overlay",
})

vim.api.nvim_buf_set_extmark(buffer_id, ns, 18, 10, {
virt_text = {{"*", "Question"}},
vim.api.nvim_buf_set_extmark(buffer_id, ns, extmarks_first_line + 3, 10, {
virt_text = { { "*", "Question" } },
virt_text_pos = "inline",
})

vim.api.nvim_buf_set_extmark(buffer_id, ns, 19, 0, {
virt_lines = {{{"Extmark below", "Question"}}},
vim.api.nvim_buf_set_extmark(buffer_id, ns, extmarks_first_line + 4, 0, {
virt_lines = { { { "Extmark below", "Question" } } },
})

local function create_float(content, row, col)
Expand All @@ -131,4 +130,4 @@ local function create_float(content, row, col)
})
end

create_float("Floating window", 23, 10)
create_float("Floating window", 22, 10)