Skip to content

Commit

Permalink
Merge pull request #71 from maxmx03/69-configuring-highlight-of-type-…
Browse files Browse the repository at this point in the history
…variable

69 configuring highlight of type variable
  • Loading branch information
maxmx03 committed Mar 28, 2024
2 parents a0f0226 + 5c5f127 commit 1114dbf
Show file tree
Hide file tree
Showing 16 changed files with 407 additions and 102 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Test

on: [push]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Stylua
uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: --check .


docs:
runs-on: ubuntu-latest
name: pandoc to vimdoc
steps:
- uses: actions/checkout@v3
- name: panvimdoc
uses: kdheepak/panvimdoc@main
with:
vimdoc: solarized.nvim
treesitter: true
version: "NVIM v0.9.4"
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'chore(doc): auto generate docs'
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"

test:
name: Run Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- uses: rhysd/action-setup-vim@v1
with:
neovim: true

- name: luajit
uses: leafo/gh-actions-lua@v10
with:
luaVersion: "luajit-2.1.0-beta3"

- name: luarocks
uses: leafo/gh-actions-luarocks@v4

- name: run test
shell: bash
run: |
luarocks install luacheck
luarocks install vusted
vusted ./tests
3 changes: 3 additions & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"diagnostics.disable": ["undefined-field"]
}
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM archlinux
WORKDIR /dracula
COPY . .
RUN pacman -Syu --noconfirm
RUN pacman -S luarocks neovim gcc lua51 --noconfirm
RUN luarocks install luacheck && luarocks --lua-version=5.1 install vusted
CMD [ "vusted", "./tests" ]
67 changes: 3 additions & 64 deletions doc/solarized.nvim.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*solarized.nvim.txt* For NVIM v0.9.1 Last change: 2023 December 24
*solarized.nvim.txt* For NVIM v0.9.4 Last change: 2024 March 28

==============================================================================
Table of Contents *solarized.nvim-table-of-contents*
Expand All @@ -22,6 +22,7 @@ Table of Contents *solarized.nvim-table-of-contents*
- Contributing |solarized.nvim-contributing|
- Designed by |solarized.nvim-designed-by|
- Credits and Reference 🎉 |solarized.nvim-credits-and-reference-🎉|
1. Links |solarized.nvim-links|

Solarized is a sixteen color palette (eight monotones, eight accent colors)
designed for use with terminal and gui applications. click here to learn more
Expand Down Expand Up @@ -396,69 +397,7 @@ HOW TO GET COLOR TINTS ~

CONTRIBUTING *solarized.nvim-contributing*

Thank you for your interest in contributing to this project! To ensure a smooth
collaboration, please follow the guidelines below:

1. **Branching**: Make your changes on the `dev` branch. Avoid making direct
changes to the `main` branch.


2. **Testing**: Before submitting a pull request, run the `./test.py` script to
ensure that your changes pass all necessary tests. This step helps maintain the
quality and stability of the project. Ensure that the following dependencies
are installed for running tests:

>bash
sudo apt install luarocks
sudo luarocks install luacheck
sudo luarocks install vusted
cargo install stylua
<

>bash
./test.py
<

>bash
ok 1 - Color Conversions Convert hex to RGB
ok 2 - Color Conversions Convert RGB to hex
ok 3 - Color Conversions Darken the color by percentage
ok 4 - Color Conversions Lighten the color by percentage
ok 5 - Color Conversions Blend colors
ok 6 - Configuration Default configuration
ok 7 - Configuration Unique configuration table instances
ok 8 - Configuration Extend default configuration
ok 9 - Initialization Loads without encountering any errors
ok 10 - Initialization Background is set to light
ok 11 - Palette Extend solarized color palette
ok 12 - Palette Correct any invalid colors when extending the solarized palette
ok 13 - Setup Customizing Highlight Groups
ok 14 - Setup Changing Comment Style
ok 15 - Setup Changing Function Style
ok 16 - Setup Customizable Highlight Groups Without Losing Previous Configuration
ok 17 - Setup Ability to Change the Default Theme
1..17
# Success: 17
<


3. **Pull Request**: When submitting a pull request, select the `dev` branch as
the target branch. This ensures that your changes will be merged into the `dev`
branch for further review and integration.


4. **Provide Details**: Provide a clear and descriptive title and description for
your pull request, explaining the purpose and scope of your changes.


5. **Review Process**: Wait for the maintainer to review your pull request. The
maintainers will review your changes before merging.


6. **Final Approval**: Once your changes have been reviewed and approved, the
project maintainer will handle merging your changes into the `main` branch.


Pull requests are welcome and appreciated.


DESIGNED BY *solarized.nvim-designed-by*
Expand Down
7 changes: 6 additions & 1 deletion lua/solarized/highlights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ function M.custom_hl(highlights)

for highlight_name, highlight_value in pairs(highlights) do
local highlight = get_hl(highlight_name)
local val = {}

local val = vim.tbl_extend('force', highlight, highlight_value)
if highlight_value.link then
val = highlight_value
else
val = vim.tbl_extend('force', highlight, highlight_value)
end

vim.api.nvim_set_hl(0, highlight_name, val)
end
Expand Down
66 changes: 33 additions & 33 deletions lua/solarized/themes/default/syntax.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,43 @@ return function(c, config)
'Comment',
{ fg = c.base01, italic = true },
{ styles = config.styles.comments }
) -- any comment
set_hl('Constant', { fg = c.cyan }, { styles = config.styles.constants }) -- any constant
set_hl('String', { fg = c.cyan }) -- a string constant: "this is a string"
set_hl('Character', { link = 'String' }) -- a character constant: 'c', '\n'
set_hl('Number', { fg = c.magenta }, { styles = config.styles.numbers }) -- a number constant: 234, 0xff
set_hl('Boolean', { link = 'Constant' }) -- a boolean constant: TRUE, false
set_hl('Float', { link = 'Number' }) -- a floating point constant: 2.3e10
) -- any comment
set_hl('Constant', { fg = c.cyan }, { styles = config.styles.constants }) -- any constant
set_hl('String', { fg = c.cyan }) -- a string constant: "this is a string"
set_hl('Character', { link = 'String' }) -- a character constant: 'c', '\n'
set_hl('Number', { fg = c.magenta }, { styles = config.styles.numbers }) -- a number constant: 234, 0xff
set_hl('Boolean', { link = 'Constant' }) -- a boolean constant: TRUE, false
set_hl('Float', { link = 'Number' }) -- a floating point constant: 2.3e10
set_hl('Identifier', { fg = c.blue }, { styles = config.styles.variables }) -- any variable name
set_hl('Function', { fg = c.blue }, { styles = config.styles.functions }) -- function name (also: methods for classes)
set_hl('Statement', { fg = c.green }) -- any statement
set_hl('Conditional', { link = 'Statement' }) -- if, then, else, endif, switch, etc.
set_hl('Repeat', { link = 'Statement' }) -- for, do, while, etc.
set_hl('Label', { link = 'Statement' }) -- case, default, etc.
set_hl('Operator', { link = 'Statement' }) -- "sizeof", "+", "*", etc.
set_hl('Function', { fg = c.blue }, { styles = config.styles.functions }) -- function name (also: methods for classes)
set_hl('Statement', { fg = c.green }) -- any statement
set_hl('Conditional', { link = 'Statement' }) -- if, then, else, endif, switch, etc.
set_hl('Repeat', { link = 'Statement' }) -- for, do, while, etc.
set_hl('Label', { link = 'Statement' }) -- case, default, etc.
set_hl('Operator', { link = 'Statement' }) -- "sizeof", "+", "*", etc.
set_hl(
'Keyword',
{ fg = c.base1, bold = true },
{ styles = config.styles.keywords }
) -- any other keyword
set_hl('Exception', { link = 'Statement' }) -- try, catch, throw
set_hl('PreProc', { fg = c.orange }) -- generic Preprocessor
set_hl('Include', { link = 'PreProc' }) -- preprocessor #include
set_hl('Define', { link = 'PreProc' }) -- preprocessor #define
set_hl('Macro', { link = 'PreProc' }) -- same as Define
set_hl('PreCondit', { link = 'PreProc' }) -- preprocessor #if, #else, #endif, etc.
) -- any other keyword
set_hl('Exception', { link = 'Statement' }) -- try, catch, throw
set_hl('PreProc', { fg = c.orange }) -- generic Preprocessor
set_hl('Include', { link = 'PreProc' }) -- preprocessor #include
set_hl('Define', { link = 'PreProc' }) -- preprocessor #define
set_hl('Macro', { link = 'PreProc' }) -- same as Define
set_hl('PreCondit', { link = 'PreProc' }) -- preprocessor #if, #else, #endif, etc.
set_hl('Type', { fg = c.yellow }, { styles = config.styles.types }) -- int, long, char, etc.
set_hl('StorageClass', { fg = c.yellow }) -- static, register, volatile, etc.
set_hl('Structure', { fg = c.yellow }) -- struct, union, enum, etc.
set_hl('Typedef', { fg = c.yellow }) -- A typedef
set_hl('Special', { fg = c.red }) -- special symbol
set_hl('SpecialChar', { link = 'Special' }) -- special character in a constant
set_hl('Tag', { link = 'Special' }) -- you can use CTRL-] on this
set_hl('Delimiter', { fg = c.base00 }) -- character that needs attention
set_hl('SpecialComment', { link = 'Special' }) -- special things inside a comment
set_hl('Debug', { link = 'Special' }) -- debugging statements
set_hl('Underlined', { fg = c.violet }) --text that stands out, HTML links
set_hl('Ignore') --left blank, hidden |hl-Ignore|
set_hl('Error', { fg = c.error, bold = true }) --any erroneous construct
set_hl('Todo', { fg = c.magenta, bold = true }) --anything that needs extra attention; mostly the keywords TODO FIXME and XXX
set_hl('StorageClass', { fg = c.yellow }) -- static, register, volatile, etc.
set_hl('Structure', { fg = c.yellow }) -- struct, union, enum, etc.
set_hl('Typedef', { fg = c.yellow }) -- A typedef
set_hl('Special', { fg = c.red }) -- special symbol
set_hl('SpecialChar', { link = 'Special' }) -- special character in a constant
set_hl('Tag', { link = 'Special' }) -- you can use CTRL-] on this
set_hl('Delimiter', { fg = c.base00 }) -- character that needs attention
set_hl('SpecialComment', { link = 'Special' }) -- special things inside a comment
set_hl('Debug', { link = 'Special' }) -- debugging statements
set_hl('Underlined', { fg = c.violet }) --text that stands out, HTML links
set_hl('Ignore') --left blank, hidden |hl-Ignore|
set_hl('Error', { fg = c.error, bold = true }) --any erroneous construct
set_hl('Todo', { fg = c.magenta, bold = true }) --anything that needs extra attention; mostly the keywords TODO FIXME and XXX
end
5 changes: 3 additions & 2 deletions lua/solarized/themes/default/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ return function(c, config)
local utils = require('solarized.utils')
local set_hl = utils.set_hl

--[[ Highlight capture names as of nvim-treesitter commit `6806d7a` ]]--
--[[ Highlight capture names as of nvim-treesitter commit `6806d7a` ]]
--

-- Identifiers
set_hl('@variable', { link = 'Identifier' }) -- various variable names
Expand All @@ -28,7 +29,7 @@ return function(c, config)
set_hl('@string.special', { link = 'SpecialChar' }) -- other special strings (e.g. dates)
set_hl('@string.special.symbol', { fg = c.violet }) -- symbols or atoms
set_hl('@string.special.url', { link = 'Underlined' }) -- URIs (e.g. hyperlinks)
set_hl('@string.special.path', { link = 'Underlined'}) -- filenames
set_hl('@string.special.path', { link = 'Underlined' }) -- filenames
set_hl('@character', { link = 'String' }) -- character literals
set_hl('@character.special', { link = '@string.special' }) -- special characters (e.g. wildcards)
set_hl('@boolean', { link = 'Boolean' }) -- boolean literals
Expand Down
5 changes: 3 additions & 2 deletions lua/solarized/themes/neo/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ return function(c, config)
local utils = require('solarized.utils')
local set_hl = utils.set_hl

--[[ Highlight capture names as of nvim-treesitter commit `6806d7a` ]]--
--[[ Highlight capture names as of nvim-treesitter commit `6806d7a` ]]
--

-- Identifiers
set_hl('@variable', { link = 'Identifier' }) -- various variable names
Expand All @@ -28,7 +29,7 @@ return function(c, config)
set_hl('@string.special', { link = 'Constant' }) -- other special strings (e.g. dates)
set_hl('@string.special.symbol', { fg = c.violet }) -- symbols or atoms
set_hl('@string.special.url', { link = 'Underlined' }) -- URIs (e.g. hyperlinks)
set_hl('@string.special.path', { link = 'Underlined'}) -- filenames
set_hl('@string.special.path', { link = 'Underlined' }) -- filenames
set_hl('@character', { link = 'String' }) -- character literals
set_hl('@character.special', { link = 'Constant' }) -- special characters (e.g. wildcards)
set_hl('@boolean', { link = 'Constant' }) -- boolean literals
Expand Down
7 changes: 7 additions & 0 deletions stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
column_width = 80
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
call_parentheses = "Always"
collapse_simple_statement = "ConditionalOnly"
27 changes: 27 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/python3

import subprocess
import sys


def run_commands(commands):
for command in commands:
process = subprocess.Popen(command, shell=True)
process.wait()


if __name__ == '__main__':
install_dependencies = False
if len(sys.argv) > 1 and sys.argv[1] == '--install':
install_dependencies = True

commands = []
if install_dependencies:
commands.append('cargo install stylua')
commands.append('sudo luarocks install luacheck')
commands.append('sudo luarocks install vusted')

commands.append('stylua . -f ./stylua.toml')
commands.append('vusted ./tests')

run_commands(commands)
19 changes: 19 additions & 0 deletions tests/autocmd_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
describe('Autocmd', function()
test('Solarized Highlights is being created', function()
vim.cmd.colorscheme('solarized')
local todo = {
'TODO',
'WARN',
'TEST',
'PERF',
'NOTE',
'HACK',
'FIX',
}

for _, name in pairs(todo) do
local output = vim.api.nvim_get_hl(0, { name = 'SolarizedToken' .. name })
assert.is_true(type(output.fg) == 'number')
end
end)
end)
47 changes: 47 additions & 0 deletions tests/colors_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
local colorhelper = require('solarized.utils.colors')
local solarized_palette = require('solarized.palette')

describe('Color Conversions', function()
test('Convert hex to RGB', function()
local colors = solarized_palette.get_colors()
local red, green, blue = colorhelper.hex_to_rgb(colors.yellow)
local expect = { red = 181, green = 137, blue = 0 }

assert.are.same(expect.red, red)
assert.are.same(expect.green, green)
assert.are.same(expect.blue, blue)
end)

test('Convert RGB to hex', function()
local colors = solarized_palette.get_colors()
local yellow = { red = 181, green = 137, blue = 0 }
local output = colorhelper.rgb_to_hex(yellow.red, yellow.green, yellow.blue)
local expect = colors.yellow

assert.equals(expect, string.lower(output))
end)

test('Darken the color by percentage', function()
local colors = solarized_palette.get_colors()
local output = colorhelper.darken(colors.green, 100)
local expect = '#000000'
assert.equals(expect, output)
end)

test('Lighten the color by percentage', function()
local colors = solarized_palette.get_colors()
local output = colorhelper.lighten(colors.green, 100)
local expect = '#ffffff'
assert.equals(expect, output)
end)

test('Blend colors', function()
local blend = require('solarized.utils.colors').blend
local alpha = 0.15
local expect = '#27383f'

local output = blend('#73daca', '#1a1b26', alpha)

assert.equals(output, expect)
end)
end)
Loading

0 comments on commit 1114dbf

Please sign in to comment.